Skip to main content

Module observability

Module observability 

Source
Expand description

§Observability — OpenTelemetry-Compatible Tracing and Metrics

Implements an OpenTelemetry-compatible data model from scratch (no external OTel crate) including spans, exporters, and a Prometheus-format metrics registry.

§Example

use std::collections::HashMap;
use std::sync::Arc;
use tokio_prompt_orchestrator::observability::{
    InMemoryExporter, ObservabilityRegistry, Tracer,
};

let exporter = Arc::new(InMemoryExporter::new());
let tracer = Arc::new(Tracer::new(exporter.clone()));
let registry = ObservabilityRegistry::new(tracer);

let mut span = registry.tracer.start_span("my-operation");
span.set_attribute("http.method", "GET".into());
span.finish();

registry.record_metric("requests_total", 1.0, HashMap::new());
println!("{}", registry.to_prometheus());

Structs§

InMemoryExporter
A SpanExporter that accumulates all exported spans in memory.
MetricPoint
A single timestamped metric observation.
ObservabilityRegistry
Central registry that combines a Tracer with an in-process metrics store and Prometheus export.
Span
A single unit of work in a distributed trace.
SpanContext
Immutable identity and sampling context for a span, equivalent to the OpenTelemetry SpanContext.
SpanEvent
A timestamped event recorded within a span’s lifetime.
Tracer
Creates and manages spans, routing finished spans to the configured exporter.

Enums§

AttributeValue
A typed attribute value, matching the OpenTelemetry attribute type system.
SpanStatus
The completion status of a span, mirroring the OpenTelemetry StatusCode.

Traits§

SpanExporter
A sink that receives completed spans for storage or forwarding.