-
-
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.
ref(tracing): Add necessary helpers for using propagation context on …
…outgoing headers (#8434) This PR adds: 1. A getter for `PropagationContext` on the scope 2. `generateSentryTraceHeader`, which will be used to dynamically create `sentry-trace` headers, regardless of if there is a span or not 3. `getDynamicSamplingContextFromClient`, which is used to generate dynamic sampling context from a client directly (instead of having to go through a transaction) This PR also updates `extractTraceparentData` and `dynamicSamplingContextToSentryBaggageHeader` to be more liberal about the values it takes so we can better accommodate the new flows we are going to add. Co-authored-by: Francesco Novy <[email protected]>
- Loading branch information
1 parent
3625fb1
commit 9006287
Showing
18 changed files
with
120 additions
and
63 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import type { Client, DynamicSamplingContext, Scope } from '@sentry/types'; | ||
import { dropUndefinedKeys } from '@sentry/utils'; | ||
|
||
import { DEFAULT_ENVIRONMENT } from '../constants'; | ||
|
||
/** | ||
* Creates a dynamic sampling context from a client. | ||
* | ||
* Dispatchs the `createDsc` lifecycle hook as a side effect. | ||
*/ | ||
export function getDynamicSamplingContextFromClient( | ||
trace_id: string, | ||
client: Client, | ||
scope?: Scope, | ||
): DynamicSamplingContext { | ||
const options = client.getOptions(); | ||
|
||
const { publicKey: public_key } = client.getDsn() || {}; | ||
const { segment: user_segment } = (scope && scope.getUser()) || {}; | ||
|
||
const dsc = dropUndefinedKeys({ | ||
environment: options.environment || DEFAULT_ENVIRONMENT, | ||
release: options.release, | ||
user_segment, | ||
public_key, | ||
trace_id, | ||
}) as DynamicSamplingContext; | ||
|
||
client.emit && client.emit('createDsc', dsc); | ||
|
||
return dsc; | ||
} |
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
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