dartastic_opentelemetry_api library

OpenTelemetry API for Dart

This library provides the OpenTelemetry API implementation for Dart, following the OpenTelemetry specification. It includes support for tracing, metrics, baggage, and context propagation.

For more information, see the OpenTelemetry specification at https://opentelemetry.io/docs/specs/otel/

Classes

APICallbackRegistration<T extends num>
A registration for an observable callback.
APICounter<T extends num>
APICounter is a synchronous Instrument which supports non-negative increments.
APIGauge<T extends num>
APIGauge is a synchronous Instrument which reports instantaneous measurements.
APIHistogram<T extends num>
APIHistogram is a synchronous Instrument which records a distribution of values.
APIInstrument
The base interface for all metric instruments.
APIMeter
Meter is responsible for creating Instruments and recording metrics. The API prefix indicates that it's part of the API and not the SDK and generally should not be used since an API without an SDK is a noop. Use the Meter from the SDK instead.
APIMeterCreate
Factory methods for creating APIMeter instances. This is part of the meter.dart file to keep related code together. Factory class for creating APIMeter instances. This class is internal and should not be used directly by application code.
APIMeterProvider
APIMeterProvider is the entry point of the OpenTelemetry metrics API. The API prefix indicates that it's part of the API and not the SDK and generally should not be used since an API without an SDK is a noop. Use the MeterProvider from the SDK instead. It provides access to APIMeters which are used to record metrics. You cannot create a MeterProvider directly; you must use OTelAPI or more likely, OTel, for example to get the default meter provider:
APIObservableCounter<T extends num>
APIObservableCounter is an asynchronous Instrument which reports monotonically increasing value(s) when the instrument is being observed.
APIObservableGauge<T extends num>
APIObservableGauge is an asynchronous Instrument which reports non-additive value(s) when the instrument is being observed.
APIObservableResult<T extends num>
Interface for recording observations from observable instruments.
APIObservableUpDownCounter<T extends num>
APIObservableUpDownCounter is an asynchronous Instrument which reports values that increase or decrease when the instrument is being observed.
APISpan
Span represents a single operation within a trace. The API prefix indicates that it's part of the API and not the SDK and generally should not be used since an API without an SDK is a noop. Use the TracerProvider from the SDK instead. Spans can be nested to form a trace tree. Each trace contains a root span, which typically describes the end-to-end latency, and zero or more sub-spans for its sub-operations. Any span that is created MUST also be ended. This is the responsibility of the user. API implementations MAY leak memory or other resources (including, for example, CPU time for periodic work that iterates all spans) if the user forgot to end the span.
APISpanCreate
Internal constructor access for Span
APITracer
Tracer is responsible for creating APISpans and propagating context in-process. The API prefix indicates that it's part of the API and not the SDK and generally should not be used since an API without an SDK is a noop. Use the TracerProvider from the SDK instead.
APITracerProvider
APITracerProvider is the entry point of the OpenTelemetry tracing API. The API prefix indicates that it's part of the API and not the SDK and generally should not be used since an API without an SDK is a noop. Use the TracerProvider from the SDK instead. It provides access to APITracers which are used to trace operations. You cannot create a TracerProvider directly; you must use OTelAPI or more likely OTel, for example to get the default tracer:
APIUpDownCounter<T extends num>
APIUpDownCounter is a synchronous Instrument which supports increments and decrements.
Attribute<T extends Object>
Represents a value for an attribute, associated with an attribute key.
AttributeCreate
Factory class for creating Attribute instances. This class is not intended to be used directly by users. Instead, use the methods provided by the OpenTelemetry API.
Attributes
A collection of attributes that are immutable and type-safe. Create with the OTelFactory methods.
AttributesCreate
Factory class for creating Attributes instances. Used internally and not exported to respect factories. This class is not intended to be used directly by users. Instead, use the methods provided by the OpenTelemetry API.
Baggage
Immutable Baggage that stores entries with unique string keys.
BaggageCreate
Factory for creating Baggage instances. This is used internally by the OpenTelemetry API implementation.
BaggageEntry
A single entry within Baggage. Typically just a value plus optional metadata.
BaggageEntryFactory
Factory for creating BaggageEntry instances. This is used internally by the OpenTelemetry API implementation.
CompositePropagator<C, V>
A propagator that combines multiple other propagators
Context
Represents the immutable context containing active spans, baggage, and other data.
ContextCreate
Factory class for creating Context instances.
ContextKey<T>
Key for Context values Each instance is unique, even if created with the same name.
ContextKeyCreate<T>
Factory class for creating ContextKey instances.
ContextPropagator<C>
A propagator for binary values that can inject into and extract from a carrier.
CounterCreate
Factory methods for creating APICounter instances. This is part of the counter.dart file to keep related code together.
GaugeCreate
Factory methods for creating APIGauge instances. This is part of the gauge.dart file to keep related code together.
HistogramCreate
Factory methods for creating APIHistogram instances. This is part of the histogram.dart file to keep related code together.
HttpHeaderAttribute
Enum for HTTP header attributes with dynamic keys Usage:
IdGenerator
Generates trace and span IDs according to the W3C Trace Context specification.
InstrumentationScope
Represents the instrumentation scope information.
InstrumentationScopeCreate
Factory class for creating InstrumentationScope instances. Used internally and not exported to respect factories. This class is not intended to be used directly by users. Instead, use the methods provided by the OTelAPI.
Measurement<T extends num>
Represents a data point reported via the metrics API.
MeasurementCreate<T extends num>
Factory methods for creating Measurement instances.
MeterProviderCreate
Factory methods for creating APIMeterProvider instances.
ObservableCounterCreate
Factory methods for creating APIObservableCounter instances. This is part of the observable_counter.dart file to keep related code together.
ObservableGaugeCreate
Factory methods for creating APIObservableGauge instances. This is part of the observable_gauge.dart file to keep related code together.
ObservableUpDownCounterCreate<T extends num>
Factory methods for creating APIObservableUpDownCounter instances. This is part of the observable_up_down_counter.dart file to keep related code together.
OTelAPI
The OTelAPI is the no-op API implementation of OTel, as required by the specification This class should only be used in the rare case of running without and SDK It is provided to comply with the specifiction requirement that the API can be used without an SDK installed. The initialize method must be called first. Internally it sets the OTelFactory to OTelAPIFactory. The rest of the methods act like factory constructors for OTelAPI classes.
OTelAPIFactory
The factory used when no SDK is installed. The OpenTelemetry specification requires the API to work without an SDK installed All construction APIs use the factory, such as builders or 'from' helpers.
OTelFactory
The OTelFactory is the plugin mechanism for OpenTelemetry SDK's. The OpenTelemetry specifies that the API must work without any SDK installed. The API uses the OTelAPIFactory as a default. SDKs override this default by registering their own APIFactory
OTelLog
A simple log service that logs messages and signals to the console. It filters messages based on the current log level. Signals are not filtered based on log level Defaults to noop,
OTelSemantic
Base interface for OpenTelemetry semantic convention enums.
SpanContext
Immutable representation of a SpanContext. A SpanContext contains the state that must propagate to child Spans and across process boundaries. SpanContext follows the W3C Trace Context specification.
SpanContextCreate
Internal constructor access for Span
SpanEvent
Represents an event that occurred during a span's lifetime.
SpanEventCreate
Factory class for creating SpanEvent instances.
SpanId
A span identifier - an 8-byte array with an ID in a base-16 hex format. Follows W3C Trace Context specification.
SpanIdCreate
Factory class for creating SpanId instances.
Represents a link between spans in potentially different traces.
SpanLinkCreate
Internal constructor access for SpanLink
TextMapGetter<T>
TextMapGetter allows an SDK to read values from a carrier object
TextMapPropagator<C, V>
Interface for propagating context between processes using text maps
TextMapSetter<T>
TextMapSetter allows an SDK to set values on a carrier object
Timestamp
Utility class for working with OpenTelemetry timestamps.
TraceFlags
Trace flags for a SpanContext. These flags are used to control tracing behavior. TraceFlags follows the W3C Trace Context specification.
TraceFlagsCreate
Internal constructor access for TraceFlags
TraceId
A trace identifier - a 16-byte array with an ID in a base-16 hex format. TraceId follows the W3C Trace Context specification.
TraceIdCreate
Factory class for creating TraceId instances.
TracerCreate
Internal constructor access for Tracer
TracerProviderCreate
Internal constructor access for TracerProvider
TraceState
Key-value pairs carried along with a span context. TraceState follows the W3C Trace Context specification.
TraceStateCreate
Internal constructor access for TraceState
UpDownCounterCreate
Factory methods for creating APIUpDownCounter instances. This is part of the up_down_counter.dart file to keep related code together.

