-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
JavaScript tracing docs refactor #12769
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
7196311
Renaming distributed tracing, rearranging menu items. Changing tracin…
codyde 1e40d28
Adding better clarity on custom span vs adding attributes
codyde d1f10a1
Language fixes to tracing details
codyde a5cda2d
Adding additional examples and clarity
codyde 3778589
Iterating on redirect configs
codyde 39667b7
Enhancing example content for frontend and backend
codyde 61004bb
Updating example to replace API with job scheduler
codyde eac4137
Cleaning up example content
codyde 8547879
Update docs/platforms/javascript/common/tracing/span-metrics/index.mdx
codyde 6cfe9c3
renaming distributed tracing
codyde 7ae88c8
Moving and combining instrumentaiton section
codyde 470f072
Directory move for instrumentation
codyde 46f985e
reordering span metrics
codyde 5fccdbc
updates to redirects
codyde 00993d8
Merge branch 'codyde/javascript-tracing-refactor' of https://github.c…
codyde 2d8b1f3
Merge branch 'master' into codyde/javascript-tracing-refactor
codyde d86bf66
fixing missing /
codyde 07aca40
removing invalid redirect
codyde 4c01d7f
Adding missing redirects
codyde 91aa869
adding span metrics to explore; setting redirect from metrics
codyde 3216205
Merge branch 'master' into codyde/javascript-tracing-refactor
codyde 02fd7a5
Updating copy across tracing docs for clarify
codyde 6df7b6b
fixing redirect for span metrics
codyde 2640661
Update docs/platforms/javascript/common/tracing/index.mdx
codyde 0440714
Update docs/platforms/javascript/common/tracing/instrumentation/index…
codyde d082d54
Update docs/platforms/javascript/common/tracing/instrumentation/index…
codyde 8beca46
Update docs/platforms/javascript/common/tracing/index.mdx
codyde b6c4f13
Update docs/product/tracing/span-metrics/index.mdx
codyde e3f69c6
Update docs/platforms/javascript/common/tracing/span-metrics/index.mdx
codyde 3b05f16
Update docs/platforms/javascript/common/tracing/span-metrics/index.mdx
codyde e0810b3
Update docs/platforms/javascript/common/tracing/span-metrics/index.mdx
codyde 259c299
Update docs/platforms/javascript/common/tracing/instrumentation/index…
codyde 7c0ba15
Update docs/platforms/javascript/common/tracing/instrumentation/index…
codyde a89ff3e
Update docs/platforms/javascript/common/tracing/instrumentation/index…
codyde 8c30c7a
Update docs/platforms/javascript/common/tracing/instrumentation/index…
codyde 19f6635
Update docs/platforms/javascript/common/tracing/instrumentation/index…
codyde 758a14b
removing product traces docs; move to concepts
codyde 21f6c03
Merge branch 'codyde/javascript-tracing-refactor' of https://github.c…
codyde ef79e3c
Clarity updates in instrumentation docs
codyde befddb4
Adding clarity on attributes and span information
codyde d0b9346
Adding clarity on attributes instead of span metrics
codyde aff36d4
Adding clarity on attributes instead of span metrics
codyde b200fa1
Reordering distributed tracing for faster steps to configure
codyde ac7590d
Simplifying description of distributed tracing
codyde 2a7eb65
Removing profiling from this section
codyde 3c4795b
continued cleanup of instrumentation
codyde 91abaad
Adding sampling docs to tracing section
codyde 7f41731
Merge branch 'master' into codyde/javascript-tracing-refactor
codyde 7486a8e
Update docs/concepts/key-terms/tracing/index.mdx
codyde 8b6d9d5
Update docs/concepts/key-terms/tracing/index.mdx
codyde 2f02a37
Update docs/concepts/key-terms/tracing/index.mdx
codyde 40d021a
Update docs/concepts/key-terms/tracing/index.mdx
codyde 379b71d
Update docs/concepts/key-terms/tracing/index.mdx
codyde 50f1ba8
Update docs/concepts/key-terms/tracing/index.mdx
codyde ffb4cf8
Updates-Dist Tracing-Samples and configs
codyde dc0d9ba
Merge branch 'codyde/javascript-tracing-refactor' of https://github.c…
codyde File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...ommon/tracing/trace-propagation/index.mdx → ...mon/tracing/distributed-tracing/index.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...entation/custom-instrumentation/index.mdx → ...-metrics/custom-instrumentation/index.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
331 changes: 331 additions & 0 deletions
331
docs/platforms/javascript/common/tracing/span-metrics/examples.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,331 @@ | ||
| --- | ||
| title: Instrumentation Examples | ||
| description: "Examples of using span metrics to debug performance issues and monitor application behavior across frontend and backend services." | ||
| sidebar_order: 10 | ||
| --- | ||
|
|
||
| <Alert> | ||
|
|
||
| These examples assume you have already <PlatformLink to="/tracing/">set up tracing</PlatformLink> in your application. | ||
|
|
||
| </Alert> | ||
|
|
||
| This guide provides practical examples of using span metrics to solve common monitoring and debugging challenges across your entire application stack. Each example demonstrates how to instrument both frontend and backend components, showing how they work together within a distributed trace to provide end-to-end visibility. | ||
|
|
||
| ## File Upload and Processing Pipeline | ||
|
|
||
| **Challenge:** Understanding bottlenecks and failures in multi-step file processing operations across client and server components. | ||
|
|
||
| **Solution:** Track the entire file processing pipeline with detailed metrics at each stage, from client-side upload preparation through server-side processing. | ||
|
|
||
| **Frontend Instrumentation:** | ||
| ```javascript | ||
| // Client-side file upload handling | ||
| Sentry.startSpan( | ||
| { | ||
| name: 'Client File Upload', | ||
| op: 'file.upload.client', | ||
| attributes: { | ||
| // Client-side file preparation | ||
| 'file.size_bytes': 15728640, // 15MB | ||
| 'file.type': 'image/jpeg', | ||
| 'file.name': 'user-profile.jpg', | ||
|
|
||
| // Client processing metrics | ||
| 'client.compression_applied': true, | ||
|
|
||
| // Upload progress tracking | ||
| 'upload.retry_count': 0, | ||
| 'upload.total_time_ms': 3500 | ||
| } | ||
| }, | ||
| async () => { | ||
| // Client-side upload implementation | ||
| } | ||
| ); | ||
| ``` | ||
|
|
||
| **Backend Instrumentation:** | ||
| ```javascript | ||
| // Server-side processing | ||
| Sentry.startSpan( | ||
| { | ||
| name: 'Server File Processing', | ||
| op: 'file.process.server', | ||
| attributes: { | ||
| // Server processing steps | ||
| 'processing.steps_completed': ['virus_scan', 'resize', 'compress', 'metadata'], | ||
|
|
||
| // Storage operations | ||
| 'storage.provider': 's3', | ||
| 'storage.region': 'us-west-2', | ||
| 'storage.upload_time_ms': 850, | ||
|
|
||
| // CDN configuration | ||
| 'cdn.provider': 'cloudfront', | ||
| 'cdn.propagation_ms': 1500 | ||
| } | ||
| }, | ||
| async () => { | ||
| // Server-side processing implementation | ||
| } | ||
| ); | ||
| ``` | ||
|
|
||
| **How the Trace Works Together:** | ||
| The frontend span initiates the trace and handles the file upload process. It propagates the trace context to the backend through the upload request headers. The backend span continues the trace, processing the file and storing it. This creates a complete picture of the file's journey from client to CDN, allowing you to: | ||
|
|
||
| - Identify bottlenecks at any stage (client prep, upload, server processing, CDN propagation) | ||
| - Track end-to-end processing times and success rates | ||
| - Monitor resource usage across the stack | ||
| - Correlate client-side upload issues with server-side processing errors | ||
|
|
||
| ## LLM Integration Monitoring | ||
|
|
||
| **Challenge:** Managing cost (token usage) and performance of LLM integrations across frontend and backend coponents. | ||
|
|
||
| **Solution:** Tracking of the entire LLM interaction flow, from user input to response rendering. | ||
|
|
||
| **Frontend Instrumentation:** | ||
| ```javascript | ||
| // Client-side LLM interaction handling | ||
| Sentry.startSpan( | ||
| { | ||
| name: 'LLM Client Interaction', | ||
| op: 'ai.client', | ||
| attributes: { | ||
| // User interaction metrics | ||
| 'input.char_count': 280, | ||
| 'input.language': 'en', | ||
| 'input.type': 'question', | ||
|
|
||
| // UI performance | ||
| 'ui.time_to_first_token_ms': 245, | ||
| 'ui.total_request_time_ms': 3250, | ||
|
|
||
| // Stream handling | ||
| 'stream.rendering_mode': 'markdown' | ||
| } | ||
| }, | ||
| async () => { | ||
| // Client-side LLM handling | ||
| } | ||
| ); | ||
| ``` | ||
|
|
||
| **Backend Instrumentation:** | ||
| ```javascript | ||
| // Server-side LLM processing | ||
| Sentry.startSpan( | ||
| { | ||
| name: 'LLM API Processing', | ||
| op: 'ai.server', | ||
| attributes: { | ||
| // Model configuration | ||
| 'llm.model': 'claude-3-5-sonnet-20241022', | ||
| 'llm.temperature': 0.5, | ||
| 'llm.max_tokens': 4096, | ||
|
|
||
| // Token usage metrics | ||
| 'llm.prompt_tokens': 425, | ||
| 'llm.completion_tokens': 632, | ||
| 'llm.total_tokens': 1057, | ||
|
|
||
| // Performance tracking | ||
| 'llm.api_latency_ms': 2800, | ||
| 'llm.queue_time_ms': 150, | ||
|
|
||
| // Cost tracking | ||
| 'llm.cost_usd': 0.076, | ||
| 'llm.rate_limit_remaining': 95 | ||
| } | ||
| }, | ||
| async () => { | ||
| // Server-side LLM processing | ||
| } | ||
| ); | ||
| ``` | ||
|
|
||
| **How the Trace Works Together:** | ||
| The frontend span captures the user interaction and UI rendering performance, while the backend span tracks the actual LLM API interaction. The distributed trace shows the complete flow from user input to rendered response, enabling you to: | ||
|
|
||
| - Analyze end-to-end response times and user experience | ||
| - Track costs and token usage patterns | ||
| - Optimize streaming performance and UI rendering | ||
| - Monitor rate limits and queue times | ||
| - Correlate user inputs with model performance | ||
|
|
||
| ## E-Commerce Transaction Flow | ||
|
|
||
| **Challenge:** Understanding the complete purchase flow and identifying revenue-impacting issues across the entire stack. | ||
|
|
||
| **Solution:** Track the full checkout process from cart interaction to order fulfillment. | ||
|
|
||
| **Frontend Instrumentation:** | ||
| ```javascript | ||
| // Client-side checkout process | ||
| Sentry.startSpan( | ||
| { | ||
| name: 'Checkout UI Flow', | ||
| op: 'commerce.checkout.client', | ||
| attributes: { | ||
| // Cart interaction metrics | ||
| 'cart.items_added': 3, | ||
| 'cart.items_removed': 0, | ||
| 'cart.update_count': 2, | ||
|
|
||
| // User interaction tracking | ||
| 'ui.form_completion_time_ms': 45000, | ||
| 'ui.payment_method_changes': 1, | ||
| 'ui.address_validation_retries': 0, | ||
|
|
||
| // Client performance | ||
| 'client.page_load_time_ms': 850, | ||
| 'client.payment_widget_load_ms': 650, | ||
| 'client.total_interaction_time_ms': 120000 | ||
| } | ||
| }, | ||
| async () => { | ||
| // Client-side checkout implementation | ||
| } | ||
| ); | ||
| ``` | ||
|
|
||
| **Backend Instrumentation:** | ||
| ```javascript | ||
| // Server-side order processing | ||
| Sentry.startSpan( | ||
| { | ||
| name: 'Order Processing', | ||
| op: 'commerce.order.server', | ||
| attributes: { | ||
| // Order details | ||
| 'order.id': 'ord_123456789', | ||
| 'order.total_amount': 159.99, | ||
| 'order.currency': 'USD', | ||
| 'order.items': ['SKU123', 'SKU456', 'SKU789'], | ||
|
|
||
| // Payment processing | ||
| 'payment.provider': 'stripe', | ||
| 'payment.method': 'credit_card', | ||
| 'payment.processing_time_ms': 1200, | ||
|
|
||
| // Inventory checks | ||
| 'inventory.check_time_ms': 150, | ||
| 'inventory.all_available': true, | ||
|
|
||
| // Fulfillment | ||
| 'fulfillment.warehouse': 'WEST-01', | ||
| 'fulfillment.shipping_method': 'express', | ||
| 'fulfillment.estimated_delivery': '2024-03-20' | ||
| } | ||
| }, | ||
| async () => { | ||
| // Server-side order processing | ||
| } | ||
| ); | ||
| ``` | ||
|
|
||
| **How the Trace Works Together:** | ||
| The frontend span tracks the user's checkout experience, while the backend span handles order processing and fulfillment. The distributed trace provides visibility into the entire purchase flow, allowing you to: | ||
|
|
||
| - Analyze checkout funnel performance and drop-off points | ||
| - Track payment processing success rates and timing | ||
| - Monitor inventory availability impact on conversions | ||
| - Measure end-to-end order completion times | ||
| - Identify friction points in the user experience | ||
|
|
||
| ## Job Scheduling and Processing Pipeline | ||
|
|
||
| **Challenge:** Understanding performance and reliability of distributed job processing systems, from job creation through completion. | ||
|
|
||
| **Solution:** Comprehensive tracking of job lifecycle across scheduling, queueing, and processing stages. | ||
|
|
||
| **Frontend Instrumentation:** | ||
| ```javascript | ||
| // Client-side job submission and monitoring | ||
| Sentry.startSpan( | ||
| { | ||
| name: 'Job Submission Flow', | ||
| op: 'job.client', | ||
| attributes: { | ||
| // Job configuration | ||
| 'job.type': 'video_transcoding', | ||
| 'job.priority': 'high', | ||
| 'job.estimated_duration_ms': 300000, | ||
|
|
||
| // Input metrics | ||
| 'input.size_bytes': 52428800, // 50MB | ||
| 'input.format': 'mp4', | ||
| 'input.segments': 5, | ||
|
|
||
| // Client-side scheduling | ||
| 'schedule.requested_start': '2024-03-15T10:00:00Z', | ||
| 'schedule.deadline': '2024-03-15T11:00:00Z', | ||
|
|
||
| // Progress monitoring | ||
| 'monitor.polling_interval_ms': 5000, | ||
| 'monitor.status_updates_received': 12, | ||
| 'monitor.last_progress_percent': 45 | ||
| } | ||
| }, | ||
| async () => { | ||
| // Job submission and progress tracking implementation | ||
| } | ||
| ); | ||
| ``` | ||
|
|
||
| **Backend Instrumentation:** | ||
| ```javascript | ||
| // Server-side job processing | ||
| Sentry.startSpan( | ||
| { | ||
| name: 'Job Processing Pipeline', | ||
| op: 'job.server', | ||
| attributes: { | ||
| // Queue metrics | ||
| 'queue.name': 'video-processing', | ||
| 'queue.provider': 'redis', | ||
| 'queue.length_at_enqueue': 23, | ||
| 'queue.wait_time_ms': 45000, | ||
|
|
||
| // Worker metrics | ||
| 'worker.id': 'worker-pod-123', | ||
| 'worker.current_load': 0.75, | ||
| 'worker.memory_usage_mb': 1024, | ||
|
|
||
| // Processing stages | ||
| 'processing.stages_completed': ['download', 'transcode', 'thumbnail'], | ||
| 'processing.stage_durations_ms': { | ||
| 'download': 12000, | ||
| 'transcode': 180000, | ||
| 'thumbnail': 5000 | ||
| }, | ||
|
|
||
| // Resource utilization | ||
| 'resource.cpu_percent': 85, | ||
| 'resource.gpu_utilization': 0.92, | ||
| 'resource.memory_peak_mb': 2048, | ||
|
|
||
| // Job outcome | ||
| 'outcome.status': 'completed', | ||
| 'outcome.retry_count': 0, | ||
| 'outcome.output_size_bytes': 31457280 // 30MB | ||
| } | ||
| }, | ||
| async () => { | ||
| // Job processing implementation | ||
| } | ||
| ); | ||
| ``` | ||
|
|
||
| **How the Trace Works Together:** | ||
| The frontend span tracks job submission and monitoring, while the backend span captures queue management and processing details. The distributed trace provides visibility into the entire job lifecycle, enabling you to: | ||
|
|
||
| - Monitor end-to-end job processing times and success rates | ||
| - Track queue health and worker resource utilization | ||
| - Identify bottlenecks in specific processing stages | ||
| - Analyze job scheduling efficiency and queue wait times | ||
| - Optimize resource allocation based on job characteristics | ||
|
|
||
| For more information about implementing these examples effectively, see our <PlatformLink to="/tracing/span-metrics/">Span Metrics guide</PlatformLink> which includes detailed best practices and implementation guidelines. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.