From 16ae86673e158784821243f62a67243cb26c1824 Mon Sep 17 00:00:00 2001 From: Archish Date: Thu, 1 Oct 2026 17:06:57 +0530 Subject: [PATCH 1/2] :art: updated middleware dart package --- README.md | 27 ++++++++++++++++++++ lib/src/web/web_instrumentation_options.dart | 19 ++++++-------- pubspec.yaml | 2 +- 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index ae4656e..c86c3cf 100644 --- a/README.md +++ b/README.md @@ -343,6 +343,33 @@ await FlutterOTel.initialize( ); ``` +### Network Requests (Android / iOS / desktop) + +Outside the browser there is nothing to patch, so wrap the client your app +uses. Each request gets a `GET host/path` client span (`event.type=xhr`), the +same name the web SDK uses, and carries trace headers so your backend's spans +join the app's trace: + +```dart +final client = http.Client().instrument(); // package:http +dio.addOTelInstrumentation(); // dio +``` + +By default both W3C (`traceparent`) and B3 (`b3`, `x-b3-*`) headers are sent. +To send only one: + +```dart +final client = http.Client().instrument( + config: const HttpInstrumentationConfig( + tracePropagationFormat: TracePropagationFormat.b3, // or .w3c + ), +); +``` + +Use `shouldInstrument: (url) => ...` to skip URLs. Skipped requests get no +span and no headers. On web the browser instrumentation already covers every +client, so wrap only when `!kIsWeb` to avoid a second span per request. + ### Platform-Specific Exporters Flutterrific automatically selects the right protocol: diff --git a/lib/src/web/web_instrumentation_options.dart b/lib/src/web/web_instrumentation_options.dart index ef1e0c9..c8afb90 100644 --- a/lib/src/web/web_instrumentation_options.dart +++ b/lib/src/web/web_instrumentation_options.dart @@ -1,16 +1,13 @@ // Licensed under the Apache License, Version 2.0 -/// Trace-context header formats injected into instrumented requests. -enum TracePropagationFormat { - /// W3C `traceparent` only. - w3c, - - /// B3 single (`b3`) and multi (`X-B3-*`) headers. - b3, - - /// W3C plus both B3 encodings (browser SDK default). - all, -} +import 'package:middleware_dart_opentelemetry/middleware_dart_opentelemetry.dart' + show TracePropagationFormat; + +// One enum for web and mobile: the web options take it here, and the mobile +// `HttpInstrumentationConfig` (OTelHttpClient / OTelDioInterceptor) takes the +// same type. +export 'package:middleware_dart_opentelemetry/middleware_dart_opentelemetry.dart' + show TracePropagationFormat; /// Browser instrumentation for Flutter web, mirroring the Middleware browser /// SDK (`@middleware.io/browser`). Ignored on every other platform. diff --git a/pubspec.yaml b/pubspec.yaml index 6532584..2f2056b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ environment: dependencies: flutter: sdk: flutter - middleware_dart_opentelemetry: ^1.0.6 + middleware_dart_opentelemetry: ^1.0.7 # Pinned: 1.0.0-rc.1 removed the Flutter semantic enums # (NavigationAction, AppLifecycleSemantics, InteractionType, ...) this SDK # builds against. From 95cedff4f01998508f486c23a39f5418f2f8b175 Mon Sep 17 00:00:00 2001 From: Archish Date: Thu, 1 Oct 2026 17:08:06 +0530 Subject: [PATCH 2/2] :art: updated flutter middleware package --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 2f2056b..f313fc7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: middleware_flutter_opentelemetry description: "A Flutter package for OpenTelemetry based on middleware_dart_opentelemetry" -version: 2.1.0 +version: 2.1.1 homepage: https://middleware.io repository: https://github.com/middleware-labs/flutter-sdk.git