OTelAPI class

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.

Constructors

OTelAPI.new()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

addMeterProvider(String name, {String? endpoint, String? serviceName, String? serviceVersion}) APIMeterProvider
Adds or replaces a named meter provider
addTracerProvider(String name, {String? endpoint, String? serviceName, String? serviceVersion}) APITracerProvider
Adds or replaces a named tracer provider
attributeBool(String name, bool value) Attribute<bool>
Create a boolean attribute key
attributeBoolList(String name, List<bool> value) Attribute<List<bool>>
Create a boolean list attribute key
attributeDouble(String name, double value) Attribute<double>
Create a double attribute key
attributeDoubleList(String name, List<double> value) Attribute<List<double>>
Create a double list attribute key
attributeInt(String name, int value) Attribute<int>
Create an integer attribute key
attributeIntList(String name, List<int> value) Attribute<List<int>>
Create an integer list attribute key
attributes([List<Attribute<Object>>? entries]) Attributes
Creates an Attributes collection from a list of Attributes.
attributesFromList(List<Attribute<Object>> attributeList) Attributes
Creates attributes from a list of individual attribute objects.
attributesFromMap(Map<String, Object> namedMap) Attributes
Creates an empty Attributes collection from a named set of values. String, bool, int and double or Lists of those types get turned into the matching typed attribute. DateTime gets converted to an Attribute<String> with the UTC time string. Attributes get added as-is (note - that would be unnecessary code) Anything else gets converted to an Attribute<String> via its toString.
attributesFromSemanticMap(Map<OTelSemantic, Object> semanticMap) Attributes
Creates Attributes from a map of semantic attributes to their values.
attributeString(String name, String value) Attribute<String>
Create a string attribute key
attributeStringList(String name, List<String> value) Attribute<List<String>>
Create a string list attribute key
baggage([Map<String, BaggageEntry>? entries]) Baggage
Creates an Baggage with the given name and entries.
baggageEntry(String value, String? metadata) BaggageEntry
Creates an BaggageEntry with the given value and optional metadata.
baggageForMap(Map<String, String> keyValuePairs) Baggage
Creates an Baggage with the given name and keyValuePairs which are converted into BaggeEntrys without metadata.
baggageFromJson(Map<String, dynamic> json) Baggage
Creates a baggage instance from a JSON representation.
context({Baggage? baggage}) Context
Creates a new Context with optional Baggage
contextKey<T>(String name) ContextKey<T>
Creates a new ContextKey with the given name. Each instance will be unique, even with the same name, per spec. The name is for debugging purposes only.
createCounter(String name, {String? description, String? unit}) APICounter<num>
Creates a counter instrument Creates a counter instrument with the specified name, description, and unit.
createGauge(String name, {String? description, String? unit}) APIGauge<num>
Creates a gauge instrument with the specified name, description, and unit.
createHistogram(String name, {String? description, String? unit, List<double>? boundaries}) APIHistogram<num>
Creates a histogram instrument with the specified name, description, unit, and boundaries.
createMeasurement<T extends num>(T value, [Attributes? attributes]) Measurement<T>
Creates an observable up-down counter instrument Creates a measurement with the given value and optional attributes.
createObservableCounter(String name, {String? description, String? unit, ObservableCallback<num>? callback}) APIObservableCounter<num>
Creates an observable counter instrument
createObservableGauge(String name, {String? description, String? unit, ObservableCallback<num>? callback}) APIObservableGauge<num>
Creates an observable gauge instrument
createObservableUpDownCounter(String name, {String? description, String? unit, ObservableCallback<num>? callback}) APIObservableUpDownCounter<num>
Creates an observable up-down counter instrument
createUpDownCounter(String name, {String? description, String? unit}) APIUpDownCounter<num>
Creates an up-down counter instrument with the specified name, description, and unit.
initialize({String endpoint = OTelFactory.defaultEndpoint, String? serviceName = OTelAPI.defaultServiceName, String? serviceVersion = OTelAPI.defaultServiceVersion, OTelFactoryCreationFunction? oTelFactoryCreationFunction}) → void
Typically developers will want to initialize OTel (the SDK), and not OTelAPI (the no-op API). The initialize method must be called before any other methods.
instrumentationScope({required String name, String version = '1.0.0', String? schemaUrl, Attributes? attributes}) InstrumentationScope
Creates a new InstrumentationScope.
invalidTraceId() TraceId
Creates an invalid TraceId (all zeros).
meterProvider([String? name]) APIMeterProvider
Gets a MeterProvider. If name is null, this returns the global default APIMeterProvider, if not it returns a MeterProvider for the name. If the MeterProvider does not exist, it is created.
meterProviders() List<APIMeterProvider>
returns a list of APITracerProviders including the the global default and any named providers added.
reset() → void
Reset API state (only public for testing)
spanContext({TraceId? traceId, SpanId? spanId, SpanId? parentSpanId, TraceFlags? traceFlags, TraceState? traceState, bool? isRemote = false}) SpanContext
The API MUST implement methods to create a SpanContext. These methods SHOULD be the only way to create a SpanContext. This functionality MUST be fully implemented in the API, and SHOULD NOT be overridable. Hence the SDK defers to this method
spanContextFromParent(SpanContext parent) SpanContext
Create a child SpanContext from a parent context
spanContextInvalid() SpanContext
Create an invalid SpanContext as required but the spec
spanEvent(String name, [Attributes? attributes, DateTime? timestamp]) SpanEvent
Creates a span event
spanEventNow(String name, Attributes attributes) SpanEvent
Creates a span event with the current timestamp.
spanId() SpanId
Generate a new random SpanId
spanIdFrom(String hexString) SpanId
SpanId from 8-byte String.
spanIdFromBytes(List<int> traceIdBytes) SpanId
Creates a SpanId from the provided bytes.
spanIdInvalid() SpanId
Creates an invalid SpanId (all zeros)
spanIdOf(Uint8List spanId) SpanId
SpanId of 8 bytes.
Creates a SpanLink with the specified span context and attributes.
traceFlags([int? flags]) TraceFlags
Creates a TraceFlags object with the specified flags.
traceId() TraceId
Creates a new random TraceId.
traceIdFrom(String hexString) TraceId
Creates a new TraceId from a hex string
traceIdFromBytes(List<int> traceIdBytes) TraceId
Creates a TraceId from the provided bytes.
traceIdInvalid() TraceId
Creates an invalid Trace (all zeros)
traceIdOf(Uint8List traceId) TraceId
Creates a TraceId from the provided raw bytes.
tracer(String name) APITracer
Get the default or named tracer from the global TracerProvider
tracerProvider([String? name]) APITracerProvider
Gets a TracerProvider. If name is null, this returns the global default APITracerProvider from the installed factory, (API if no SDK is installed), if not it returns an APITracerProvider for the name. If the TracerProvider does not exist, it is created.
tracerProviders() List<APITracerProvider>
returns a list of APITracerProviders including the the global default and any named providers added.
traceState(Map<String, String>? entries) TraceState
Creates a TraceState object with the specified entries.

Constants

defaultSchemaUrl → const String
Default schema URL for the OpenTelemetry specification.
defaultServiceName → const String
Default service name used when no service name is provided.
defaultServiceVersion → const String
Default service version, matching the OpenTelemetry specification version.