Files
deepseek-harness/packages/telemetry/session-telemetry-otel

@deepseek-ai/dsh-session-telemetry-otel

English | 中文

The OpenTelemetry backend for the telemetry seam — the only entry a deployment loads. Its mode decides whether the seam hands records over immediately, releases them only at recorded feedback, or keeps telemetry local. Uploading modes compose the OTel JS SDK as-is (LoggerProviderBatchLogRecordProcessor → OTLP/HTTP log exporter) and map each handed-over record onto logger.emit(), under two instrumentation scopes: ledger records on @deepseek-ai/dsh-session-telemetry-otel, operational records on @deepseek-ai/dsh-session-telemetry-otel/ops. Resource identity (service.name/service.version) comes from dsh-llm's APP_IDENTITY, the same source the attribution headers use.

Config

- id: telemetry-otel
  name: '@deepseek-ai/dsh-session-telemetry-otel'
  config:
    mode: FULL                # FULL (default), FEEDBACK_ONLY, or DISABLED
    exporter:                # passed verbatim to the SDK's OTLP/HTTP log exporter
      url: https://collector.example.com/v1/logs
      headers:
        authorization: !!js `Bearer ${process.env.OTLP_TOKEN}`
    processor: {}            # optional; passed verbatim to BatchLogRecordProcessor
mode Behavior
FULL Default. Each projected record, including lifecycle ops records, is handed to the OTel SDK immediately.
FEEDBACK_ONLY Each feedback/record releases the redacted, projected session prefix through that event. Later records wait for another feedback event and remain local if none arrives.
DISABLED No coordinator, provider, processor, or exporter is constructed. No telemetry record leaves the process. A feedback/record logs session telemetry is DISABLED; nothing will be shared and this feedback remains local; the event remains in the local session log.

exporter.url is required in FULL and FEEDBACK_ONLY, has no default, and must parse as http(s); it is optional and unused in DISABLED. Uploading modes also reject a non-positive-integer processor.maxExportBatchSize, which the SDK accepts but then hangs on at shutdown. Everything else is the SDK's option shape, owned and documented by the SDK, and both blocks pass through whole: every OTLPExporterNodeConfigBase field (headers, timeoutMillis, compression, keepAlive, …) reaches the exporter, and batching, export cadence (scheduledDelayMillis), retry, queue bounds, and loss policy under sustained failure are the SDK's documented behavior, tuned through the processor passthrough. The backend deliberately implements no flush(): the batch processor is the only flusher in the process, which is what makes shutdown()'s drain complete.

What leaves the machine

In uploading modes, records carry the complete event.data as the seam's telemetry/record waterfall returns it — user and assistant message content, tool arguments and results (command output, file contents), the full system prompt and tool schemas (request/header), todo text, compaction summaries, hook stderrSummary, feedback text, and the session cwd (a local path). The seam ships no redaction rules: with no telemetry/record listener mounted, that is the raw captured copy, so a deployment exporting beyond a trusted boundary mounts its own rules (see the seam README). Provider credentials never appear regardless: adapter API keys are constructor parameters, not session events, so they are structurally absent from the log and therefore from telemetry. DISABLED does not construct the SDK pipeline or hand any capture to a backend.

Field mapping

Seam record → SDK log record: timetimestamp/observedTimestamp; severityseverityNumber/severityText (INFO 9 / WARN 13 / ERROR 17); body → the structured log body; attributes verbatim. Receivers dedupe on (session.id, event.seq) and alert on severity. In FULL, they may also detect crashes by shutdown-record absence: the marker is emitted at the session's own disposal or application teardown, and a marker followed by more events is a telemetry reload. In FEEDBACK_ONLY, a released prefix normally has no later shutdown marker, so its absence is not a crash signal. Streams are not self-contained across lineage: a resumed session continues its own id's stream from where the previous process left off, and a forked session's stream starts at its inherited boundary — its prefix lives in the parent's stream, stitched via session.parent_id + session.seed_length. A resumed local log may contain synthetic closers that were never exported; the wire stream stays faithful to records actually handed to the SDK.

Model Experience

None, as the backend only forwards the seam's redacted records into the OTel SDK pipeline; it never contributes to a model request.

KV Cache effect

None; this package neither assembles nor sends a provider request.

Known Limitations and Deferred Work

  • Upstream experimental tree@opentelemetry/sdk-logs is still published from the upstream experimental tree; SDK API churn lands here and only here — the seam contract does not move.
  • No live-collector coverage — every test exports to a local mock collector; the keyless Loader-composition e2e (tests/loader-composition.e2e.ts) covers the wire shape on every run, and behavior against a real OTLP deployment (auth, TLS, throttling) is the SDK exporter's documented territory.
  • Feedback-only memory — each session retains deep-copied, redacted projected records in memory until feedback releases them or the session becomes unreachable. There is no durable pre-feedback spool; a crash before feedback uploads nothing.