@@ -4,16 +4,11 @@ import { context } from '@opentelemetry/api';
4
4
import { propagation , trace } from '@opentelemetry/api' ;
5
5
import { W3CBaggagePropagator , isTracingSuppressed } from '@opentelemetry/core' ;
6
6
import { ATTR_URL_FULL , SEMATTRS_HTTP_URL } from '@opentelemetry/semantic-conventions' ;
7
- import type { continueTrace } from '@sentry/core' ;
7
+ import type { continueTrace } from '@sentry/core' ;
8
+ import { getDynamicSamplingContextFromScopes } from '@sentry/core' ;
8
9
import { getRootSpan } from '@sentry/core' ;
9
10
import { spanToJSON } from '@sentry/core' ;
10
- import {
11
- getClient ,
12
- getCurrentScope ,
13
- getDynamicSamplingContextFromClient ,
14
- getDynamicSamplingContextFromSpan ,
15
- getIsolationScope ,
16
- } from '@sentry/core' ;
11
+ import { getClient , getCurrentScope , getDynamicSamplingContextFromSpan , getIsolationScope } from '@sentry/core' ;
17
12
import type { DynamicSamplingContext , Options , PropagationContext } from '@sentry/types' ;
18
13
import {
19
14
LRUMap ,
@@ -204,8 +199,7 @@ function getInjectionData(context: Context): {
204
199
if ( span && ! spanIsRemote ) {
205
200
const spanContext = span . spanContext ( ) ;
206
201
207
- const propagationContext = getPropagationContextFromSpan ( span ) ;
208
- const dynamicSamplingContext = getDynamicSamplingContext ( propagationContext , spanContext . traceId ) ;
202
+ const dynamicSamplingContext = getDynamicSamplingContextFromSpan ( span ) ;
209
203
return {
210
204
dynamicSamplingContext,
211
205
traceId : spanContext . traceId ,
@@ -216,9 +210,10 @@ function getInjectionData(context: Context): {
216
210
217
211
// Else we try to use the propagation context from the scope
218
212
const scope = getScopesFromContext ( context ) ?. scope || getCurrentScope ( ) ;
213
+ const client = getClient ( ) ;
219
214
220
215
const propagationContext = scope . getPropagationContext ( ) ;
221
- const dynamicSamplingContext = getDynamicSamplingContext ( propagationContext , propagationContext . traceId ) ;
216
+ const dynamicSamplingContext = client ? getDynamicSamplingContextFromScopes ( client , scope ) : undefined ;
222
217
return {
223
218
dynamicSamplingContext,
224
219
traceId : propagationContext . traceId ,
@@ -227,26 +222,6 @@ function getInjectionData(context: Context): {
227
222
} ;
228
223
}
229
224
230
- /** Get the DSC from a context, or fall back to use the one from the client. */
231
- function getDynamicSamplingContext (
232
- propagationContext : PropagationContext ,
233
- traceId : string | undefined ,
234
- ) : Partial < DynamicSamplingContext > | undefined {
235
- // If we have a DSC on the propagation context, we just use it
236
- if ( propagationContext ?. dsc ) {
237
- return propagationContext . dsc ;
238
- }
239
-
240
- // Else, we try to generate a new one
241
- const client = getClient ( ) ;
242
-
243
- if ( client ) {
244
- return getDynamicSamplingContextFromClient ( traceId || propagationContext . traceId , client ) ;
245
- }
246
-
247
- return undefined ;
248
- }
249
-
250
225
function getContextWithRemoteActiveSpan (
251
226
ctx : Context ,
252
227
{ sentryTrace, baggage } : Parameters < typeof continueTrace > [ 0 ] ,
0 commit comments