# Custom Instrumentation | Sentry for Zap

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

To set it up manually, all you have to do is to make sure your application extracts incoming headers and to set those headers again when making an outgoing request within your application.

## [Step 1) Extract Incoming Tracing Information](https://docs.sentry.io/platforms/go/guides/zap/tracing/trace-propagation/custom-instrumentation.md#step-1-extract-incoming-tracing-information)

Incoming tracing information has to be extracted and stored in memory for later use. Sentry provides the `sentry.ContinueTrace()` function to help you with this. Incoming tracing information can come from different places:

* In a web environment it will be sent via HTTP headers, for example, by another Sentry SDK used in your frontend project.
* You also can pick up tracing information from environment variables.

Here's an example of how to extract and store incoming tracing information using `sentry.ContinueTrace()`:

```go
ctx := r.Context()
hub := sentry.GetHubFromContext(ctx)
sentry.ContinueTrace(hub, r.Header.Get(sentry.SentryTraceHeader), r.Header.Get(sentry.SentryBaggageHeader)),
```

Sentry's `sentry.ContinueTrace()` function will extract the given headers, try to find the `sentry-trace` and `baggage` headers, and store them in memory for later use.

## [Step 2) Inject Tracing Information to Outgoing Requests](https://docs.sentry.io/platforms/go/guides/zap/tracing/trace-propagation/custom-instrumentation.md#step-2-inject-tracing-information-to-outgoing-requests)

For distributed tracing to work, the two headers `sentry-trace` and `baggage`, must now also be added to outgoing requests. If you pregenerate HTML on the server-side, you might want to take a look at option 2 as well, which describes how to pass on tracing information through HTML meta tags.

### [Inject Tracing Information Into HTTP Requests](https://docs.sentry.io/platforms/go/guides/zap/tracing/trace-propagation/custom-instrumentation.md#inject-tracing-information-into-http-requests)

You can generate this tracing information with the Sentry SDK's `hub.GetTraceparent()` and `hub.GetBaggage()` functions. Here's an example using Guzzle:

```go
ctx := r.Context()
hub := sentry.GetHubFromContext(ctx)
req, _ := http.NewRequest("GET", "http://example.com", nil)
req.Header.Set(sentry.SentryTraceHeader, hub.GetTraceparent())
req.Header.Set(sentry.SentryBaggageHeader, hub.GetBaggage())
```

In this example, tracing information is propagated to the project running at `https://example.com`. If this project uses a Sentry SDK, it will extract and save the tracing information for later use.

The two services are now connected with your custom distributed tracing implementation.

## [Verification](https://docs.sentry.io/platforms/go/guides/zap/tracing/trace-propagation/custom-instrumentation.md#verification)

If you make outgoing requests from your project to other services, check if the headers `sentry-trace` and `baggage` are present in the request. If so, distributed tracing is working.
