feat(ping): propagate trace context in cron monitor pings#600
Merged
Conversation
Inject the current span's W3C trace context (e.g. the `traceparent` header) into the HTTP GET requests sent to the configured cron monitor URLs. This lets the monitoring service's telemetry be correlated with the originating backup run when investigating cross-service failures. A reusable `TracePropagationExt` extension trait is added to the telemetry module so any `reqwest::RequestBuilder` can opt in via `.with_trace_context()`, using the globally configured OpenTelemetry text map propagator installed by the OpenTelemetry battery. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FvLUhVVh5My5zTN4aCoJjY
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #600 +/- ##
==========================================
+ Coverage 72.74% 73.18% +0.43%
==========================================
Files 29 30 +1
Lines 2077 2111 +34
==========================================
+ Hits 1511 1545 +34
Misses 566 566 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds W3C trace headers (e.g.
traceparent) to the HTTP requests sent to the configured cron monitor URLs (start/success/failure). This lets the monitoring service's telemetry be correlated with the originating backup run, enabling cross-service tracing when things fail — exactly the goal described in the request.What changed
src/telemetry/trace_propagation.rs(new): a small, reusable helper built on the OpenTelemetry text map propagator that the OpenTelemetry battery already installs globally.HeaderInjectorthat writes propagated fields into areqwest::header::HeaderMap, skipping anything that isn't a valid HTTP header.TracePropagationExtextension trait adding.with_trace_context()toreqwest::RequestBuilder, which injects the current span's trace context into the outgoing request.src/ping.rs: the cron-monitorGETrequests now call.with_trace_context().src/telemetry/mod.rs: re-exports the new module.When telemetry export is disabled (no valid span context), no headers are added, so requests are left untouched.
Notes
reqwest::RequestBuilderso other outbound HTTP clients (GitHub/Forgejo) can adopt the same propagation later if desired.Testing
cargo build✅cargo test --features pure_tests✅ (109 passed; network-gated tests ignored as usual)traceparentheader and that an empty context produces none.cargo fmt --checkandcargo clippy --all-targets✅🤖 Generated with Claude Code
Generated by Claude Code