Community implementation of native bindings for Datadog's SDK. This is not an official package.
- Generate a client token from Datadog through the Settings > API panel (under Client Tokens).
- Initialize:
ddLogger = DatadogFlutter( clientToken: myDatadogClientToken, serviceName: 'my-app-name', environment: 'production', )
In its default implementation, log data will only be transmitted to Datadog through Logger
records. print
statements are not guaranteed to be captured.
It is strongly recommended to include access DatadogFlutter
through a singleton instead of multiple instantiations.
use_frameworks!
(Flutter includes this by default) and your minimum iOS target must be >= 11. This is a requirement from the Datadog SDK.
ddLogger.addTag('restaurant_type', 'pizza');
ddLogger.removeTag('restaurant_type');
// add attribute to every log
ddLogger.addAttribute('toppings', 'extra_cheese');
// add atttributes to some logs
ddLogger.log('time to cook pizza', Level.FINE, attributes: {
'durationInMilliseconds': timer.elapsedMilliseconds,
});
By default, the DatadogFlutter
default constructor will send all logs from Logger
to Datadog. To ignore, set bindOnRecord
:
DatadogFlutter(
clientToken: myDatadogClientToken,
bindOnRecord: false,
)
And log conditionally later:
Logger.root.onRecord.listen((record) async {
if (shouldSendToDatadog) {
ddLogger.onRecordCallback(record)
}
});