Documentation
¶
Overview ¶
Package otel is the module overview for Scope's OpenTelemetry integration. It declares no API of its own; every adapter lives in a subpackage listed below.
The module adds traces and metrics to Core's capabilities from the outside and provides development exporters that write all three OTel signals to log/slog. Core itself never imports OpenTelemetry: a wrapper here is an ordinary decorator, and this module invents no tracer, meter, registry, or observation abstraction. The official API is the vendor-neutral layer.
Adapters ¶
Adapters are split by the contract they wrap, so one generic config never mixes different lifecycles:
- chat: chat call and lazy stream.
- embedding, image, moderation, rerank, speech, transcription: one modality each.
- eval: a generic Evaluator result.
- rag: retrieval.
- tool: tool invocation.
- history: history store and conversation listing.
- vectorstore: the vector-store capabilities.
- agent: managed Process activation, Step, and Effect, through an Observer bound as an agent.EventListener.
The a2a and mcp modules are protocol integrations and use the official OTel API directly at their own call boundary, so this module has no adapter for them.
What never enters telemetry ¶
Prompts, queries, documents, media, audio, transcripts, and evaluation subjects stay out. An adapter records identity, counts, latency, outcome, and a stable low-cardinality error classification, because error.type is a metric dimension and a provider message would create one time series per string.
Development sinks ¶
The slog subpackage implements the three official SDK exporter interfaces, writing one slog record per span, metric batch, and log record. Export always returns nil so a sink failure never pollutes the business path, flushing is synchronous rather than batched, and an error span is promoted to error level. In production the composition root swaps these for the official OTLP exporters; the wrappers and the Core protocol code do not change.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package agent adapts Agent Framework events to the official OpenTelemetry tracing and metrics APIs.
|
Package agent adapts Agent Framework events to the official OpenTelemetry tracing and metrics APIs. |
|
Package chat instruments Core chat capabilities with OpenTelemetry.
|
Package chat instruments Core chat capabilities with OpenTelemetry. |
|
Package embedding instruments Core embedding calls with OpenTelemetry.
|
Package embedding instruments Core embedding calls with OpenTelemetry. |
|
Package eval instruments generic Scope evaluation calls with OpenTelemetry.
|
Package eval instruments generic Scope evaluation calls with OpenTelemetry. |
|
Package history instruments conversation-history capabilities with OpenTelemetry.
|
Package history instruments conversation-history capabilities with OpenTelemetry. |
|
Package image instruments Core image-generation calls with OpenTelemetry.
|
Package image instruments Core image-generation calls with OpenTelemetry. |
|
Package moderation instruments Core moderation calls with OpenTelemetry.
|
Package moderation instruments Core moderation calls with OpenTelemetry. |
|
Package rag instruments retrieval capabilities with OpenTelemetry.
|
Package rag instruments retrieval capabilities with OpenTelemetry. |
|
Package rerank instruments Core reranking calls with OpenTelemetry.
|
Package rerank instruments Core reranking calls with OpenTelemetry. |
|
Package slog sinks all three OpenTelemetry signals — Traces, Metrics, and Logs — into a log/slog logger, so every span, metric, and log line from any Scope module lands in one structured stream correlated by trace_id / span_id.
|
Package slog sinks all three OpenTelemetry signals — Traces, Metrics, and Logs — into a log/slog logger, so every span, metric, and log line from any Scope module lands in one structured stream correlated by trace_id / span_id. |
|
Package speech instruments Core speech-synthesis calls with OpenTelemetry.
|
Package speech instruments Core speech-synthesis calls with OpenTelemetry. |
|
Package tool instruments Core tool execution with OpenTelemetry.
|
Package tool instruments Core tool execution with OpenTelemetry. |
|
Package transcription instruments Core transcription calls with OpenTelemetry.
|
Package transcription instruments Core transcription calls with OpenTelemetry. |
|
Package vectorstore instruments Core vector-store capabilities with OpenTelemetry.
|
Package vectorstore instruments Core vector-store capabilities with OpenTelemetry. |