Skip to content

Commit 61004bb

Browse files
committed
Updating example to replace API with job scheduler
1 parent 39667b7 commit 61004bb

File tree

1 file changed

+57
-43
lines changed
  • docs/platforms/javascript/common/tracing/span-metrics

1 file changed

+57
-43
lines changed

docs/platforms/javascript/common/tracing/span-metrics/examples.mdx

Lines changed: 57 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -243,83 +243,97 @@ The frontend span tracks the user's checkout experience, while the backend span
243243
- Measure end-to-end order completion times
244244
- Identify friction points in the user experience
245245

246-
## API Integration Health
246+
## Job Scheduling and Processing Pipeline
247247

248-
**Challenge:** Maintaining reliability and performance of critical API integrations across client and server components.
248+
**Challenge:** Understanding performance and reliability of distributed job processing systems, from job creation through completion.
249249

250-
**Solution:** Detailed tracking of API interactions from both consumer and provider perspectives.
250+
**Solution:** Comprehensive tracking of job lifecycle across scheduling, queueing, and processing stages.
251251

252252
**Frontend Instrumentation:**
253253
```javascript
254-
// Client-side API consumer
254+
// Client-side job submission and monitoring
255255
Sentry.startSpan(
256256
{
257-
name: 'API Client Request',
258-
op: 'http.client',
257+
name: 'Job Submission Flow',
258+
op: 'job.client',
259259
attributes: {
260-
// Request context
261-
'http.endpoint': '/api/users',
262-
'http.method': 'POST',
260+
// Job configuration
261+
'job.type': 'video_transcoding',
262+
'job.priority': 'high',
263+
'job.estimated_duration_ms': 300000,
263264

264-
// Client metrics
265-
'client.retry_count': 0,
266-
'client.cache_status': 'miss',
267-
'client.network_type': '4g',
265+
// Input metrics
266+
'input.size_bytes': 52428800, // 50MB
267+
'input.format': 'mp4',
268+
'input.segments': 5,
268269

269-
// Request lifecycle
270-
'request.size_bytes': 1024,
271-
'request.preparation_time_ms': 50,
272-
'response.parse_time_ms': 75,
270+
// Client-side scheduling
271+
'schedule.requested_start': '2024-03-15T10:00:00Z',
272+
'schedule.deadline': '2024-03-15T11:00:00Z',
273273

274-
// Error handling
275-
'error.type': null,
276-
'error.retry_strategy': 'exponential'
274+
// Progress monitoring
275+
'monitor.polling_interval_ms': 5000,
276+
'monitor.status_updates_received': 12,
277+
'monitor.last_progress_percent': 45
277278
}
278279
},
279280
async () => {
280-
// Client-side API call
281+
// Job submission and progress tracking implementation
281282
}
282283
);
283284
```
284285

285286
**Backend Instrumentation:**
286287
```javascript
287-
// Server-side API provider
288+
// Server-side job processing
288289
Sentry.startSpan(
289290
{
290-
name: 'API Server Handler',
291-
op: 'http.server',
291+
name: 'Job Processing Pipeline',
292+
op: 'job.server',
292293
attributes: {
293-
// Request processing
294-
'server.handler': 'UserController.create',
295-
'server.processing_time_ms': 150,
294+
// Queue metrics
295+
'queue.name': 'video-processing',
296+
'queue.provider': 'redis',
297+
'queue.length_at_enqueue': 23,
298+
'queue.wait_time_ms': 45000,
296299

297-
// Database interaction
298-
'db.query_count': 3,
299-
'db.total_query_time_ms': 85,
300+
// Worker metrics
301+
'worker.id': 'worker-pod-123',
302+
'worker.current_load': 0.75,
303+
'worker.memory_usage_mb': 1024,
300304

301-
// Response metrics
302-
'response.size_bytes': 2048,
303-
'response.status_code': 200,
305+
// Processing stages
306+
'processing.stages_completed': ['download', 'transcode', 'thumbnail'],
307+
'processing.stage_durations_ms': {
308+
'download': 12000,
309+
'transcode': 180000,
310+
'thumbnail': 5000
311+
},
304312

305-
// Rate limiting
306-
'rate_limit.remaining': 95,
307-
'rate_limit.reset_ms': 3600000
313+
// Resource utilization
314+
'resource.cpu_percent': 85,
315+
'resource.gpu_utilization': 0.92,
316+
'resource.memory_peak_mb': 2048,
317+
318+
// Job outcome
319+
'outcome.status': 'completed',
320+
'outcome.retry_count': 0,
321+
'outcome.output_size_bytes': 31457280 // 30MB
308322
}
309323
},
310324
async () => {
311-
// Server-side request handling
325+
// Job processing implementation
312326
}
313327
);
314328
```
315329

316330
**How the Trace Works Together:**
317-
The frontend span captures the API consumer perspective, while the backend span tracks the server-side processing. The distributed trace provides full visibility into the API interaction, enabling you to:
331+
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:
318332

319-
- Monitor end-to-end API request lifecycles
320-
- Track client-side network conditions and their impact
321-
- Analyze server processing efficiency
322-
- Identify bottlenecks in database queries
323-
- Monitor rate limit usage and impact
333+
- Monitor end-to-end job processing times and success rates
334+
- Track queue health and worker resource utilization
335+
- Identify bottlenecks in specific processing stages
336+
- Analyze job scheduling efficiency and queue wait times
337+
- Optimize resource allocation based on job characteristics
324338

325339
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.

0 commit comments

Comments
 (0)