Skip to content

Structured JSON logs with optional OpenTelemetry OTLP export - #9

Merged
dougrathbone merged 1 commit into
masterfrom
dougrathbone/otel-structured-logs-a897
Sep 12, 2026
Merged

dougrathbone merged 1 commit into
masterfrom
dougrathbone/otel-structured-logs-a897

Conversation

@dougrathbone

Copy link
Copy Markdown
Owner

What

Server and conduit-worker now emit structured JSON logs and can optionally export the same records over OpenTelemetry OTLP/HTTP. Nothing here is Datadog-specific: stdout works with any shipper, and OTLP works with any collector (Datadog agent, Grafana Alloy, contrib Collector, Honeycomb, …).

Why

Datadog had no Conduit application logs — only misrouted conduit.dovetail.com edge traffic. Operational events were console.log strings that do not cluster or facet. This covers:

  1. JSON on stdout (always on unless CONDUIT_LOG_STDOUT=false) so kube/journald/CloudWatch/DD agents can tail a stable schema.
  2. OTLP when configured via standard OTEL_* env vars.

Behavior

  • Call sites use log from src/server/logging/ (src/shared/logging.ts for types/format). Messages stay stable; IDs live in attributes (runId, workerId, component, exception.*).
  • Resource: service.name defaults to conduit / conduit-worker from CONDUIT_PROCESS_MODE; override with OTEL_SERVICE_NAME.
  • OTLP is off until OTEL_EXPORTER_OTLP_ENDPOINT or OTEL_EXPORTER_OTLP_LOGS_ENDPOINT is set. OTEL_SDK_DISABLED=true or OTEL_LOGS_EXPORTER=none also skips export.
  • Init runs from the existing first-import observability/instrument path (now also on the worker). Shutdown flushes OTLP buffers.

Example stdout line:

{"timestamp":"2026-09-12T00:00:00.000Z","severity":"WARN","level":"warn","body":"Worker lease expired","message":"Worker lease expired","service.name":"conduit","workerId":"eks-…"}

Deploy notes

No OTLP endpoint required. To export:

OTEL_EXPORTER_OTLP_ENDPOINT=http://<collector>:4318
OTEL_RESOURCE_ATTRIBUTES=deployment.environment.name=production
# plus OTEL_EXPORTER_OTLP_HEADERS if the collector needs auth

Tests

  • Unit tests for JSON format, level filtering, and OTEL env resolution
  • npx tsc --noEmit (server + web)
  • npm test
Open in Web Open in Cursor 

Server and worker emit one JSON line per event (OTel field names, stable
messages, run/worker attributes) so any stdout shipper can ingest them.
When OTEL_EXPORTER_OTLP_ENDPOINT is set, the same records go out over
OTLP/HTTP — Datadog, Grafana, or any collector — without a vendor SDK.

Co-authored-by: Doug Rathbone <dougrathbone@users.noreply.github.com>
@dougrathbone
dougrathbone marked this pull request as ready for review September 12, 2026 00:42
@dougrathbone
dougrathbone merged commit 056d207 into master Sep 12, 2026
1 check passed
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