dynatrace_flutter_plugin_dio

Creator: coderz1093

Last updated:

0 purchases

dynatrace_flutter_plugin_dio Image
dynatrace_flutter_plugin_dio Images

Languages

Categories

Add to Cart

Description:

dynatrace flutter plugin dio

Dynatrace Flutter Plugin support with Dio #
This plugin adds support/instrumentation for dio when used with the Dynatrace Flutter Plugin.
Requirements #

Dynatrace Flutter Plugin.
Flutter Version >= 1.12.0
Dart Version >= 2.15
Dio Version >= 5.0.0
Gradle: >= 5.x
Android API Level >= 21
iOS SDK >= 12

Overview #

Usage
Request & Response size calculation

Usage #
Our plugin for Dio provides an extension method, .instrument(), which can be used to automatically tag and time the web requests that are called with the Dio package.
import 'package:dynatrace_flutter_plugin_dio/dynatrace_flutter_plugin_dio.dart';

final dio = Dio();
dio.instrument();
copied to clipboard
Create a user action and correlate the dio request shown in the Waterfall analysis:
import 'package:dynatrace_flutter_plugin_dio/dynatrace_flutter_plugin_dio.dart';
import 'package:dynatrace_flutter_plugin/dynatrace_flutter_plugin.dart';

final dio = Dio();
dio.instrument();

var url = 'https://dynatrace.com';
DynatraceRootAction dioAction =
Dynatrace().enterAction('Dio Action');

try {
await dio.get(url);
} catch (error) {
// insert error handling here
} finally {
dioAction.leaveAction();
}
copied to clipboard

Note:
If you do not create a user action around the dio request, our plugin will automatically create a user action which will include the request in the Waterfall analysis of such action. The name of this action is **Dio Request:
Request & Response size calculation #
The web request instrumentation is by default reporting request and response bytes. This calculation has some limitations, therefore the instrument function allows you to pass DynatraceClientAdapterOptions. Per default, Dio will append following headers:

"Accept-Encoding": "gzip"
"User-Agent": "Dart/X.X (dart:io)"

These headers are not visible at the request size calculation, but can be modified via HttpClient used in Dio (e.g request.headers.removeAll(HttpHeaders.acceptEncodingHeader)). If the header value will be overridden by a different value, our calculation will not be able to consider this as we expect the default header value. For example, if "Accept-Encoding" is removed, use DynatraceClientAdapterOptions to get correct values for the request size calculation (see the example below). If headers are changed on request basis and a different "Accept-Encoding" value is appended directly, the calculation will consider this.
import 'package:dynatrace_flutter_plugin_dio/dynatrace_flutter_plugin_dio.dart';
import 'package:dynatrace_flutter_plugin/dynatrace_flutter_plugin.dart';

Map<String, String> _myNewDefaultHeaders = {
"User-Agent": "Dart/X.X (dart:io)"
};
DynatraceClientAdapterOptions _options = DynatraceClientAdapterOptions(_myNewDefaultHeaders);

final dio = Dio();
dio.instrument(options: _options);

var url = 'https://dynatrace.com';
DynatraceRootAction dioAction =
Dynatrace().enterAction('Dio Action');

try {
await dio.get(url);
} catch (error) {
// insert error handling here
} finally {
dioAction.leaveAction();
}
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.