Repository navigation
feat(obs): spans leave the process — OTLP over the reqwest we already link (telemetry P6b) - #429
Merged
Merged
Conversation
… link The exporter er-obs was shaped for. `init` still always installs the structured stderr layer; when an OTLP endpoint is configured it additionally installs a `tracing-opentelemetry` bridge, so the span tree that already exists in-process starts arriving somewhere it can be queried. Opt-in by the presence of an endpoint rather than opt-out by a flag, because `er-entity` and `dedupe` are build tools and every test binary in the workspace calls `init`. `Option<Layer>` is itself a `Layer`, so with no endpoint the exporter is absent from the subscriber rather than installed-and-disabled. ## The deferral reason was real and did not survive re-measurement init.rs argued the exporter could not land because `opentelemetry-otlp`'s `reqwest-rustls` feature resolves a second `reqwest` and selects `aws-lc-rs`, pulling an `aws-lc-sys` that needs a cmake the build image lacks. That was right about the feature it tested and wrong as a verdict on the exporter: supplying our own HTTP client avoids the client features entirely. Re-measured on this branch — zero `aws-lc-sys`, one `reqwest` (0.12.28), rustls still on `ring`, 12 new lock entries and no second HTTP or TLS stack. `tonic` is among them because `opentelemetry-proto` depends on it unconditionally, but without `transport`, which is why no new `hyper` appears. It is a protobuf codec here, not a gRPC stack. ## The trap, and why the test sends real bytes The SDK's batch processor owns a plain std::thread and polls the exporter future on it with a non-tokio executor, so an async `reqwest::Client` panics there with `there is no reactor running`. That panic does NOT fail the process — it is on the processor's thread, so `main` runs on and every span is silently dropped. Observed while building this. So `ReqwestClient` hands each request to a single-worker runtime this module owns, which works whether or not the caller has one: the API and dispatcher are `#[tokio::main]`, the `er` CLI and `exec-task` deliberately are not. tests/otlp_export.rs asserts on **bytes received by a listener** in both shapes, because a provider that merely builds proves nothing — the first version built fine and exported nothing. Verified by reintroducing the bug: the no-runtime test fails with that exact panic. One guess recorded as wrong rather than quietly dropped: `block_on` instead of `spawn` was expected to fail the in-runtime case. It passes both, because the SDK always polls on its own thread. `spawn` is kept for having one fewer assumption, and the tests say they do not discriminate the two. ## Flush `Guard::force_flush` gains a body and `Drop` gains a flush-then-shutdown, so every normally-returning path is covered. `exec-task` is not one of those: `std::process::exit` does not run destructors, so main.rs flushes explicitly before exiting. A pod exits immediately after its last span, and the tail of every run — including every failure — depends on it. Failures degrade to "no telemetry" throughout and are never propagated. Observation must not change a run, and this code runs from the first statement of `main`, where an error is a pod that will not boot for an unrelated reason. `make check` passes. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
#418 sets OTEL_SERVICE_NAMESPACE on both the deployments and the task template. It is not an OTLP SDK variable — the spec carries service.namespace inside OTEL_RESOURCE_ATTRIBUTES — so the value was shipped to no effect. Reading it here is cheaper than changing the chart and leaves one spelling rather than two, and service.namespace is worth having: it is what separates this product from anything else that ever writes to the one shared store. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
athvin
added a commit
that referenced
this pull request
Nov 3, 2026
… (P14) (#454) This is a deduplication engine, so names, emails, phones and addresses ARE the payload, and §10.4's rule is that telemetry carries identifiers and counts and never attribute values. #429 made that boundary matter more: spans now leave the process over OTLP, so it is an exportable store rather than in-account Postgres. The real guarantee is structural and already shipped — `er_span::sql_span` takes no parameter argument, so there is nowhere to put a bind value. These are the shape gates around it, because that property only holds while the call stays where it is: 1. only GENERATED code may call `sql_span` (244 sites, all in er-entities); product code calls `generator_span`, which has no `sql` parameter at all. `er-span` and `er-sql-check/src/emit.rs` are allowlisted with reasons — the latter WRITES those calls as string literals rather than making them. 2. every emitted `sql_span` argument is a string literal, `SQL`, or a `Store` discriminant, so none can carry a runtime value. 3. the names `er-span` declares `Pii::Never` appear nowhere in code. Each test also asserts a floor on what it examined (>60 files, >20 generated callers, >200 statements), so a moved crate tree fails here rather than passing having looked at nothing — the false-green shape this repo keeps being bitten by. The forbidden list is READ OUT of er-span/src/attr.rs rather than restated. A hardcoded copy is how a registry and its enforcement drift apart, which er-entity-lint's own header records as how three documented codes ended up never implemented. ## Two things the gate taught me while being written Its first version failed on `er-server/src/telemetry.rs` — whose comment says `url.query` is deliberately NOT recorded. A file explaining the rule was being reported as breaking it. Writing down why an attribute is forbidden is exactly the behaviour to encourage, so prose is now exempt and only code counts. And the comment stripper's limitation runs the UNSAFE way, so it says so: it does not understand string literals, so a `//` inside one strips the rest of that line and a forbidden name after it would be MISSED. A false negative, not a false positive. Accepted because the structural guarantee does not depend on this scan; if it ever does, this wants to be a real lint. Both gates observed failing on injected violations before being trusted. `make check` passes. Co-authored-by: bmoore813 <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
athvin
pushed a commit
that referenced
this pull request
Nov 5, 2026
…it (P9)
`dispatcher.rs` has carried this as a TODO since P3, and it named its own
precondition:
// The §10.2 hop, half-closed: the enqueue side writes this ... Making this
// span a true CHILD of that context needs the OTel context propagator,
// which arrives with the exporter — at which point this field becomes
// `set_parent`.
The exporter arrived in #429, so it does.
`jobs.trace_context` has held the traceparent of the enqueueing request all
along, and the dispatcher recorded it as a span FIELD. A field joins two traces
by log search; it does not make them one trace. Now the context is adopted as
the job span's parent, so a click, the HTTP request it caused, the job, its run,
its eleven stages and every statement they execute are ONE trace — which is the
thing this whole programme is for.
The field stays. CloudWatch Logs has no span tree to walk, so it remains how
the two sides join there.
## Where it lives
`er-obs`, not `er-server`. The propagator needs `opentelemetry_sdk` and
`tracing-opentelemetry` and the control plane has neither, so this keeps the
OTel surface in the one crate that owns it and gives the dispatcher a one-line
call instead of two dependencies.
## Best effort, silently
A job the scheduler enqueued has no request behind it and stays a root, which
is correct and not worth a log line on every claim. A context that will not
parse also leaves it a root — exactly the behaviour before this existed — and
`acceptable_traceparent` has already refused malformed values on the way in. A
job must never fail because its telemetry lineage could not be established.
## The test is a PAIR, and the control is the point
`adopts_parent_context.rs` asserts the exported `trace_id` equals the incoming
one, as its sixteen RAW BYTES, because that is how OTLP encodes it — asserting
on a hex string would pass while the field held something else, which is a
mistake this crate's tests already made once against `otel.status_code`.
The second test exports WITHOUT adopting and asserts the trace id is absent.
Without it the positive test could pass because the bytes appeared somewhere
incidental, and a test that cannot fail for the right reason is not evidence.
Verified by breaking `adopt_traceparent`: the positive test fails with its own
message, the control keeps passing.
`make check` passes.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
athvin
added a commit
that referenced
this pull request
Nov 5, 2026
…it (P9) (#481) `dispatcher.rs` has carried this as a TODO since P3, and it named its own precondition: // The §10.2 hop, half-closed: the enqueue side writes this ... Making this // span a true CHILD of that context needs the OTel context propagator, // which arrives with the exporter — at which point this field becomes // `set_parent`. The exporter arrived in #429, so it does. `jobs.trace_context` has held the traceparent of the enqueueing request all along, and the dispatcher recorded it as a span FIELD. A field joins two traces by log search; it does not make them one trace. Now the context is adopted as the job span's parent, so a click, the HTTP request it caused, the job, its run, its eleven stages and every statement they execute are ONE trace — which is the thing this whole programme is for. The field stays. CloudWatch Logs has no span tree to walk, so it remains how the two sides join there. ## Where it lives `er-obs`, not `er-server`. The propagator needs `opentelemetry_sdk` and `tracing-opentelemetry` and the control plane has neither, so this keeps the OTel surface in the one crate that owns it and gives the dispatcher a one-line call instead of two dependencies. ## Best effort, silently A job the scheduler enqueued has no request behind it and stays a root, which is correct and not worth a log line on every claim. A context that will not parse also leaves it a root — exactly the behaviour before this existed — and `acceptable_traceparent` has already refused malformed values on the way in. A job must never fail because its telemetry lineage could not be established. ## The test is a PAIR, and the control is the point `adopts_parent_context.rs` asserts the exported `trace_id` equals the incoming one, as its sixteen RAW BYTES, because that is how OTLP encodes it — asserting on a hex string would pass while the field held something else, which is a mistake this crate's tests already made once against `otel.status_code`. The second test exports WITHOUT adopting and asserts the trace id is absent. Without it the positive test could pass because the bytes appeared somewhere incidental, and a test that cannot fail for the right reason is not evidence. Verified by breaking `adopt_traceparent`: the positive test fails with its own message, the control keeps passing. `make check` passes. Co-authored-by: bmoore813 <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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.
The exporter
er-obswas shaped for.initstill always installs the structured stderr layer; when an OTLP endpoint is configured it additionally installs atracing-opentelemetrybridge, so the span tree that already exists in-process starts arriving somewhere it can be queried.Opt-in by the presence of an endpoint rather than opt-out by a flag, because
er-entityanddedupeare build tools and every test binary in the workspace callsinit.Option<Layer>is itself aLayer, so with no endpoint the exporter is absent from the subscriber rather than installed-and-disabled.The deferral reason was real, and did not survive re-measurement
init.rsargued at length that the exporter could not land:opentelemetry-otlp'sreqwest-rustlsfeature resolves a secondreqwestand selectsaws-lc-rsas rustls' provider, pulling anaws-lc-systhat needs a cmake the build image does not carry.That was right about the feature it tested and wrong as a verdict on the exporter. Supplying our own HTTP client avoids the client features entirely. Re-measured on this branch with
default-features = false+http-proto:aws-lc-sys/aws-lc-rsreqwestversionsringringtonicis among the twelve, which the plan hoped to avoid —opentelemetry-protodepends on it unconditionally. But without itstransportfeature, which is why no newhyperappears. It is a protobuf codec here, not a gRPC stack.The trap, and why the test sends real bytes
The SDK's batch processor owns a plain
std::threadand polls the exporter future on it with a non-tokio executor. An asyncreqwest::Clientneeds a reactor, so sending directly from that thread panics:That panic does not fail the process. It is on the processor's own thread, so
mainruns on,force_flushreturns an error nobody is obliged to read, and every span is dropped. The failure mode is a telemetry pipeline that looks installed and exports nothing — and it is invisible to a build-only check.So
ReqwestClienthands each request to a single-worker runtime this module owns, which works whether or not the caller has one: the API and dispatcher arms are#[tokio::main], while theerpipeline CLI and theexec-taskpod verb deliberately are not.tests/otlp_export.rstherefore asserts on bytes received by a listener, in both runtime shapes, checking the request line andcontent-type: application/x-protobuf— a mis-joined endpoint is a silent 404 per batch and a wrong content-type a silent 415.Gate observed failing before being trusted. Reintroducing the bug gives
1 passed; 2 failedwith that exact panic surfaced through the flush assertion.One guess recorded as wrong rather than quietly dropped:
block_onin place ofspawnwas expected to pass the no-runtime case and panic the in-runtime one. It passes both — the SDK always polls on its own thread, so there is no ambient runtime to conflict with.spawnis kept for having one fewer assumption, and the tests state that they do not discriminate between the two rather than implying a guarantee they do not provide.Flush
Guard::force_flushgains a body andDropgains flush-then-shutdown, covering every normally-returning path.exec-taskis not one of those —std::process::exitdoes not run destructors — somain.rsflushes explicitly before exiting. A pod exits immediately after its last span, so the tail of every run, including every failure, depends on it. SIGKILL and OOM remain uncoverable; the terminal message and stdout→Fluent Bit are that path.Failures degrade to "no telemetry" throughout and are never propagated. Observation must not change a run, and this runs from the first statement of
main, where an error is a pod that will not boot for a reason unrelated to its job.Also
provider_fortakes the endpoint as a parameter, which is what makes the export testable: the workspace deniesunsafe_codeandstd::env::set_varis unsafe as of edition 2024. The endpoint/duration resolvers are pure functions for the same reason, which also stops them depending on what ran beside them in a shared test binary.er-obsgainstests/main.rswithautotests = false, per the one-test-binary convention.init.rs's deferral rationale andtelemetry.rs's "there is no exporter in the build".make checkpasses.🤖 Generated with Claude Code