Repository navigation
feat(node)!: always compile OTLP span export - #2039
Conversation
Release archives and the Docker image built decdn-node without the off-by-default `otlp` feature, so `observability.otlp_endpoint` was parsed and validated but ignored with a stderr warning in every shipped binary. - Drop the `otlp` feature; the OpenTelemetry deps are unconditional and `opentelemetry-otlp` takes only grpc-tonic/trace/internal-logs. - Reject `https://` endpoints at config resolution: the exporter has no TLS, so they passed `config validate` and then aborted start-up. - Shut the tracer provider down after `runtime::run` on both exit paths (bounded at 5 s), so queued spans flush instead of being discarded with the never-dropped global. - Filter h2/hyper/hyper_util/tonic/tower spans out of the OTel layer so `trace` level cannot export the export connection. - Fix the config template, `--otlp-endpoint` help, ci.yml and CONTRIBUTING feature lists. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Gas snapshotNo gas changes vs base. |
Contracts coverageLine coverage: 89.73% (2550/2842 lines) |
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved issues blocking approval were identified.
Pull request overview
This PR makes OTLP span export standard for decdn-node, validates plaintext endpoints, prevents export feedback loops, and flushes spans during shutdown.
Changes:
- Removes the optional OTLP feature and updates dependencies.
- Adds endpoint validation, transport filtering, and bounded shutdown flushing.
- Updates documentation, changelog, configuration templates, and CI guidance.
File summaries
| File | Description |
|---|---|
crates/node/src/commands/mod.rs |
OTLP initialization, filtering, shutdown flushing, and tests |
crates/node/Cargo.toml |
Unconditional OpenTelemetry dependencies |
crates/common/src/config/mod.rs |
HTTP-only endpoint validation |
crates/common/src/cli/run.rs |
Updated endpoint help text |
crates/cli/src/commands/config.rs |
Updated configuration template |
CONTRIBUTING.md |
Updated feature-build guidance |
CHANGELOG.md |
Documented breaking OTLP changes |
Cargo.toml |
Configured OTLP tonic features |
Cargo.lock |
Updated dependency graph |
.github/workflows/ci.yml |
Corrected gated-feature CI documentation |
Review details
- Files reviewed: 9/10 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
… diff reload notices - Count failed OTLP export batches into `decdn_otlp_export_failures_total` via a counting exporter wrapper; `commands::run` builds `Metrics` before tracing and passes it into `runtime::run`. Add the ADR registry row and a `DecdnOtlpExportFailing` warning alert. OTLP bring-up moves to `commands/otlp.rs`. - Resolve `observability.otlp_endpoint` as `http://host:port` only: reject a missing port, path/query/fragment (OTLP/HTTP URLs), and userinfo. Errors never echo the endpoint, which can carry credentials. - On SIGHUP, diff the resolved restart-required observability fields (CLI/env > file) against startup and warn once per changed field, instead of an info notice whenever the section sets one. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
- Endpoint validation no longer echoes any part of the value (a scheme-less input put its first segment, possibly a username, into the scheme error) and rejects surrounding whitespace and `http:host` forms the URL parser would otherwise normalise past the check. - Document what `decdn_otlp_export_failures_total` does not count (queue-full drops, partial-success rejections) in the metric doc, ADR row, alert and CHANGELOG; point appendix-binaries at commands/otlp.rs. - Log a failed run's redacted error before the exit-time flush, log a flush timeout separately, and forward `shutdown()` in the counting exporter. - Tests: counter ignores successful exports; the installed OTel layer drops transport spans (layer built by `otlp::otel_layer`); each restart-required observability field maps to its own name; CLI values win on reload; an aborted reload emits no observability notice. Each is mutation-checked. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved validation, diagnostic export, shutdown-bound, and reload-ordering issues remain.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (3)
crates/node/src/commands/otlp.rs:143
- Only the SDK call is bounded here; the
spawn_blockingjoin itself is awaited without a timeout. The node can leave blocking-pool pulls running past shutdown (crates/node/src/node_origin/mod.rs:1664-1669), so a saturated pool can keep this task queued and let an unreachable collector holdcommands::runbeyond the advertised 5-second exit bound. Bound the wait at the process level and define how a queued/non-completing blocking shutdown is handled.
let joined =
tokio::task::spawn_blocking(move || provider.shutdown_with_timeout(OTLP_SHUTDOWN_TIMEOUT))
.await;
crates/node/src/runtime/reload.rs:1187
- This warning is emitted before the phase-2
fallible_commitloop. If a reload changes both a restart-required observability field andlog_level, and the log-level setter then fails, the reload is aborted but the observability warning has already claimed the value is being ignored. Move this call after all fallible commits (before the final notice/swap phase) and cover that abort path with a test.
self.log_level.warn_restart_required_changes();
crates/node/tests/sighup_signal.rs:626
- The new contract is specifically a
warn-level notice, but this test only counts matching text. It would still pass ifwarn_restart_required_changesregressed totracing::info!; the existingnotice_eventtest below already shows how to assert the structured level, so add the sameWARNcheck formetrics_portandotlp_endpoint.
// `[observability]` names each changed restart-required field once, never
// the reloadable `log_level`, and never echoes the endpoint.
for field in ["metrics_port", "otlp_endpoint"] {
assert_eq!(
observability_notice_count(&logs, field),
1,
"expected one notice for changed observability.{field}, got:\n{logs}"
- Files reviewed: 20/21 changed files
- Comments generated: 2
- Review effort level: Lite
- Reject empty userinfo (`http://@collector:4317`): the parsed URL reports it as absent, so the check also reads the raw authority. - Export a failed run's error: log it inside its own `node_run_failed` span, because the OpenTelemetry layer exports events only as part of a span and none is guaranteed open when `runtime::run` returns. - Bound the exit-time flush end to end: run shutdown on a dedicated thread instead of the blocking pool (which long-running pulls can saturate) and stop waiting after the SDK bound plus 1 s. - Emit "requires restart" notices after the phase-2 commits, so a reload that aborts on a failed commit reports none. - Tests: failure event exported with no open span; restart notices are WARN-level; a phase-2 abort reports no restart notice; empty userinfo rejected. Each is mutation-checked. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Summary
decdn-nodeshipped without OTLP: release archives (release.yml) and the Docker image build with default features, andotlpwas off by default.observability.otlp_endpoint/--otlp-endpoint/DECDN_OTLP_ENDPOINTwas accepted and then ignored with a stderr warning.Always-on export
opentelemetry-otlpusesdefault-features = false(grpc-tonic,trace,internal-logs), droppingopentelemetry-httpand the blocking reqwest client from the lockfile.runtime::runon both Ok and Err paths (spawn_blocking, bounded at 5 s). Previously it lived only in the never-dropped global, so queued spans were always lost.h2/hyper/hyper_util/tonic/towerspans from the OTel layer, sotracelevel cannot export the export connection.crates/node/src/commands/otlp.rs.Observability of the exporter
decdn_otlp_export_failures_totalcounts failed export batches via a countingSpanExporterwrapper.commands::runnow buildsMetricsbefore tracing and passes it intoruntime::run(cfg, config_path, reload_state, metrics). ADR registry row added (Node / Process,live) and aDecdnOtlpExportFailingwarning alert (decdn-livenessgroup).Endpoint validation (
crates/common/src/config/mod.rs)http://host:portonly: rejectshttps://(no TLS), a missing port (checked on the raw authority so:80counts), path/query/fragment (OTLP/HTTP…:4318/v1/tracesis the wrong protocol), and userinfo. Rejections never echo the endpoint, which can carry credentials; the previous error printed it.SIGHUP reload notice (
crates/node/src/runtime/reload.rs)[observability]fields (log_format,metrics_port,metrics_bind,admin_port,otlp_endpoint) are diffed as resolved values (CLI/env > file) against startup. Each changed field logs onewarnnaming the field, not the value. Previously aninfonotice fired on every reload whenever the file set any of them, and never for a CLI/env change.Docs: config template,
--otlp-endpointhelp, ci.yml gated-feature list (also correctsdecdn-incentive/test-util, which dev-deps already enable), CONTRIBUTING, CHANGELOG (BREAKING).Test plan
cargo fmt --check; clippy--workspace --all-targetsand--all-features,-D warningsRUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-itemscargo deny check,pre-commit run --all-filescargo nextest run -p decdn-node -p decdn-common -p decdn-cli— 2297 passed, incl.adr_registry_names_are_exportedandmonitoring_selectors_are_exportedshutdown_flushes_queued_spans_and_counts_the_failed_export— mutation-checked: fails without the shutdown call, and fails without the counter incrementhttps; accepts[::1]:4317,:80, trailing/;otlp_endpoint_errors_never_echo_the_valuesighup_signal: reload docs: Generalize architecture to content-agnostic CDN, refocus slashing on bad edges #2 changesmetrics_portandotlp_endpoint→ exactly one warn each, endpoint value never logged; mutation-checked (fails when the diff call is removed fromreload())anvil_bringup_shutdown_e2e(newruntime::runsignature) andsmokewithDECDN_OTLP_ENDPOINTset, against a rebuilt binaryReview follow-ups (
4d4eba29)http:hostforms are rejected.appendix-binaries.mdpoints atcommands/otlp.rs.shutdown().counting_exporter_counts_failures_only,otel_layer_drops_transport_spans, per-field reload name mapping,observability_restart_notice_follows_cli_precedence,an_aborted_reload_reports_no_observability_notice. Suite: 2301 passed.🤖 Generated with Claude Code