TelemetryRepositoryImpl class
Implementation of ITelemetryRepository using OpenTelemetry FFI with buffering.
Provides concrete implementation of telemetry repository interface, translating domain telemetry operations into native OpenTelemetry calls via FFI with in-memory batching.
Features:
- Batching: Accumulates telemetry data before export
- Periodic flushing: Auto-flushes based on time interval
- Reduced FFI overhead: Fewer native calls
- Error handling: Returns
ResultDarttypes for recovery - Retry logic: Exponential backoff for transient failures
Example:
final ffi = OpenTelemetryFFI();
final repository = TelemetryRepositoryImpl(
ffi,
batchSize: 100,
flushInterval: Duration(seconds: 30),
);
repository.initialize();
- Implemented types
Constructors
- TelemetryRepositoryImpl(OpenTelemetryFFI _ffi, {int batchSize = 100, Duration flushInterval = const Duration(seconds: 30), int maxRetries = 3, Duration retryBaseDelay = const Duration(milliseconds: 100), Duration retryMaxDelay = const Duration(seconds: 10)})
- Creates a new TelemetryRepositoryImpl instance.
Properties
- consecutiveFailureThreshold ↔ int
-
Configuration for automatic fallback behavior.
getter/setter pair
- failureCheckInterval ↔ Duration
-
getter/setter pair
- fallbackExporter ↔ TelemetryExporter?
-
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
exportEvent(
TelemetryEvent event) → Future< ResultDart< void, TelemetryException> > -
Export an event to telemetry backend.
override
-
exportMetric(
Metric metric) → Future< ResultDart< void, TelemetryException> > -
Export a metric to telemetry backend.
override
-
exportSpan(
Span span) → Future< ResultDart< void, TelemetryException> > -
Export a span to telemetry backend.
override
-
exportTrace(
Trace trace) → Future< void> -
Export a trace to telemetry backend.
override
-
flush(
) → Future< ResultDart< void, TelemetryException> > -
Flush any buffered telemetry data.
override
-
initialize(
{String otlpEndpoint = 'http://localhost:4318'}) → Future< ResultDart< void, TelemetryException> > -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setFallbackExporter(
ConsoleExporter exporter) → void - Sets the fallback exporter to use.
-
shutdown(
) → Future< ResultDart< void, TelemetryException> > -
Shutdown telemetry exporter and release resources.
override
-
toString(
) → String -
A string representation of this object.
inherited
-
updateSpan(
{required String spanId, required DateTime endTime, Map< String, String> attributes = const {}}) → Future<ResultDart< void, TelemetryException> > -
Update an existing span with new end time and attributes.
override
-
updateTrace(
{required String traceId, required DateTime endTime, Map< String, String> attributes = const {}}) → Future<ResultDart< void, TelemetryException> > -
Update an existing trace with new end time and attributes.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited