Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ In order to enable Datadog [Distributed Tracing][13], you must set the `DatadogC

- `DatadogRumConfiguration.traceSampleRate` sets a default sampling rate of 20%. If you want all resources requests to generate a full distributed trace, set this value to `100.0`.

### Track resources from other packages

While `Datadog Tracking HTTP Client` can track most common network calls in Flutter, Datadog supplies packages for integration into specific networking libraries, including gRPC, GraphQL and Dio. For more information about these libraries, see [Integrated Libraries][22].

## Enrich user sessions

Flutter RUM automatically tracks attributes such as user activity, views (using the `DatadogNavigationObserver`), errors, native crashes, and network requests (using the Datadog Tracking HTTP Client). See the [RUM Data Collection documentation][14] to learn about the RUM events and default attributes. You can further enrich user session information and gain finer control over the attributes collected by tracking custom events.
Expand Down Expand Up @@ -422,7 +426,7 @@ To enable the collection of Flutter-specific performance metrics, set `reportFlu

## OpenTelemetry setup

The [Datadog Tracking HTTP Client][10] package and [gRPC Interceptor][19] package both support distributed traces through both automatic header generation and header ingestion. This section describes how to use OpenTelemetry with RUM Flutter.
All of Datadog's automatic network tracking packages ([Datadog Tracking HTTP Client][10], [gRPC Interceptor][19], [GQL Link][20], and [Dio Interceptor][21]) support distributed traces through both automatic header generation and header ingestion. This section describes how to use OpenTelemetry with RUM Flutter.

### Datadog header generation

Expand Down Expand Up @@ -484,3 +488,6 @@ if (DatadogSdk.instance.isFirstPartyHost(host)){
[17]: https://pub.dev/documentation/datadog_flutter_plugin/latest/datadog_flutter_plugin/
[18]: /real_user_monitoring/application_monitoring/mobile_vitals/?tab=flutter
[19]: https://pub.dev/packages/datadog_grpc_interceptor
[20]: https://pub.dev/packages/datadog_gql_link
[21]: https://pub.dev/packages/datadog_dio
[22]: /real_user_monitoring/application_monitoring/flutter/integrated_libraries
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,49 @@ final datadogConfig = DatadogConfiguration(
);
```

## Dio

<div class="alert alert-info">
For most Dio setups, use Datadog Tracking Http Client instead of the specialized Dio interceptor. Only use the Dio interceptor if you're using a non-standard Dio <code>HttpClientAdapter</code> that cannot be tracked by Datadog Tracking Http Client.
</div>

Datadog provides [`datadog_dio`][6] for use with the [Dio Flutter package][7]. The Dio interceptor automatically tracks requests from a given Dio client as RUM Resources and enables distributed tracing with APM.

### Setup

Add `datadog_dio` to your `pubspec.yaml` or by running `flutter pub add datadog_dio` from your terminal:

```yaml
dependencies:
# Other dependencies
datadog_dio: ^1.0.0
```

To use this plugin, call `addDatadogInterceptor` at the end of your Dio initialization:

```dart
import 'package:datadog_dio/datadog_dio.dart'

// Initialize Datadog - be sure to set the [DatadogConfiguration.firstPartyHosts] member
// Enable Datadog Distributed Tracing
final config = DatadogConfiguration(
// ...
firstPartyHosts = ['localhost']
)

// Create our Dio client
final dio = Dio()
// Dio configuration...
..addDatadogInterceptor(DatadogSdk.instance);
```

Calling `addDatadogInterceptor` adds the Datadog interceptor as the first interceptor in your list. This ensures all network requests from Dio are sent to Datadog, since other interceptors may not forward information down the chain. Call `addDatadogInterceptor` after completing all other Dio configuration.

### Use with other Datadog Network Tracking

To track all network requests, including those made by `dart:io` and widgets like `NetworkImage`, use `datadog_tracking_http_client` to capture these requests. However, depending on your setup, the global override method used in `enableHttpTracking` may cause resources to be double reported (once by the global override and once by the Dio interceptor)

To avoid this, use the `ignoreUrlPatterns` parameter when calling `enableHttpTracking` to ignore requests made by your Dio client.

## Further Reading

Expand All @@ -232,3 +274,4 @@ final datadogConfig = DatadogConfiguration(
[8]: https://pub.dev/packages/webview_flutter
[9]: https://pub.dev/packages/flutter_inappwebview
[10]: /real_user_monitoring/application_monitoring/web_view_tracking?tab=flutter
[11]: https://pub.dev/packages/datadog_dio
Loading