mod otel#

module otel#

OpenTelemetry subscriber support for NeMo Flow.

This crate adapts NeMo Flow lifecycle events into OpenTelemetry trace spans:

  • scope/tool/LLM Start events open spans

  • matching End events close spans

  • Mark events become span events on the active parent span when possible

  • orphan marks fall back to zero-duration spans so they still reach OTLP

The public API is intentionally small:

Types

type Result<T>#

Result type for the OpenTelemetry subscriber crate.

Enums

enum OpenTelemetryError#

Errors produced while configuring or operating the OpenTelemetry subscriber.

MissingTokioRuntime#

The tonic gRPC exporter requires an active Tokio runtime.

UnsupportedTransport#

The requested transport is not available on this target.

transport: &'static str#

Human-readable transport label used in the error message.

InvalidGrpcHeader#

Failed to parse a configured gRPC metadata header.

key: String#

Header name that failed to parse.

message: String#

Parser failure message.

ExporterBuild(String)#

Failed to build the OTLP exporter.

Provider(String)#

The underlying tracer provider returned an error.

Core(FlowError)#

Registration errors from the core runtime.

enum OtlpTransport#

Supported OTLP trace transports.

HttpBinary#

OTLP/HTTP protobuf, typically http://host:4318/v1/traces.

Grpc#

OTLP/gRPC, typically http://host:4317.

Structs and Unions

struct OpenTelemetryConfig#

Configuration for the OpenTelemetry subscriber.

Implementations

impl OpenTelemetryConfig#

Functions

fn grpc(service_name: impl Into<String>) -> Self#

Creates a gRPC OTLP config for the given service name.

fn http_binary(service_name: impl Into<String>) -> Self#

Creates an HTTP OTLP config for the given service name.

fn with_endpoint(mut self, endpoint: impl Into<String>) -> Self#

Overrides the OTLP endpoint. If unset, exporter defaults and OTEL_* env vars apply.

fn with_header(mut self, key: impl Into<String>, value: impl Into<String>) -> Self#

Adds a header/metadata entry for the exporter.

fn with_instrumentation_scope(mut self, scope: impl Into<String>) -> Self#

Sets the instrumentation scope name used for emitted spans.

fn with_resource_attribute(mut self, key: impl Into<String>, value: impl Into<String>) -> Self#

Adds a resource attribute as a string key/value pair.

fn with_service_namespace(mut self, namespace: impl Into<String>) -> Self#

Sets the service namespace resource attribute.

fn with_service_version(mut self, version: impl Into<String>) -> Self#

Sets the service version resource attribute.

fn with_timeout(mut self, timeout: Duration) -> Self#

Sets the OTLP request timeout.

Traits implemented

impl Default for OpenTelemetryConfig#
struct OpenTelemetrySubscriber#

OpenTelemetry-backed NeMo Flow subscriber.

Implementations

impl OpenTelemetrySubscriber#

Functions

fn deregister(&self, name: &str) -> Result<bool>#

Deregisters a previously-registered global subscriber by name.

fn force_flush(&self) -> Result<()>#

Flushes finished spans through the underlying tracer provider.

fn from_tracer_provider(provider: SdkTracerProvider, instrumentation_scope: impl Into<String>) -> Self#

Builds a subscriber from an already-configured tracer provider.

fn new(config: OpenTelemetryConfig) -> Result<Self>#

Builds a subscriber backed by a new OTLP tracer provider.

fn register(&self, name: &str) -> Result<()>#

Registers this subscriber globally with the NeMo Flow runtime.

fn shutdown(&self) -> Result<()>#

Shuts down the underlying tracer provider.

Call deregister(...) first if the subscriber is still registered with NeMo Flow.

fn subscriber(&self) -> EventSubscriberFn#

Returns the raw NeMo Flow subscriber callback for custom registration flows.