Correlation and Distributed Tracing

Correlation and Distributed Tracing

Guides a coding agent in implementing distributed tracing with correlation IDs, trace propagation and spans across microservices, including OpenTelemetry.

Skill files7 files

references/

scripts/

templates/

SKILL.md98 lines
1
---
2
name: correlation-tracing
3
description: >
4
Implement distributed tracing with correlation IDs, trace propagation, and
5
span tracking across microservices. Use when debugging distributed systems,
6
monitoring request flows, or implementing observability.
7
---
8
9
# Correlation & Distributed Tracing
10
11
## Table of Contents
12
13
- [Overview](#overview)
14
- [When to Use](#when-to-use)
15
- [Quick Start](#quick-start)
16
- [Reference Guides](#reference-guides)
17
- [Best Practices](#best-practices)
18
19
## Overview
20
21
Implement correlation IDs and distributed tracing to track requests across multiple services and understand system behavior.
22
23
## When to Use
24
25
- Microservices architectures
26
- Debugging distributed systems
27
- Performance monitoring
28
- Request flow visualization
29
- Error tracking across services
30
- Dependency analysis
31
- Latency optimization
32
33
## Quick Start
34
35
Minimal working example:
36
37
```typescript
38
import express from "express";
39
import { v4 as uuidv4 } from "uuid";
40
41
// Async local storage for context
42
import { AsyncLocalStorage } from "async_hooks";
43
44
const traceContext = new AsyncLocalStorage<Map<string, any>>();
45
46
interface TraceContext {
47
traceId: string;
48
spanId: string;
49
parentSpanId?: string;
50
serviceName: string;
51
}
52
53
function correlationMiddleware(serviceName: string) {
54
return (
55
req: express.Request,
56
res: express.Response,
57
next: express.NextFunction,
58
) => {
59
// Extract or generate trace ID
60
const traceId = (req.headers["x-trace-id"] as string) || uuidv4();
61
const parentSpanId = req.headers["x-span-id"] as string;
62
const spanId = uuidv4();
63
// ... (see reference guides for full implementation)
64
```
65
66
## Reference Guides
67
68
Detailed implementations in the `references/` directory:
69
70
| Guide | Contents |
71
|---|---|
72
| [Correlation ID Middleware (Express)](references/correlation-id-middleware-express.md) | Correlation ID Middleware (Express) |
73
| [OpenTelemetry Integration](references/opentelemetry-integration.md) | OpenTelemetry Integration |
74
| [Python Distributed Tracing](references/python-distributed-tracing.md) | Python Distributed Tracing |
75
| [Manual Trace Propagation](references/manual-trace-propagation.md) | Manual Trace Propagation |
76
77
## Best Practices
78
79
### ✅ DO
80
81
- Generate trace IDs at entry points
82
- Propagate trace context across services
83
- Include correlation IDs in logs
84
- Use structured logging
85
- Set appropriate span attributes
86
- Sample traces in high-traffic systems
87
- Monitor trace collection overhead
88
- Implement context propagation
89
90
### ❌ DON'T
91
92
- Skip trace propagation
93
- Log without correlation context
94
- Create too many spans
95
- Store sensitive data in spans
96
- Block on trace reporting
97
- Forget error tracking
98

© AJ Geddes · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…