---
title: "Custom Instrumentation"
url: https://docs.sentry.io/platforms/dart/guides/flutter/tracing/trace-propagation/custom-instrumentation/
---

# Custom Instrumentation | Sentry for Flutter

On this page you will learn how to manually propagate trace information into and out of your Dart application.

To obtain a trace header from the span, use `ISentrySpan#toSentryTrace()` method. Then pass it to the downstream service. If the communication happens over HTTP, it is recommended that you set the value to the `sentry-trace` HTTP header.

To create a span as a continuation of the trace retrieved from the upstream service, pass the `sentry-trace` header value to the transaction context:

```dart
import 'package:sentry/sentry.dart';

final header = request.headers['sentry-trace'];
final sentryTraceHeader = SentryTraceHeader.fromTraceHeader(header);
try {
  final transaction = Sentry.startTransactionWithContext(SentryTransactionContext.fromSentryTrace('name', 'operation', sentryTraceHeader));
} catch (error) {
  // handle [InvalidSentryTraceHeaderException] if invalid `sentry-trace` header.
}
```

The `SentryHttpClient` instrumentation handles trace continuations automatically when enabling the [performance](https://docs.sentry.io/platforms/dart/performance.md) feature.
