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§
- InMemory
Exporter - A
SpanExporterthat accumulates all exported spans in memory. - Metric
Point - A single timestamped metric observation.
- Observability
Registry - Central registry that combines a
Tracerwith an in-process metrics store and Prometheus export. - Span
- A single unit of work in a distributed trace.
- Span
Context - Immutable identity and sampling context for a span, equivalent to the
OpenTelemetry
SpanContext. - Span
Event - A timestamped event recorded within a span’s lifetime.
- Tracer
- Creates and manages spans, routing finished spans to the configured exporter.
Enums§
- Attribute
Value - A typed attribute value, matching the OpenTelemetry attribute type system.
- Span
Status - The completion status of a span, mirroring the OpenTelemetry
StatusCode.
Traits§
- Span
Exporter - A sink that receives completed spans for storage or forwarding.