Skip to main content

Crate graphrt_otel

Crate graphrt_otel 

Source
Expand description

§graphrt-otel

OpenTelemetry for graphrt runs, without the OpenTelemetry SDK: an EventTracer turns run graphrt_core::Events into spans (one per run, one per node execution, one per container body run) with GenAI semantic convention attributes, and exporters ship them as OTLP/HTTP JSON.

use std::sync::Arc;
use futures::StreamExt;
use graphrt_otel::{EventTracer, OtelConfig, OtlpHttpExporter};

let config = OtelConfig::from_env().expect("valid OTEL_* variables");
let exporter = Arc::new(OtlpHttpExporter::start(&config, None).expect("inside tokio"));
let mut tracer = EventTracer::new(exporter.clone()).with_graph(graph);
while let Some(event) = run.next().await {
    tracer.on_event(&event);
}
exporter.shutdown().await;

Content (node outputs, progress payloads) is not recorded unless EventTracer::capture_content is enabled; secrets are always masked.

Re-exports§

pub use config::ConfigError;
pub use config::OtelConfig;
pub use exporter::InMemoryExporter;
pub use exporter::MultiExporter;
pub use exporter::SpanExporter;
pub use exporter::StdoutExporter;
pub use exporter::WriterExporter;
pub use http::ExportError;
pub use http::OtlpHttpExporter;
pub use metrics::Metrics;
pub use otlp::Resource;
pub use span::AttrValue;
pub use span::Span;
pub use span::SpanId;
pub use span::StatusCode;
pub use span::TraceId;
pub use span::TraceParent;
pub use tracer::EventTracer;

Modules§

config
Configuration from the standard OTEL_* environment variables.
exporter
Span exporters: the SpanExporter contract plus in-memory, writer (stdout / stderr) and fan-out implementations.
http
OTLP/HTTP JSON exporter with batching, a bounded queue and retries.
metrics
Cumulative metrics: run and node counters, node duration histograms and token usage, encoded as OTLP metrics.
otlp
OTLP/JSON encoding (opentelemetry-proto JSON mapping: hex ids, 64-bit integers as strings, lowerCamelCase field names).
span
In-memory span model, ids and W3C trace context.
tracer
EventTracer: turns a run’s Event stream into OpenTelemetry spans.