-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
3,470 additions
and
311 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
import { createContextKey } from '@opentelemetry/api'; | ||
|
||
export const OTEL_CONTEXT_HUB_KEY = createContextKey('sentry_hub'); | ||
|
||
export const OTEL_ATTR_ORIGIN = 'sentry.origin'; | ||
export const OTEL_ATTR_OP = 'sentry.op'; | ||
export const OTEL_ATTR_SOURCE = 'sentry.source'; | ||
|
||
export const OTEL_ATTR_PARENT_SAMPLED = 'sentry.parentSampled'; | ||
export const OTEL_ATTR_DROP_SPAN = 'sentry.dropSpan'; | ||
|
||
export const OTEL_ATTR_BREADCRUMB_TYPE = 'sentry.breadcrumb.type'; | ||
export const OTEL_ATTR_BREADCRUMB_LEVEL = 'sentry.breadcrumb.level'; | ||
export const OTEL_ATTR_BREADCRUMB_EVENT_ID = 'sentry.breadcrumb.event_id'; | ||
export const OTEL_ATTR_BREADCRUMB_CATEGORY = 'sentry.breadcrumb.category'; | ||
export const OTEL_ATTR_BREADCRUMB_DATA = 'sentry.breadcrumb.data'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import type { Span as OtelSpan } from '@opentelemetry/api'; | ||
import type { Hub, Scope, TransactionMetadata } from '@sentry/types'; | ||
|
||
// We store the parent span, scope & metadata in separate weakmaps, so we can access them for a given span | ||
// This way we can enhance the data that an OTEL Span natively gives us | ||
// and since we are using weakmaps, we do not need to clean up after ourselves | ||
const otelSpanScope = new WeakMap<OtelSpan, Scope>(); | ||
const otelSpanHub = new WeakMap<OtelSpan, Hub>(); | ||
const otelSpanParent = new WeakMap<OtelSpan, OtelSpan>(); | ||
const otelSpanMetadata = new WeakMap<OtelSpan, Partial<TransactionMetadata>>(); | ||
|
||
/** Set the Sentry scope on an OTEL span. */ | ||
export function setOtelSpanScope(span: OtelSpan, scope: Scope): void { | ||
otelSpanScope.set(span, scope); | ||
} | ||
|
||
/** Get the Sentry scope of an OTEL span. */ | ||
export function getOtelSpanScope(span: OtelSpan): Scope | undefined { | ||
return otelSpanScope.get(span); | ||
} | ||
|
||
/** Set the Sentry hub on an OTEL span. */ | ||
export function setOtelSpanHub(span: OtelSpan, hub: Hub): void { | ||
otelSpanHub.set(span, hub); | ||
} | ||
|
||
/** Get the Sentry hub of an OTEL span. */ | ||
export function getOtelSpanHub(span: OtelSpan): Hub | undefined { | ||
return otelSpanHub.get(span); | ||
} | ||
|
||
/** Set the parent OTEL span on an OTEL span. */ | ||
export function setOtelSpanParent(span: OtelSpan, parentSpan: OtelSpan): void { | ||
otelSpanParent.set(span, parentSpan); | ||
} | ||
|
||
/** Get the parent OTEL span of an OTEL span. */ | ||
export function getOtelSpanParent(span: OtelSpan): OtelSpan | undefined { | ||
return otelSpanParent.get(span); | ||
} | ||
|
||
/** Set metadata for an OTEL span. */ | ||
export function setOtelSpanMetadata(span: OtelSpan, metadata: Partial<TransactionMetadata>): void { | ||
otelSpanMetadata.set(span, metadata); | ||
} | ||
|
||
/** Get metadata for an OTEL span. */ | ||
export function getOtelSpanMetadata(span: OtelSpan): Partial<TransactionMetadata> | undefined { | ||
return otelSpanMetadata.get(span); | ||
} |
Oops, something went wrong.