-
-
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.
fix(node): Unify
getDynamicSamplingContextFromSpan
(#12522)
We used to have a different implementation, that worked slightly different. This had two problems: 1. We did not look up the root span in the OTEL implementation, but relied on already passing in the root span (in core, we convert it to root span) 2. We did not use frozen DSC properly Now, the core implementation just works for both OTEL and core spans. While at this, it also aligns the behavior of looking at the `source` of a span for DSC. Now, only if the source is `url` we'll _not_ set the transaction on the DSC - previously, if no source was set at all, we'd also skip this. But conceptually "no source" is similar to "custom", which we _do_ allow, so now this is a bit simpler. Fixes #12508
- Loading branch information
Showing
13 changed files
with
95 additions
and
99 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
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
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
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
65 changes: 0 additions & 65 deletions
65
packages/opentelemetry/src/utils/dynamicSamplingContext.ts
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
packages/opentelemetry/src/utils/enhanceDscWithOpenTelemetryRootSpanName.ts
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,28 @@ | ||
import { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, spanToJSON } from '@sentry/core'; | ||
import type { Client } from '@sentry/types'; | ||
import { parseSpanDescription } from './parseSpanDescription'; | ||
import { spanHasName } from './spanTypes'; | ||
|
||
/** | ||
* Setup a DSC handler on the passed client, | ||
* ensuring that the transaction name is inferred from the span correctly. | ||
*/ | ||
export function enhanceDscWithOpenTelemetryRootSpanName(client: Client): void { | ||
client.on('createDsc', (dsc, rootSpan) => { | ||
// We want to overwrite the transaction on the DSC that is created by default in core | ||
// The reason for this is that we want to infer the span name, not use the initial one | ||
// Otherwise, we'll get names like "GET" instead of e.g. "GET /foo" | ||
// `parseSpanDescription` takes the attributes of the span into account for the name | ||
// This mutates the passed-in DSC | ||
if (rootSpan) { | ||
const jsonSpan = spanToJSON(rootSpan); | ||
const attributes = jsonSpan.data || {}; | ||
const source = attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]; | ||
|
||
const { description } = spanHasName(rootSpan) ? parseSpanDescription(rootSpan) : { description: undefined }; | ||
if (source !== 'url' && description) { | ||
dsc.transaction = description; | ||
} | ||
} | ||
}); | ||
} |
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