Repository navigation
[probes.http] Add opt-in OpenTelemetry tracing - #1358
Conversation
|
Happy to make any tweaks to the config/tracer setup, I just made some arbitrary choices. But the functionality is working as expected in my testing. |
bdcbb50 to
521e80e
Compare
|
@cbroglie I was out on vacation for the last few weeks. I'll take a look at it in the next few days. |
manugarg
left a comment
There was a problem hiding this comment.
Sorry for the late review.
521e80e to
a8c78b3
Compare
|
No worries! Addressed the feedback. |
a8c78b3 to
b315917
Compare
|
Sorry for the slow turnaround, but I think everything has been addressed now! |
manugarg
left a comment
There was a problem hiding this comment.
Thanks for sticking with this @cbroglie, and sorry for another round. I built the branch, ran the full test suite (all green), config-tested the new example, and ran it end-to-end against a fake OTLP/gRPC collector -- spans, resource attributes, and W3C propagation all work as advertised. The earlier feedback is genuinely addressed: propagator validated before the exporter is built, insecure+TLS rejected, WithEndpointURL, the otelsdk split, the noop meter provider, and the latency-breakdown composition test.
A few things still open; the first two are worth fixing before merge.
Response body not closed on read error (can't inline, line isn't in the diff)
probes/http/http.go:370:
respBody, err := io.ReadAll(resp.Body)
if err != nil {
l.WithAttributes(p.dynamicHeaderAttrs(req)...).Warning(err.Error())
return err // body never closed
}This is a pre-existing connection leak, but tracing turns it into a span leak too: otelhttp's wrappedBody.Read calls span.End() only on io.EOF; a non-EOF error just sets the status, and only Close() ends the span. So every read failure now also leaks an unended span that the batch processor never sees. A defer resp.Body.Close() right after the client.Do error check fixes both. Happy for this to be a separate PR if you'd rather keep this one focused.
Verification notes
go test ./...passes on the branch.go run ./cmd/cloudprober -configtest -config_file examples/tracing/cloudprober.cfgpasses.- End-to-end against a local OTLP/gRPC receiver: resource comes through as
env=review host.name=... service.name=cp-verify, client spans are correctly parented roots withprobe/targetattributes, andtraceparentreaches the target. - Binary size: 89.6 MB -> 91.0 MB (+1.6%). Fine.
b315917 to
d7ee192
Compare
manugarg
left a comment
There was a problem hiding this comment.
@cbroglie sorry for the back and forth here (sometimes AI review agents over-litigate).
I'd like to request one more structural change, this time for simplification. Can you please drop the query-param redaction from this PR. It's complex and will not be used much (at least not right away). It may become part of Otel SDK soon and even if we have to add it ourselves, I'd probably implement it reusing the same code.
Concretely, to remove:
- internal/tracing/redact_exporter.go and redact_exporter_test.go
- internal/tracing/otelsdk/redact.go
- redact_query_params_in_traces (field 26) from probes/http/proto/config.proto, plus regen
- the spanAttrs marker block in probes/http/http.go
- the newRedactingExporter wrap in tracing.go
Thanks in advance!
Cloudprober is the client in HTTP probes, so it now starts the root span for each sampled request and exports it to an OTLP collector. This makes probe requests visible in distributed traces and propagates W3C trace context to the target. Tracing is configured globally via a new top-level `tracing` block and is off by default. When configured, all tracing-capable probes (HTTP today) are instrumented automatically; there are no per-probe tracing options.
d7ee192 to
af4e12a
Compare
More than happy to drop that complexity 👍 |
Cloudprober is the client in HTTP probes, so it now starts the root span for each sampled request and exports it to an OTLP collector. This makes probe requests visible in distributed traces and propagates W3C trace context to the target.
Tracing is configured globally via a new top-level
tracingblock and is off by default. When configured, all tracing-capable probes (HTTP today) are instrumented automatically; there are no per-probe tracing options.