Skip to content

feat(node)!: always compile OTLP span export - #2039

Merged
thiras merged 4 commits into
mainfrom
feat/otlp-default
Sep 15, 2026
Merged

thiras merged 4 commits into
mainfrom
feat/otlp-default

Conversation

@thiras

@thiras thiras commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

decdn-node shipped without OTLP: release archives (release.yml) and the Docker image build with default features, and otlp was off by default. observability.otlp_endpoint / --otlp-endpoint / DECDN_OTLP_ENDPOINT was accepted and then ignored with a stderr warning.

Always-on export

  • Feature removed. OpenTelemetry deps are unconditional (+~20 crates; hyper/tower already present). No OTel layer is installed when no endpoint is set. opentelemetry-otlp uses default-features = false (grpc-tonic, trace, internal-logs), dropping opentelemetry-http and the blocking reqwest client from the lockfile.
  • Exit flush. The tracer provider is shut down after runtime::run on 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.
  • No export feedback loop. A per-layer filter drops h2/hyper/hyper_util/tonic/tower spans from the OTel layer, so trace level cannot export the export connection.
  • OTLP bring-up lives in crates/node/src/commands/otlp.rs.

Observability of the exporter

  • decdn_otlp_export_failures_total counts failed export batches via a counting SpanExporter wrapper. commands::run now builds Metrics before tracing and passes it into runtime::run(cfg, config_path, reload_state, metrics). ADR registry row added (Node / Process, live) and a DecdnOtlpExportFailing warning alert (decdn-liveness group).

Endpoint validation (crates/common/src/config/mod.rs)

  • http://host:port only: rejects https:// (no TLS), a missing port (checked on the raw authority so :80 counts), path/query/fragment (OTLP/HTTP …:4318/v1/traces is 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)

  • Restart-required [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 one warn naming the field, not the value. Previously an info notice fired on every reload whenever the file set any of them, and never for a CLI/env change.

Docs: config template, --otlp-endpoint help, ci.yml gated-feature list (also corrects decdn-incentive/test-util, which dev-deps already enable), CONTRIBUTING, CHANGELOG (BREAKING).

Test plan

  • cargo fmt --check; clippy --workspace --all-targets and --all-features, -D warnings
  • RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items
  • cargo deny check, pre-commit run --all-files
  • cargo nextest run -p decdn-node -p decdn-common -p decdn-cli — 2297 passed, incl. adr_registry_names_are_exported and monitoring_selectors_are_exported
  • shutdown_flushes_queued_spans_and_counts_the_failed_export — mutation-checked: fails without the shutdown call, and fails without the counter increment
  • Endpoint tests: rejects missing port / path / query / fragment / userinfo / bad host / https; accepts [::1]:4317, :80, trailing /; otlp_endpoint_errors_never_echo_the_value
  • sighup_signal: reload docs: Generalize architecture to content-agnostic CDN, refocus slashing on bad edges #2 changes metrics_port and otlp_endpoint → exactly one warn each, endpoint value never logged; mutation-checked (fails when the diff call is removed from reload())
  • anvil e2e anvil_bringup_shutdown_e2e (new runtime::run signature) and smoke with DECDN_OTLP_ENDPOINT set, against a rebuilt binary

Review follow-ups (4d4eba29)

  • Endpoint errors echo no part of the value (a scheme-less input leaked its first segment through the scheme message); surrounding whitespace and http:host forms are rejected.
  • Counter docs (metric, ADR row, alert, CHANGELOG) state what is not counted: queue-full drops and partial-success rejections. appendix-binaries.md points at commands/otlp.rs.
  • A failed run logs its redacted error before the flush; a flush timeout is logged separately; the counting exporter forwards shutdown().
  • New mutation-checked tests: 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

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]>
Copilot AI lite review requested due to automatic review settings September 15, 2026 20:08
@thiras thiras self-assigned this Sep 15, 2026
@github-actions

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Contracts coverage

Line coverage: 89.73% (2550/2842 lines)
▼ -0.03pp vs base (89.75% → 89.73%)
Run: 35027660406

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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.

thiras and others added 2 commits September 15, 2026 23:45
… 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]>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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_blocking join 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 hold commands::run beyond 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_commit loop. If a reload changes both a restart-required observability field and log_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 if warn_restart_required_changes regressed to tracing::info!; the existing notice_event test below already shows how to assert the structured level, so add the same WARN check for metrics_port and otlp_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

Comment thread crates/common/src/config/mod.rs Resolved
Comment thread crates/node/src/commands/otlp.rs Resolved
- 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]>
@thiras
thiras merged commit 361018d into main Sep 15, 2026
25 of 27 checks passed
@thiras
thiras deleted the feat/otlp-default branch September 15, 2026 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants