Skip to content
This repository was archived by the owner on Aug 14, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 38 additions & 4 deletions src/docs/sdk/performance/opentelemetry.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,51 @@ const sdk = new NodeSDK({
});
```

### Step 2: Define `isSentryRequest`
### Step 2: Implement the SentryPropagator on your SDK Add SentryPropagator

We want to make sure we don't create spans that represent requests to Sentry
`SentryPropagator` is used to inject/extract `sentry-trace` and `baggage` headers to make trace propogation and dynamic sampling work correctly.

TODO @neel
```ts
import { Context, TextMapPropagator } from "@opentelemetry/api";
import { SpanContext } from "@opentelemetry/api";

export class SentryPropagator implements TextMapPropagator {
inject(context: Context, carrier: unknown, setter: TextMapSetter): void {
const spanContext = getSpanContext(context);
if (isSentryRequest(spanContext)) {
return;
}

const sentryTrace = generateSentryTrace(spanContext);
setSentryTraceHeader(carrier, sentryTrace, setter);

const baggage = generateBaggageFromContext(context);
setBaggageHeader(carrier, baggage, setter);
}

extract(context: Context, carrier: unknown, getter: TextMapGetter): Context {
const sentryTraceParent = extractSentryTraceFromCarrier(carrier, getter);
setSentryTraceInfoOnSpanContext(context, sentryTraceParent);

const dynamicSamplingContext = extractBaggageFromCarrier(carrier, getter);
setDynamicSamplingContextOnSpanContext(context, dynamicSamplingContext);

return context;
}
}
```

### Step 3: Define `isSentryRequest`

We want to make sure that we don't create Sentry Spans for requests to Sentry.

TODO: We need to make sure we filter these out somehow. Spec WIP

### Step 3: Define `getTraceData`

We want to make sure a transaction is started with information from the `sentry-trace` and `baggage` headers.

TODO @neel
If the user is using the `SentryPropagator`, the `sentry-trace` information should be getting attached to incoming spans automatically. This should mean that we don't need to explicitly grab the header. The `SentryPropagator` should also be putting the Dynamic Sampling Context from the baggage header onto the OpenTelemetry Context, which then can be used in `getTraceData` to inject the DSC in during transaction creation.

### Step 4: Define `updateSpanWithOtelData`

Expand Down