FlutterOTel class
Main entry point for Middleware Flutter OpenTelemetry SDK.
This class provides a simple API for adding OpenTelemetry tracing to Flutter applications with minimal configuration.
FlutterOTel relies on OTel from middleware_dart_opentelemetry. For custom OTel code such as making custom spans, tracers or spanProcessors, use the OTel class from Middleware. can use the complete OTel SDK class from Middleware.
Constructors
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
-
dispose(
) → void - Clean up resources
-
endScreenSpan(
String screenName) → void - Ends the span for a screen/route
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
- Records a navigation event between routes
-
recordUserInteraction(
String screenName, String interactionType, {String? targetName, Duration? responseTime, Map< String, dynamic> ? attributes}) → void - Creates and immediately ends a span for a user interaction
-
startScreenSpan(
String screenName, {bool root = false, bool childRoute = false, Attributes? attributes, List< SpanLink> ? spanLinks}) → Span -
Starts a span for a screen/route
Normally this will be handled automatically by the NavigatorObserver
This is useful for manual spans like a subscription popup.
rootif (route is true, this starts a new trace)childRouteIf not a child, this ends an existing screen span.spanLinks -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- appLaunchId ↔ String?
-
Created during initialize, this id is common throughout all traces until
the app is closed.
getter/setter pair
- appName → String
-
Lifecycle observer for automatic app lifecycle tracing
no setter
- commonAttributesFunction ↔ CommonAttributesFunction?
-
A function to return attributes to include in all traces, called when
spans are created but the UITracer. This is a good place to include
value that change over time (as opposed to resource attributes, which
do not change) to correlate traces. Consider adding values for
UserSemantics userId, userRole and userSession.
getter/setter pair
- currentAppLifecycleId ↔ Uint8List?
-
An id for the latest app lifecycle
getter/setter pair
- interactionTracker → OTelInteractionTracker
-
Lifecycle observer for automatic app lifecycle tracing
no setter
- isRecording ↔ bool
-
getter/setter pair
- lifecycleObserver → OTelLifecycleObserver
-
Lifecycle observer for automatic app lifecycle tracing
no setter
- meterProvider → UIMeterProvider
-
Get the MeterProvider instance
no setter
-
repaintBoundaryKey
→ GlobalKey<
State< StatefulWidget> > -
Get the repaint boundary key for wrapping your app
no setter
- routeObserver → OTelNavigatorObserver
-
Add this to the observers in GoRouter or the NavigatorObserver in the
MaterialApp if not using GoRouter
no setter
- screenshotManager → MiddlewareScreenshotManager?
-
no setter
- sessionStartTime ↔ int?
-
Depicts session start time in milliseconds since epoch.
getter/setter pair
- tracer → UITracer
-
Get the Tracer instance
no setter
- tracerProvider → UITracerProvider
-
no setter
Static Methods
-
forceFlush(
) → dynamic - Sends all pending OTel data
-
initialize(
{String? appName, String? endpoint, bool secure = true, String serviceName = defaultServiceName, String? serviceVersion = defaultServiceVersion, String? tracerName, String? tracerVersion, Attributes? resourceAttributes, CommonAttributesFunction? commonAttributesFunction, SpanProcessor? spanProcessor, Sampler? sampler, SpanKind spanKind = SpanKind.client, String? middlewareAccountKey, Duration? flushTracesInterval = const Duration(seconds: 30), bool detectPlatformResources = true, MetricExporter? metricExporter, MetricReader? metricReader, bool enableMetrics = true}) → Future< void> -
maskView(
GlobalKey< State< key) → voidStatefulWidget> > - Mask a sensitive view (e.g., password field)
-
meter(
{String name = 'flutter.default', String? version, String? schemaUrl}) → UIMeter - Get a Meter with the given name and version
-
recordPerformanceMetric(
String name, Duration duration, {Map< String, dynamic> ? attributes}) → void - Records a performance metric
-
reportError(
String message, dynamic error, StackTrace? stackTrace, {Map< String, dynamic> ? attributes}) → void - Records an error within the current context
-
reset(
) → dynamic -
startSessionRecording(
) → Future< void> -
stopSessionRecording(
) → Future< void> - Stop session recording
-
unmaskView(
GlobalKey< State< key) → voidStatefulWidget> > - Unmask a previously masked view
Constants
- defaultServiceName → const String
- defaultServiceVersion → const String
- middlewareEndpoint → const String