OpenTelemetry Log Correlation and Trace Linking Prompt
Wire application logs into the OpenTelemetry logs signal and correlate them with traces by injecting trace_id and span_id, so a single click moves between a slow trace and its exact log lines across services.
- Target user
- Engineers unifying logs, traces, and metrics into one observability workflow
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT, Cursor
The prompt
You are a senior observability engineer who correlates logs and traces so incident responders never grep blindly. I will provide: - Language/runtime, logging library, and OTel SDK/appender availability - How logs ship today (stdout + agent, sidecar, direct to backend) - The traces setup already in place (SDK, propagation, Collector) - The backend(s) for logs and traces and whether they support trace-to-log linking Your job: 1. **Injection strategy** — choose between the OTel logs SDK/appender (native log records with trace context) versus keeping the existing logger and injecting trace_id/span_id into structured fields. Justify for my stack. 2. **Trace context capture** — show exactly how to read the active span context and add trace_id, span_id, and trace_flags to each log record, including the case where no span is active. 3. **Structured format** — define the log schema (JSON keys, severity mapping to OTel SeverityNumber, resource attributes like service.name) so both backends can join on it. 4. **Collector pipeline** — if routing logs through OTLP, give the receiver/processor/exporter config, including severity filtering and batching; if keeping the log agent, show the parser that extracts trace_id. 5. **Correlation UX** — describe the exact join key and how a responder pivots trace to logs and logs to trace in the chosen backend. 6. **Gaps** — enumerate where correlation will break (async boundaries, thread pools, lost context) and how to fix or accept each. 7. **Cost/volume** — estimate added volume and propose severity or sampling controls. Output as: (a) the injection code for my logger, (b) the log schema table, (c) the Collector or agent config, (d) a correlation walkthrough, (e) a list of known gaps with mitigations. Flag any place context propagation loss would silently produce unlinkable logs.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
OpenTelemetry Baggage and Span Links Design Prompt
Design correct use of OpenTelemetry Baggage and span links: propagate business context (tenant, request class) across services, and link asynchronous or batched work back to originating traces without abusing baggage as a data bus.
-
OpenTelemetry Tail Sampling Strategy Prompt
Design a tail-based sampling strategy in the OpenTelemetry Collector that keeps errors and slow traces while cutting cost, including decision-wait tuning and trace-ID-aware load balancing across Collector replicas.
-
OpenTelemetry Collector Gateway Scaling & HA Prompt
Design a horizontally scalable, highly available OpenTelemetry Collector gateway tier — autoscaling, load balancing, queue persistence, and zero-loss rolling upgrades — so telemetry survives replica churn and traffic spikes.
-
OpenTelemetry Collector Routing & Multi-Backend Fan-out Prompt
Design a routing-connector-based OpenTelemetry Collector topology that fans telemetry out to multiple backends or tenants by attribute — with per-route processors, failover, and cost tiers — without duplicating data or dropping unmatched signals.
More OpenTelemetry prompts & error guides
Browse every OpenTelemetry prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.