Enums

AppInfoSemantics
RUM Semantics related to application information
AppLifecycleSemantics
RUM Semantics related to application lifecycle events
AppLifecycleStates
Defines the UI lifecycle, values for AppLifecycleSemantics.lifecycleState
AppStartType
RUM Semantic values for AppLifecycleSemantics.appStartType key
BatterySemantics
ClientResource
Specification
CloudResource
Specification
ComputeInstanceResource
Specification
ComputeUnitResource
Specification
DatabaseResource
DeploymentResource
Specification
DeviceResource
Specification
DeviceSemantics
RUM Semantics related to device information
EnvironmentResource
Specification
ErrorResource
Specification
ErrorSemantics
RUM Semantics related to errors and crashes
ExceptionResource
FeatureFlagResource
OpenTelemetry Semantic Conventions - Feature Flag Attributes Specification
FileResource
OpenTelemetry Semantic Conventions - File Attributes Specification
GenAIResource
OpenTelemetry Semantic Conventions - GenAI Attributes Specification
GeneralResourceResource
GraphQLResource
HostResource
OpenTelemetry Semantic Conventions - Host Attributes Specification
HttpResource
InteractionSemantics
Semantics related to user interactions
InteractionType
KubernetesResource
Specification
LifecycleState
Application lifecycle states
LogLevel
The log levels supported by OTelLog.
MessagingResource
Navigation actions in a UI context
RUM Semantics related to navigation and routing
NetworkResource
NetworkSemantics
RUM Semantics related to network
OperatingSystemResource
Specification
PerformanceSemantics
RUM Semantics related to performance measurements
ProcessResource
Specification
RPCResource
ServiceResource
Specification
SessionViewSemantics
RUM Semantics related to session and view information
SourceCodeResource
Specification
SpanKind
Type of span. Can be used to specify additional relationships between spans in addition to a parent/child relationship.
SpanStatusCode
The set of canonical status codes.
TelemetryDistroResource
Specification
TelemetrySDKResource
Specification
UserSemantics
RUM Semantics related to user information
VersionResource
Specification

Extensions

AttributesExtension on Map<String, Object>
Extension to create Attributes from a simple Map
OTelSemanticExtension on OTelSemantic
Extension on OTelSemantic to provide utility methods.

Functions

otelApiFactoryFactoryFunction({required String apiEndpoint, required String apiServiceName, required String apiServiceVersion}) OTelFactory
Factory function that creates an instance of OTelAPIFactory.

Typedefs

LogFunction = void Function(String)
Function type for logging operations
ObservableCallback<T extends num> = void Function(APIObservableResult<T> result)
A callback function for observable instruments.
OTelFactoryCreationFunction = OTelFactory Function({required String apiEndpoint, required String apiServiceName, required String apiServiceVersion})
A function that creates the OTel Factory, used bu initialize methods