@@ -49,41 +49,47 @@ export class NoopTracer implements Tracer {
49
49
50
50
startActiveSpan < F extends ( span : Span ) => ReturnType < F > > (
51
51
name : string ,
52
- arg2 : F | SpanOptions ,
52
+ fn : F
53
+ ) : ReturnType < F > ;
54
+ startActiveSpan < F extends ( span : Span ) => ReturnType < F > > (
55
+ name : string ,
56
+ opts : SpanOptions | undefined ,
57
+ fn : F
58
+ ) : ReturnType < F > ;
59
+ startActiveSpan < F extends ( span : Span ) => ReturnType < F > > (
60
+ name : string ,
61
+ opts : SpanOptions | undefined ,
62
+ ctx : Context | undefined ,
63
+ fn : F
64
+ ) : ReturnType < F > ;
65
+ startActiveSpan < F extends ( span : Span ) => ReturnType < F > > (
66
+ name : string ,
67
+ arg2 ?: F | SpanOptions ,
53
68
arg3 ?: F | Context ,
54
69
arg4 ?: F
55
70
) : ReturnType < F > | undefined {
56
- let fn : F | undefined ,
57
- options : SpanOptions | undefined ,
58
- activeContext : Context | undefined ;
59
- if ( arguments . length === 2 && typeof arg2 === 'function' ) {
60
- fn = arg2 ;
61
- } else if (
62
- arguments . length === 3 &&
63
- typeof arg2 === 'object' &&
64
- typeof arg3 === 'function'
65
- ) {
66
- options = arg2 ;
67
- fn = arg3 ;
68
- } else if (
69
- arguments . length === 4 &&
70
- typeof arg2 === 'object' &&
71
- typeof arg3 === 'object' &&
72
- typeof arg4 === 'function'
73
- ) {
74
- options = arg2 ;
75
- activeContext = arg3 ;
76
- fn = arg4 ;
71
+ let opts : SpanOptions | undefined ;
72
+ let ctx : Context | undefined ;
73
+ let fn : F ;
74
+
75
+ if ( arguments . length < 2 ) {
76
+ return ;
77
+ } else if ( arguments . length === 2 ) {
78
+ fn = arg2 as F ;
79
+ } else if ( arguments . length === 3 ) {
80
+ opts = arg2 as SpanOptions | undefined ;
81
+ fn = arg3 as F ;
82
+ } else {
83
+ opts = arg2 as SpanOptions | undefined ;
84
+ ctx = arg3 as Context | undefined ;
85
+ fn = arg4 as F ;
77
86
}
78
87
79
- const parentContext = activeContext ?? context . active ( ) ;
80
- const span = this . startSpan ( name , options , parentContext ) ;
88
+ const parentContext = ctx ?? context . active ( ) ;
89
+ const span = this . startSpan ( name , opts , parentContext ) ;
81
90
const contextWithSpanSet = setSpan ( parentContext , span ) ;
82
91
83
- if ( fn ) {
84
- return context . with ( contextWithSpanSet , fn , undefined , span ) ;
85
- }
86
- return ;
92
+ return context . with ( contextWithSpanSet , fn , undefined , span ) ;
87
93
}
88
94
}
89
95
0 commit comments