@@ -5,18 +5,21 @@ import { TraceState } from '@opentelemetry/core';
55import  type  {  Sampler ,  SamplingResult  }  from  '@opentelemetry/sdk-trace-base' ; 
66import  {  SamplingDecision  }  from  '@opentelemetry/sdk-trace-base' ; 
77import  { 
8-   SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD , 
98  SEMANTIC_ATTRIBUTE_SENTRY_OP , 
109  SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE , 
11-   SEMANTIC_ATTRIBUTE_URL_FULL , 
1210  hasTracingEnabled , 
1311  sampleSpan , 
1412}  from  '@sentry/core' ; 
1513import  type  {  Client ,  SpanAttributes  }  from  '@sentry/types' ; 
1614import  {  logger  }  from  '@sentry/utils' ; 
1715import  {  SENTRY_TRACE_STATE_SAMPLED_NOT_RECORDING ,  SENTRY_TRACE_STATE_URL  }  from  './constants' ; 
1816
19- import  {  SEMATTRS_HTTP_METHOD ,  SEMATTRS_HTTP_URL  }  from  '@opentelemetry/semantic-conventions' ; 
17+ import  { 
18+   ATTR_HTTP_REQUEST_METHOD , 
19+   ATTR_URL_FULL , 
20+   SEMATTRS_HTTP_METHOD , 
21+   SEMATTRS_HTTP_URL , 
22+ }  from  '@opentelemetry/semantic-conventions' ; 
2023import  {  DEBUG_BUILD  }  from  './debug-build' ; 
2124import  {  getPropagationContextFromSpan  }  from  './propagator' ; 
2225import  {  getSamplingDecision  }  from  './utils/getSamplingDecision' ; 
@@ -52,13 +55,13 @@ export class SentrySampler implements Sampler {
5255      return  wrapSamplingDecision ( {  decision : undefined ,  context,  spanAttributes } ) ; 
5356    } 
5457
58+     // `ATTR_HTTP_REQUEST_METHOD` is the new attribute, but we still support the old one, `SEMATTRS_HTTP_METHOD`, for now. 
59+     // eslint-disable-next-line deprecation/deprecation 
60+     const  maybeSpanHttpMethod  =  spanAttributes [ SEMATTRS_HTTP_METHOD ]  ||  spanAttributes [ ATTR_HTTP_REQUEST_METHOD ] ; 
61+ 
5562    // If we have a http.client span that has no local parent, we never want to sample it 
5663    // but we want to leave downstream sampling decisions up to the server 
57-     if  ( 
58-       spanKind  ===  SpanKind . CLIENT  && 
59-       ( spanAttributes [ SEMATTRS_HTTP_METHOD ]  ||  spanAttributes [ SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD ] )  && 
60-       ( ! parentSpan  ||  parentContext ?. isRemote ) 
61-     )  { 
64+     if  ( spanKind  ===  SpanKind . CLIENT  &&  maybeSpanHttpMethod  &&  ( ! parentSpan  ||  parentContext ?. isRemote ) )  { 
6265      return  wrapSamplingDecision ( {  decision : undefined ,  context,  spanAttributes } ) ; 
6366    } 
6467
@@ -109,7 +112,7 @@ export class SentrySampler implements Sampler {
109112      [ SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE ] : sampleRate , 
110113    } ; 
111114
112-     const  method  =  `${ spanAttributes [ SEMATTRS_HTTP_METHOD ] }  ` . toUpperCase ( ) ; 
115+     const  method  =  `${ maybeSpanHttpMethod }  ` . toUpperCase ( ) ; 
113116    if  ( method  ===  'OPTIONS'  ||  method  ===  'HEAD' )  { 
114117      DEBUG_BUILD  &&  logger . log ( `[Tracing] Not sampling span because HTTP method is '${ method }  ' for ${ spanName }  ` ) ; 
115118
@@ -198,7 +201,9 @@ function getBaseTraceState(context: Context, spanAttributes: SpanAttributes): Tr
198201  let  traceState  =  parentContext ?. traceState  ||  new  TraceState ( ) ; 
199202
200203  // We always keep the URL on the trace state, so we can access it in the propagator 
201-   const  url  =  spanAttributes [ SEMATTRS_HTTP_URL ]  ||  spanAttributes [ SEMANTIC_ATTRIBUTE_URL_FULL ] ; 
204+   // `ATTR_URL_FULL` is the new attribute, but we still support the old one, `ATTR_HTTP_URL`, for now. 
205+   // eslint-disable-next-line deprecation/deprecation 
206+   const  url  =  spanAttributes [ SEMATTRS_HTTP_URL ]  ||  spanAttributes [ ATTR_URL_FULL ] ; 
202207  if  ( url  &&  typeof  url  ===  'string' )  { 
203208    traceState  =  traceState . set ( SENTRY_TRACE_STATE_URL ,  url ) ; 
204209  } 
0 commit comments