Repository navigation
Description
Metadata
Parent: #1807
Related cleanup umbrella: #2177
Related current module: polylogue/daemon/otlp_receiver.py receives OTLP; this issue is outbound/internal projection.
Related substrates: run projections, observed events, context snapshots, tool calls/actions, recovery/context compiler.
Cross-pollination source: /tmp/ideas.md OTel projection notes for Polylogue and Sinex.
Status: proposed feature.
Purpose
Project Polylogue's own AI-work evidence into OpenTelemetry-style traces/spans/logs so sessions, runs, tool calls, observed events, and context snapshots can be inspected with standard observability tooling.
Important distinction: Polylogue already has an OTLP receiver for inbound external telemetry (polylogue/daemon/otlp_receiver.py). This issue is not about accepting OTLP. It is about producing/exporting a view of Polylogue's internal evidence as OTLP-compatible telemetry.
OTel must be an export/projection, not internal authority. The archive's truth remains sessions/messages/blocks/actions/assertions/runs/observed-events/context-snapshots/refs.
Current code reality
Current inbound OTLP receiver:
polylogue/daemon/otlp_receiver.py
POST /v1/traces, /v1/metrics, /v1/logs
opt-in observability_enabled
loopback/non-loopback auth behavior
stores received payloads in ops.db otlp_telemetry
Current evidence substrates to project:
messages / blocks / actions rows
run projection rows from recovery/run transforms
ObservedEvent query-unit rows
ContextSnapshot query-unit rows
RecoveryContextCompilation / work-packet evidence refs
ObjectRef / EvidenceRef strings
Missing owner:
polylogue evidence -> OTel trace/span/log export mapping
Proposed projection
Add a projection module such as:
polylogue/telemetry/otel_projection.py
Core DTO:
OtelProjectionPayload:
mode: Literal["otel-projection"]
source_ref: str
format: Literal["json", "otlp-json", "otlp-protobuf"]
trace_count: int
span_count: int
log_count: int
caveats: tuple[str, ...]
refs: tuple[str, ...]Mapping sketch:
session/logical session -> trace
run -> root span or trace-level span
message -> event/log or span event, depending on role/type
provider tool call/action -> child span with tool name/path/command attributes
ObservedEvent -> span event/log record with delivery/support state
ContextSnapshot -> span event with boundary/inheritance/segment refs
assertion/evidence refs -> attributes/links
work packet -> grouped projection metadata or trace annotation
Attribute naming should be stable and namespaced:
polylogue.session.id
polylogue.origin
polylogue.run.ref
polylogue.action.tool_name
polylogue.context_snapshot.ref
polylogue.observed_event.kind
polylogue.assertion.ref
polylogue.evidence.ref
Surfaces
CLI:
polylogue read SESSION_REF --view otel --format json
polylogue find QUERY then analyze --view otel --format json
polylogue ops telemetry export --session SESSION_ID --format otlp-jsonDaemon/API:
GET /api/sessions/:id/otel
MCP/Python:
export_otel(session_id or ref, format?)
Exact command placement should follow current command-surface cleanup rules: do not add a new root if read/analyze/ops owns it better.
Design constraints
- OTel is projection/export only. Do not make OTel ids the archive identity.
- Preserve refs: exported spans/logs should carry Polylogue refs so a user can navigate back to archive evidence.
- Privacy controls apply. Tool outputs, raw paths, and raw message text may need bounded/redacted modes.
- Export should be bounded by query/session limits; do not export an entire archive by default.
- If
opentelemetry-protois optional, JSON export should still work without it. - Do not confuse inbound receiver storage (
otlp_telemetry) with outbound projected evidence.
Acceptance criteria
- A projection function can export one fixture session with a run, tool call/action, observed event, and context snapshot into an OTLP-like JSON shape.
- Exported spans/logs include stable Polylogue ref attributes/links.
- CLI or API surface exposes the projection for a single session/ref.
- The projection works without installing
opentelemetry-protowhen JSON format is requested. - Privacy/redaction behavior is documented and tested for tool outputs and local paths.
- Docs explain inbound OTLP receiver vs outbound OTel projection so users do not confuse the two.
Tests
- Unit test for session/run/tool/context projection mapping.
- JSON schema or payload contract test.
- CLI/API smoke for one session export.
- Optional-protobuf fallback test.
- Privacy/redaction test.
Non-goals
- Do not replace Polylogue refs with trace/span ids.
- Do not require an external collector for local export tests.
- Do not add live remote export/streaming before bounded single-session export works.
- Do not store projected OTel as canonical archive data unless a later issue proves that need.
Activity
fix(telemetry): redact absolute paths in OTel projection
feat(telemetry): project query-unit evidence to OTel (#2183) (#2215)
feat(export): add sanitized spans-jsonl bundle leg (#2434) (#2455)