LogDrop

Tracing

Trace Flutter requests from the device into your backend with the LogDrop Flutter SDK.

The Flutter SDK adds a W3C traceparent header to the requests your Dart code makes through dart:io, and the native Android and iOS SDKs send each request as one client span. Flutter itself creates, queues and sends no spans, so there is no OpenTelemetry package to add and nothing to configure in Dart.

A backend traced by LogDrop continues the same trace, so one request shows up in Trace Explorer from the device into your services.

Rules that all LogDrop mobile SDKs share (authentication, which requests are traced, delivery and limits) are on End-to-end Tracing.

1. Use SDK 3.0.7 or later

Tracing needs Flutter SDK 3.0.7 or later. Set the package version in pubspec.yaml:

pubspec.yaml
dependencies:
  logdrop_flutter_sdk: ^3.1.0

Version 3.0.7 brings the native Android and iOS SDKs 2.1.11, which contain the tracing. The native setup on Android and iOS is unchanged; see Native Configuration.

2. Initialize in Dart

Tracing starts with the LogDropFlutter.init() call your app already makes; there is no separate tracing call. Where you place that call matters, as the notes below the code explain.

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await LogDropFlutter.init();
  runApp(const MyApp());
}

LogDropFlutter.init() installs LogDrop's HttpOverrides, wrapping any override that was already set.

  • If your app sets HttpOverrides.global itself, do it before LogDropFlutter.init(). An override set afterwards replaces LogDrop's and turns tracing off for Dart requests.
  • Call LogDropFlutter.init() before your app creates HTTP clients: an HttpClient created earlier is never traced. Dio, for example, keeps the client it creates for its first request.

The App ID from the native configuration is all the SDK needs: spans go to <base URL>/v1/traces with the header x-logdrop-app-id. Turn on HTTP Logging for the project in the panel.

Your backend must send its traces to the same LogDrop project as this app, with an ingest key created in the app's project (why).

What is traced

Not every request gets a trace. This list shows which requests get a traceparent header and a span, and how Dart and the native SDK share the work.

  • Requests through dart:io HttpClient and the packages built on it: package:http (IOClient), Dio's default adapter, Image.network and similar.
  • Clients that bypass dart:io, such as cronet_http or cupertino_http, are not traced by the Dart layer.
  • Requests that your plugins make natively are traced by the native SDKs, as described for Android and iOS. On Android this needs the LogDrop Gradle plugin; Dart requests do not.
  • For each request, Dart asks the native SDK once whether to trace it, then keeps or sets traceparent and hands one HTTP record to the native SDK, which turns it into the client span. A valid traceparent your app set itself is kept, and no span is sent for it.

The other rules are in Which requests are traced.

Delivery

The native SDKs queue, split and send the spans, with the limits and retries in Delivery.

Send queued spans now (optional)

The SDK sends spans on its own. flushOtlpTracing asks it to send the queued spans now and tells you whether that worked. Use it where you need the spans out right away, for example at the end of an integration test or before the user signs out.

import 'package:logdrop_flutter_sdk/logdropsdk.dart';

final delivered = await LogDrop.flushOtlpTracing(timeout: const Duration(seconds: 2));
  • It waits at most the timeout (default 2 seconds, at most 5 seconds; a longer timeout waits 5 seconds) and returns true only when the native SDK confirms delivery.
  • false means a timeout, no network, a batch waiting for its retry, or spans dropped since the previous flush. The queued spans are still sent later.
  • It throws a PlatformException with the code OTLP_SDK_UNAVAILABLE when the native SDK in the app has no span exporter, which happens only if your app forces a native SDK older than 2.1.11.

Changing the App ID

LogDrop.setAppId(...) drops the spans queued for the previous App ID. This way a span is never sent with another project's App ID.

Check it

To confirm that tracing works, make one request from the app and find its trace in the panel. Follow Check it. The device span is under your app's package name (Android) or bundle identifier (iOS) in Trace Explorer.

Known limits

In these cases a trace can miss spans, a request can carry traceparent where you did not expect it, or a request sent again shows up as a separate trace.

  • dart:io follows redirects itself, with the first request's decision. The ignore rules are checked for the first URL only, so a redirect to an ignored host still carries traceparent, and a redirect is not a separate span.
  • App-level retries start a new trace. dart:io has no retry hook, so a request your code (or a Dio retry interceptor) sends again is a new request with a new trace.
  • The device clock must not run more than 5 minutes ahead of LogDrop's.
  • Requests that plugins send natively follow the native limits; for example, on iOS URLSession's own connection retries share one client span (iOS).

On this page