Configuration options

Discover configuration options to customize your BugSnag integration.

Setting configuration options

Configuration options can be set by setting named parameters when calling bugsnag_performance.start():

Available options

 API key

The API key used for performance data sent to BugSnag.

await bugsnag_performance.start(
  apiKey: 'YOUR_API_KEY_HERE'
);

You can find your API key in Project Settings from your BugSnag dashboard.

App version information

Setting your app’s version in configuration allows you to see performance data for a specific release:

await bugsnag_performance.start(
  apiKey: 'YOUR_API_KEY_HERE', 
  appVersion: '1.2.3'
);

Auto instrumentation

The instrumentation added to your app to capture measurements can be disabled entirely using the following configuration options:

await bugsnag_performance.start(
  apiKey: apiKey, 
  instrumentAppStart: false,
  instrumentNavigation: false
);

Custom attribute limits

The following configuration options can be used to increase the size of custom attribute data that can be stored in each span:

await bugsnag_performance.start(
  apiKey: apiKey, 
  attributeCountLimit: 200,
  attributeStringValueLimit: 5000
  attributeArrayLengthLimit: 5000
);

The number of attributes is limited to 128 by default and subsequent attributes are dropped. The limit can be increased up to 1000.

Individual string values are limited to 1024 by default and array values to 1000 with excess characters and elements being truncated. These limits can both be increased up to 10,000.

The key used for the attribute has a fixed limit of 1024. Attributes with a longer key will be dropped.

Care should be taken to avoid adding excessive data as oversized span payloads are rejected by the BugSnag API. If the payload limits are being reached for your project, a warning will be displayed on your Performance dashboard.

Endpoint

By default we will send trace and span data to the bugsnag.com web service address for traces.

If you are using BugSnag On-premise you’ll need to set this to your Trace Server endpoint.

await bugsnag_performance.start(
  apiKey: apiKey, 
  endpoint: Uri.parse('YOUR_ENDPOINT_HERE')
);

Network request callback

If you are using one of the BugSnag packages to instrument network requests, you can control which network requests are captured and sanitize the URL string sent to your BugSnag dashboard using the networkRequestCallback configuration option. The network request span will be transmitted to BugSnag using the url in the returned object, or will not be sent at all if null is returned:

await bugsnag_performance.start(
  apiKey: apiKey, 
  networkRequestCallback: (requestInfo) {
    // Don't send network request span
    if (requestInfo.url!.contains('no-track.com')){
      return null;
    }

    // Remove user ID
    if (requestInfo.type == 'GET'
        && RegExp(r"/account\/[0-9]+/").hasMatch(requestInfo.url!)) {
      requestInfo.url = requestInfo.url?.replaceAll(RegExp(r'/account/[0-9]+/'),
                                                    'account/[account-id]');
    }

    return requestInfo;
  }
);

Release stages

Setting a release stage in your configuration allows you to filter performance data by different stages of the application release process (development, production, etc) in the BugSnag dashboard:

await bugsnag_performance.start(
  apiKey: apiKey, 
  releaseStage: 'staging'
);

// if no release stage is set then we will automatically use the following:
Platform.environment['DEPLOYMENT_ENVIRONMENT'];

You can also limit which builds send performance data by setting the enabledReleaseStages configuration option:

await bugsnag_performance.start(
  apiKey: apiKey, 
  enabledReleaseStages: ['production'],['staging']
);

By default, performance data will be sent for all stages.

Span callbacks

Callback functions can be registered to tranform and filter spans before they are sent to BugSnag:

await bugsnag_performance.start(
  apiKey: apiKey, 
  onSpanEndCallbacks: [
    (span) async {
      span.setAttribute('device.locale', 'en-US');
      return true;
    }
  ],
);

These callbacks can be executed with a high frequency, so care should be taken not to perform complex operations that will have a detrimental effect on performance. To aid diagnostics, the amount of time taken for the callbacks to run is captured in the bugsnag.span.callbacks_duration attribute and shown on the span details panel on the Performance dashboard.

You can perform any operation on the span during the callback, but you should avoid ending the span from inside the callback to prevent a recursive loop.

The return value from the callback determines whether the span will be sent. When a span is discarded, it doesn’t affect other spans in the trace. Therefore returning false in your callback will result in an incomplete trace being shown in your dashboard. In general we recommend returning true in all cases to allow the built-in probability-based sampling to run without potential biases in the aggregated data.

Trace propagation

Enabling this option sends OpenTelemetry compatible trace context headers on network requests made to your servers.

If you are using one of the BugSnag packages to instrument network requests this is enabled by setting the tracePropagationUrls configuration option to control which URLs should include the header:

await bugsnag_performance.start(
  apiKey: apiKey,
  tracePropagationUrls: [
    RegExp(r'^(http(s)?(://))?(www\.)?example\.com(/.*)?$')
  ]
);

We only recommend sending this information to servers that are under your control and instrumented by OpenTelemetry. Once configured, you will be able to see full distributed traces in BugSnag.