Kubesense Dio integration

A package for use with Dio and the Kubesense SDK, used to track performance of HTTP calls and enable Kubesense Distributed Tracing.

Getting started

To use the Kubesense Dio Interceptor, call addKubesenseInterceptor on your Dio object:

import 'package:kubesense_dio/kubesense_dio.dart'

Dio dio = Dio()
  // Other Dio configuration...
  ..addKubesenseInterceptor(KubesenseSdk.instance);

In order to enable Kubesense Distributed Tracing, you also need to set the firstPartyHosts property when configuring Kubesense.

import 'package:kubesense_tracking_http_client/kubesense_tracking_http_client.dart';

final configuration = KubesenseConfiguration(
  // configuration
  firstPartyHosts: ['example.com'],
)

Use with other Dio interceptors

addKubesenseInterceptor adds the Kubesense interceptor as the first interceptor in your list of interceptors, which is important to ensure that all network requests from Dio are sent to Kubesense, as other interceptors may decide not to forward information down the interceptor chain. For this reason, it is important to make sure you call addKubesenseInterceptor after any other configuration of Dio is complete.

Use with other Kubesense Network Tracking

Clients that want to track all network requests, including those made by dart:io and widgets like NetworkImage can continue to use kubesense_tracking_http_client to capture these requests. However, depending on your setup, the global overide 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, we recommend using ignoreUrlPatterns parameter when calling enableHttpTracking to ignore requests made by your Dio client.

License

Apache License, v2.0

Libraries

kubesense_dio