- 
          
- 
        Couldn't load subscription status. 
- Fork 1.6k
docs(js): Update span metrics instrumentation examples #15320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
- Add four comprehensive real-world examples with sample repositories - E-Commerce Checkout Flow (Crash Commerce) - Media Upload with Background Processing (SnapTrace) - Search Autocomplete (NullFlix) - Manual LLM Instrumentation (Customer Service Bot) - Fix high-cardinality span name in payment processing - Add missing gen_ai.response.model attribute to AI agent span - Include implementation guidance and monitoring recommendations
| The latest updates on your projects. Learn more about Vercel for GitHub. 
 1 Skipped Deployment
 | 
| }, | ||
| }, | ||
| async (toolSpan) => { | ||
| const toolOutput = await executeKnowledgeBaseSearch(toolCall.function.arguments); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Function executeKnowledgeBaseSearch is called but searchKnowledgeBase is defined, causing a ReferenceError.
Severity: CRITICAL | Confidence: 1.00
🔍 Detailed Analysis
The code at line 706 attempts to call executeKnowledgeBaseSearch(toolCall.function.arguments), but the corresponding function is defined as searchKnowledgeBase at line 740+. This mismatch will cause a ReferenceError when an LLM response includes tool calls and the system attempts to execute them.
💡 Suggested Fix
Rename executeKnowledgeBaseSearch to searchKnowledgeBase at line 706 to match the function definition.
🤖 Prompt for AI Agent
Fix this bug. In docs/platforms/javascript/common/tracing/span-metrics/examples.mdx at
line 706: The code at line 706 attempts to call
`executeKnowledgeBaseSearch(toolCall.function.arguments)`, but the corresponding
function is defined as `searchKnowledgeBase` at line 740+. This mismatch will cause a
`ReferenceError` when an LLM response includes tool calls and the system attempts to
execute them.
Did we get this right? 👍 / 👎 to inform future reviews.
| span?.setAttribute('job.id', uploadData.jobId); | ||
|  | ||
| // Update UI to show processing status | ||
| updateUploadStatus(uploadId, 'processing'); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Variable uploadId is used at line 224 without being declared or defined, leading to a ReferenceError.
Severity: CRITICAL | Confidence: 1.00
🔍 Detailed Analysis
In the handleUpload function, uploadId is referenced at line 224 within updateUploadStatus(uploadId, 'processing'). However, uploadId is never declared or defined as a variable or function parameter within its scope. This will result in a ReferenceError: uploadId is not defined when the upload completes successfully.
💡 Suggested Fix
Declare and assign a value to uploadId before its usage at line 224, likely by extracting it from uploadData.
🤖 Prompt for AI Agent
Fix this bug. In docs/platforms/javascript/common/tracing/span-metrics/examples.mdx at
line 224: In the `handleUpload` function, `uploadId` is referenced at line 224 within
`updateUploadStatus(uploadId, 'processing')`. However, `uploadId` is never declared or
defined as a variable or function parameter within its scope. This will result in a
`ReferenceError: uploadId is not defined` when the upload completes successfully.
Did we get this right? 👍 / 👎 to inform future reviews.
        
          
                docs/platforms/javascript/common/tracing/span-metrics/examples.mdx
              
                Outdated
          
            Show resolved
            Hide resolved
        
      - Fix duplicate finalResponse declaration (line 719) - Fix undefined uploadId reference, use uploadData.jobId instead (line 224) - Fix function name mismatch, call searchKnowledgeBase instead of executeKnowledgeBaseSearch (line 708)
- Serialize processing.operations array with JSON.stringify() - Ensures proper attribute serialization in Sentry spans - Follows Sentry conventions for non-primitive span attributes
| Bundle ReportChanges will increase total bundle size by 279 bytes (0.0%) ⬆️. This is within the configured threshold ✅ Detailed changes
 Affected Assets, Files, and Routes:view changes for bundle: sentry-docs-client-array-pushAssets Changed:
 view changes for bundle: sentry-docs-server-cjsAssets Changed:
 | 
Overview
Updates the span metrics instrumentation examples page with comprehensive, real-world use cases demonstrating how to instrument both frontend and backend code for distributed tracing.
What's New
Four Complete Examples with Sample Repositories
E-Commerce Checkout Flow (Crash Commerce)
ui.actionspansMedia Upload with Background Processing (SnapTrace)
file.uploadspansSearch Autocomplete (NullFlix)
Manual LLM Instrumentation (Customer Service Bot)
Key Improvements
Content Structure
Each example includes: