11import { TraceFlags , context , trace } from '@opentelemetry/api' ;
22import type { SpanProcessor } from '@opentelemetry/sdk-trace-base' ;
3- import { spanToJSON } from '@sentry/core' ;
4- import { SentrySpanProcessor , getClient , setPropagationContextOnContext } from '@sentry/opentelemetry' ;
3+ import { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE , spanToJSON } from '@sentry/core' ;
4+ import { SentrySpanProcessor , setPropagationContextOnContext } from '@sentry/opentelemetry' ;
55import type { PropagationContext , TransactionEvent } from '@sentry/types' ;
66import { logger } from '@sentry/utils' ;
77
88import * as Sentry from '../../src' ;
9- import type { NodeClient } from '../../src/sdk/client' ;
109import { cleanupOtel , getProvider , mockSdkInit } from '../helpers/mockSdkInit' ;
1110
1211describe ( 'Integration | Transactions' , ( ) => {
@@ -20,7 +19,7 @@ describe('Integration | Transactions', () => {
2019
2120 mockSdkInit ( { enableTracing : true , beforeSendTransaction } ) ;
2221
23- const client = Sentry . getClient < NodeClient > ( ) ;
22+ const client = Sentry . getClient ( ) ! ;
2423
2524 Sentry . addBreadcrumb ( { message : 'test breadcrumb 1' , timestamp : 123456 } ) ;
2625 Sentry . setTag ( 'outer.tag' , 'test value' ) ;
@@ -29,11 +28,11 @@ describe('Integration | Transactions', () => {
2928 {
3029 op : 'test op' ,
3130 name : 'test name' ,
32- attributes : {
33- [ Sentry . SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ] : 'task' ,
34- } ,
3531 origin : 'auto.test' ,
3632 metadata : { requestPath : 'test-path' } ,
33+ attributes : {
34+ [ SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ] : 'task' ,
35+ } ,
3736 } ,
3837 span => {
3938 Sentry . addBreadcrumb ( { message : 'test breadcrumb 2' , timestamp : 123456 } ) ;
@@ -88,6 +87,8 @@ describe('Integration | Transactions', () => {
8887 'sentry.op' : 'test op' ,
8988 'sentry.origin' : 'auto.test' ,
9089 'sentry.source' : 'task' ,
90+ 'sentry.sample_rate' : 1 ,
91+ 'test.outer' : 'test value' ,
9192 } ,
9293 op : 'test op' ,
9394 span_id : expect . any ( String ) ,
@@ -120,6 +121,7 @@ describe('Integration | Transactions', () => {
120121 tags : {
121122 'outer.tag' : 'test value' ,
122123 'test.tag' : 'test value' ,
124+ transaction : 'test name' ,
123125 } ,
124126 timestamp : expect . any ( Number ) ,
125127 transaction : 'test name' ,
@@ -175,39 +177,31 @@ describe('Integration | Transactions', () => {
175177
176178 mockSdkInit ( { enableTracing : true , beforeSendTransaction } ) ;
177179
178- const client = Sentry . getClient ( ) ;
180+ const client = Sentry . getClient ( ) ! ;
179181
180182 Sentry . addBreadcrumb ( { message : 'test breadcrumb 1' , timestamp : 123456 } ) ;
181183
182184 Sentry . withIsolationScope ( ( ) => {
183- Sentry . startSpan (
184- {
185- op : 'test op' ,
186- name : 'test name' ,
187- origin : 'auto.test' ,
188- attributes : { [ Sentry . SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ] : 'task' } ,
189- } ,
190- span => {
191- Sentry . addBreadcrumb ( { message : 'test breadcrumb 2' , timestamp : 123456 } ) ;
185+ Sentry . startSpan ( { op : 'test op' , name : 'test name' , source : 'task' , origin : 'auto.test' } , span => {
186+ Sentry . addBreadcrumb ( { message : 'test breadcrumb 2' , timestamp : 123456 } ) ;
192187
193- span . setAttributes ( {
194- 'test.outer' : 'test value' ,
195- } ) ;
188+ span . setAttributes ( {
189+ 'test.outer' : 'test value' ,
190+ } ) ;
196191
197- const subSpan = Sentry . startInactiveSpan ( { name : 'inner span 1' } ) ;
198- subSpan . end ( ) ;
192+ const subSpan = Sentry . startInactiveSpan ( { name : 'inner span 1' } ) ;
193+ subSpan . end ( ) ;
199194
200- Sentry . setTag ( 'test.tag' , 'test value' ) ;
195+ Sentry . setTag ( 'test.tag' , 'test value' ) ;
201196
202- Sentry . startSpan ( { name : 'inner span 2' } , innerSpan => {
203- Sentry . addBreadcrumb ( { message : 'test breadcrumb 3' , timestamp : 123456 } ) ;
197+ Sentry . startSpan ( { name : 'inner span 2' } , innerSpan => {
198+ Sentry . addBreadcrumb ( { message : 'test breadcrumb 3' , timestamp : 123456 } ) ;
204199
205- innerSpan . setAttributes ( {
206- 'test.inner' : 'test value' ,
207- } ) ;
200+ innerSpan . setAttributes ( {
201+ 'test.inner' : 'test value' ,
208202 } ) ;
209- } ,
210- ) ;
203+ } ) ;
204+ } ) ;
211205 } ) ;
212206
213207 Sentry . withIsolationScope ( ( ) => {
@@ -255,6 +249,8 @@ describe('Integration | Transactions', () => {
255249 'sentry.op' : 'test op' ,
256250 'sentry.origin' : 'auto.test' ,
257251 'sentry.source' : 'task' ,
252+ 'test.outer' : 'test value' ,
253+ 'sentry.sample_rate' : 1 ,
258254 } ,
259255 op : 'test op' ,
260256 span_id : expect . any ( String ) ,
@@ -265,7 +261,7 @@ describe('Integration | Transactions', () => {
265261 } ) ,
266262 spans : [ expect . any ( Object ) , expect . any ( Object ) ] ,
267263 start_timestamp : expect . any ( Number ) ,
268- tags : { 'test.tag' : 'test value' } ,
264+ tags : { 'test.tag' : 'test value' , transaction : 'test name' } ,
269265 timestamp : expect . any ( Number ) ,
270266 transaction : 'test name' ,
271267 transaction_info : { source : 'task' } ,
@@ -295,6 +291,8 @@ describe('Integration | Transactions', () => {
295291 'sentry.op' : 'test op b' ,
296292 'sentry.origin' : 'manual' ,
297293 'sentry.source' : 'custom' ,
294+ 'test.outer' : 'test value b' ,
295+ 'sentry.sample_rate' : 1 ,
298296 } ,
299297 op : 'test op b' ,
300298 span_id : expect . any ( String ) ,
@@ -305,7 +303,7 @@ describe('Integration | Transactions', () => {
305303 } ) ,
306304 spans : [ expect . any ( Object ) , expect . any ( Object ) ] ,
307305 start_timestamp : expect . any ( Number ) ,
308- tags : { 'test.tag' : 'test value b' } ,
306+ tags : { 'test.tag' : 'test value b' , transaction : 'test name b' } ,
309307 timestamp : expect . any ( Number ) ,
310308 transaction : 'test name b' ,
311309 transaction_info : { source : 'custom' } ,
@@ -322,7 +320,7 @@ describe('Integration | Transactions', () => {
322320
323321 mockSdkInit ( { enableTracing : true , beforeSendTransaction } ) ;
324322
325- const client = Sentry . getClient < NodeClient > ( ) ;
323+ const client = Sentry . getClient < Sentry . NodeClient > ( ) ;
326324
327325 Sentry . addBreadcrumb ( { message : 'test breadcrumb 1' , timestamp : 123456 } ) ;
328326
@@ -401,6 +399,8 @@ describe('Integration | Transactions', () => {
401399 'otel.kind' : 'INTERNAL' ,
402400 'sentry.origin' : 'manual' ,
403401 'sentry.source' : 'custom' ,
402+ 'test.outer' : 'test value' ,
403+ 'sentry.sample_rate' : 1 ,
404404 } ,
405405 span_id : expect . any ( String ) ,
406406 status : 'ok' ,
@@ -410,7 +410,7 @@ describe('Integration | Transactions', () => {
410410 } ) ,
411411 spans : [ expect . any ( Object ) , expect . any ( Object ) ] ,
412412 start_timestamp : expect . any ( Number ) ,
413- tags : { 'test.tag' : 'test value' } ,
413+ tags : { 'test.tag' : 'test value' , transaction : 'test name' } ,
414414 timestamp : expect . any ( Number ) ,
415415 transaction : 'test name' ,
416416 type : 'transaction' ,
@@ -438,6 +438,8 @@ describe('Integration | Transactions', () => {
438438 'otel.kind' : 'INTERNAL' ,
439439 'sentry.origin' : 'manual' ,
440440 'sentry.source' : 'custom' ,
441+ 'test.outer' : 'test value b' ,
442+ 'sentry.sample_rate' : 1 ,
441443 } ,
442444 span_id : expect . any ( String ) ,
443445 status : 'ok' ,
@@ -447,7 +449,7 @@ describe('Integration | Transactions', () => {
447449 } ) ,
448450 spans : [ expect . any ( Object ) , expect . any ( Object ) ] ,
449451 start_timestamp : expect . any ( Number ) ,
450- tags : { 'test.tag' : 'test value b' } ,
452+ tags : { 'test.tag' : 'test value b' , transaction : 'test name b' } ,
451453 timestamp : expect . any ( Number ) ,
452454 transaction : 'test name b' ,
453455 type : 'transaction' ,
@@ -481,7 +483,7 @@ describe('Integration | Transactions', () => {
481483
482484 mockSdkInit ( { enableTracing : true , beforeSendTransaction } ) ;
483485
484- const client = getClient ( ) as NodeClient ;
486+ const client = Sentry . getClient ( ) ! ;
485487
486488 // We simulate the correct context we'd normally get from the SentryPropagator
487489 context . with (
@@ -519,6 +521,7 @@ describe('Integration | Transactions', () => {
519521 'sentry.op' : 'test op' ,
520522 'sentry.origin' : 'auto.test' ,
521523 'sentry.source' : 'task' ,
524+ 'sentry.sample_rate' : 1 ,
522525 } ,
523526 op : 'test op' ,
524527 span_id : expect . any ( String ) ,
@@ -592,7 +595,7 @@ describe('Integration | Transactions', () => {
592595
593596 mockSdkInit ( { enableTracing : true , beforeSendTransaction } ) ;
594597
595- const client = getClient ( ) as NodeClient ;
598+ const client = Sentry . getClient ( ) ! ;
596599 const provider = getProvider ( ) ;
597600 const multiSpanProcessor = provider ?. activeSpanProcessor as
598601 | ( SpanProcessor & { _spanProcessors ?: SpanProcessor [ ] } )
0 commit comments