11import * as api from '@opentelemetry/api' ;
2- import { Span , SpanStatusCode } from '@opentelemetry/api' ;
3- import { InstrumentationBase } from '@opentelemetry/instrumentation' ;
4- import type { InstrumentationConfig } from '@opentelemetry/instrumentation' ;
5- import type { SagaMonitor } from 'redux-saga' ;
6- import type { PutEffect } from 'redux-saga/effects' ;
7-
2+ import { type Span , SpanStatusCode } from '@opentelemetry/api' ;
3+ import { InstrumentationBase } from '@opentelemetry/instrumentation' ;
4+ import type { InstrumentationConfig } from '@opentelemetry/instrumentation' ;
5+ import type { SagaMonitor } from 'redux-saga' ;
6+ import type { PutEffect } from 'redux-saga/effects' ;
87
98export interface ReduxSagaInstrumentationConfig extends InstrumentationConfig {
109 // Add any custom config fields you'd like here.
1110 // For example, you might ignore certain effect types, or customize naming, etc.
1211 shouldPropagateTraceContextPut ?: ( effect : PutEffect ) => boolean ;
13- propagateContextToCall ?: boolean
12+ propagateContextToCall ?: boolean ;
1413}
1514
1615/**
@@ -45,11 +44,11 @@ export class ReduxSagaInstrumentation extends InstrumentationBase<ReduxSagaInstr
4544 const parentContext = api . propagation . extract ( api . context . active ( ) , payload ) ;
4645 const spanName = instrumentation . _getEffectName ( effect ) ;
4746 const span = instrumentation . tracer . startSpan (
48- spanName ,
49- {
50- kind : api . SpanKind . CLIENT
51- } ,
52- parentContext
47+ spanName ,
48+ {
49+ kind : api . SpanKind . CLIENT ,
50+ } ,
51+ parentContext
5352 ) ;
5453 instrumentation . _spans . set ( effectId , span ) ;
5554
@@ -65,9 +64,9 @@ export class ReduxSagaInstrumentation extends InstrumentationBase<ReduxSagaInstr
6564
6665 // Use the parent span's context to create a child span
6766 const childSpan = instrumentation . tracer . startSpan (
68- spanName ,
69- { kind : api . SpanKind . CLIENT } ,
70- api . trace . setSpan ( api . context . active ( ) , parentSpan )
67+ spanName ,
68+ { kind : api . SpanKind . CLIENT } ,
69+ api . trace . setSpan ( api . context . active ( ) , parentSpan )
7170 ) ;
7271
7372 if ( effect . type === 'PUT' && instrumentation . _config . shouldPropagateTraceContextPut ?.( effect ) ) {
@@ -82,14 +81,11 @@ export class ReduxSagaInstrumentation extends InstrumentationBase<ReduxSagaInstr
8281 }
8382
8483 instrumentation . _spans . set ( effectId , childSpan ) ;
85- } else if ( traceable ) {
84+ } else if ( traceable ) {
8685 const spanName = instrumentation . _getEffectName ( effect ) ;
87- const span = instrumentation . tracer . startSpan (
88- spanName ,
89- {
90- kind : api . SpanKind . CLIENT
91- }
92- ) ;
86+ const span = instrumentation . tracer . startSpan ( spanName , {
87+ kind : api . SpanKind . CLIENT ,
88+ } ) ;
9389 instrumentation . _spans . set ( effectId , span ) ;
9490 }
9591 } catch ( e ) {
@@ -101,7 +97,9 @@ export class ReduxSagaInstrumentation extends InstrumentationBase<ReduxSagaInstr
10197 try {
10298 // Called when an effect has completed successfully
10399 const span = instrumentation . _spans . get ( effectId ) ;
104- if ( ! span ) { return ; }
100+ if ( ! span ) {
101+ return ;
102+ }
105103
106104 if ( result ?. toPromise ) {
107105 result . toPromise ( ) . then ( ( res : any ) => {
@@ -125,7 +123,9 @@ export class ReduxSagaInstrumentation extends InstrumentationBase<ReduxSagaInstr
125123 try {
126124 // Called when an effect has failed
127125 const span = instrumentation . _spans . get ( effectId ) ;
128- if ( ! span ) { return ; }
126+ if ( ! span ) {
127+ return ;
128+ }
129129
130130 span . setStatus ( { code : SpanStatusCode . ERROR , message : error ?. message } ) ;
131131 span . recordException ( error ) ;
@@ -140,7 +140,9 @@ export class ReduxSagaInstrumentation extends InstrumentationBase<ReduxSagaInstr
140140 try {
141141 // Called when an effect has been cancelled
142142 const span = instrumentation . _spans . get ( effectId ) ;
143- if ( ! span ) { return ; }
143+ if ( ! span ) {
144+ return ;
145+ }
144146
145147 // You might mark it as a cancellation, or success, or custom
146148 span . setAttribute ( 'redux-saga.cancelled' , true ) ;
0 commit comments