Expand description
turnframe-telemetry: metrics, tracing and dashboards for a Turnframe runtime.
The runtime reports what it did through one small contract in
turnframe_core::observe; this crate ships the implementations of it an
application wants in production, plus the data to build a dashboard from
them. Every metric of §26.2, the latencies of §28, the identifiers of §26.1
as tracing fields, one span per provider call described with the
OpenTelemetry GenAI conventions, and a vendor-neutral TraceGrouping that
reaches every span rather than only the trace root.
Two rules decide what it will not do, and
docs/telemetry.md
says why. Prompt and completion text stays out by default —
ContentRecorder is the only way in, is disabled unless an application
enables it, and passes every string through a redactor the application
wrote. No user text and no case text ever becomes a metric label, which
is enforced three ways rather than asked for.
use std::sync::Arc;
use std::time::Duration;
use turnframe_core::ids::WorkflowKey;
use turnframe_core::observe::{Observer, Signal, SignalLabels};
use turnframe_telemetry::{CompositeObserver, MetricsObserver, TracingObserver, metrics};
// Once, after the metrics exporter is installed.
metrics::describe_all();
let observer: Arc<dyn Observer> = Arc::new(
CompositeObserver::new()
.with(MetricsObserver::new())
.with(TracingObserver::new()),
);
// The runtime then reports what it did:
let labels = SignalLabels::workflow(WorkflowKey::from("trip"));
observer.observe_labeled(&Signal::TurnReceived, &labels);
observer.observe_duration(&Signal::TurnDuration, Duration::from_millis(412), &labels);In tests, swap the composite for a RecordingObserver and assert on the
signals the code under test produced.
§Modules
crate::metrics: theMetricsObserver, the label rules and the metric catalogue that generates this crate’s README table.crate::tracing: theTracingObserver, the §26.1 identifier fields and the turn and stage span helpers.crate::attrs: every attribute key in one place, so an adapter and an application spell them identically.crate::composite:CompositeObserverandRecordingObserver.crate::dashboard: a data-only description of the §26.3 dashboard.crate::otel(featureotel): the same signals as OpenTelemetry instruments, and the grouping carried in baggage and stamped onto every span byGroupingSpanProcessor.
Re-exports§
pub use crate::composite::CompositeObserver;pub use crate::composite::RecordedSignal;pub use crate::composite::RecordingObserver;pub use crate::dashboard::Dashboard;pub use crate::dashboard::Panel;pub use crate::dashboard::PanelId;pub use crate::dashboard::PanelSource;pub use crate::metrics::LabelKey;pub use crate::metrics::MetricDoc;pub use crate::metrics::MetricsObserver;pub use crate::tracing::ContentRecorder;pub use crate::tracing::ContentRedactor;pub use crate::tracing::ContentRole;pub use crate::tracing::PipelineStage;pub use crate::tracing::ProviderCall;pub use crate::tracing::TraceGrouping;pub use crate::tracing::TracingObserver;pub use crate::tracing::TurnIdentifiers;pub use crate::otel::GroupingSpanProcessor;pub use crate::otel::OtelObserver;
Modules§
- attrs
- The attribute keys this crate emits, in one place.
- composite
- Combining observers, and the observer tests assert against.
- dashboard
- The reliability dashboard of spec §26.3, as data.
- metrics
- Metric emission through the
metricsfacade (spec §26.2, §28). - otel
- OpenTelemetry bridge (feature
otel). - tracing
- Structured tracing: the end-to-end trace of one turn (spec §26.1).