This repository was archived by the owner on Nov 10, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +18
-10
lines changed Expand file tree Collapse file tree 5 files changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import {
21
21
registerGlobal ,
22
22
unregisterGlobal ,
23
23
} from '../internal/global-utils' ;
24
+ import { DiagAPI } from './diag' ;
24
25
25
26
const API_NAME = 'context' ;
26
27
const NOOP_CONTEXT_MANAGER = new NoopContextManager ( ) ;
@@ -49,7 +50,7 @@ export class ContextAPI {
49
50
* @returns true if the context manager was successfully registered, else false
50
51
*/
51
52
public setGlobalContextManager ( contextManager : ContextManager ) : boolean {
52
- return registerGlobal ( API_NAME , contextManager ) ;
53
+ return registerGlobal ( API_NAME , contextManager , DiagAPI . instance ( ) ) ;
53
54
}
54
55
55
56
/**
@@ -93,6 +94,6 @@ export class ContextAPI {
93
94
/** Disable and remove the global context manager */
94
95
public disable ( ) {
95
96
this . _getContextManager ( ) . disable ( ) ;
96
- unregisterGlobal ( API_NAME ) ;
97
+ unregisterGlobal ( API_NAME , DiagAPI . instance ( ) ) ;
97
98
}
98
99
}
Original file line number Diff line number Diff line change @@ -96,11 +96,11 @@ export class DiagAPI implements DiagLogger {
96
96
) ;
97
97
}
98
98
99
- return registerGlobal ( 'diag' , newLogger , true ) ;
99
+ return registerGlobal ( 'diag' , newLogger , self , true ) ;
100
100
} ;
101
101
102
102
self . disable = ( ) => {
103
- unregisterGlobal ( API_NAME ) ;
103
+ unregisterGlobal ( API_NAME , self ) ;
104
104
} ;
105
105
106
106
self . createComponentLogger = ( options : ComponentLoggerOptions ) => {
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ import {
34
34
deleteBaggage ,
35
35
} from '../baggage/context-helpers' ;
36
36
import { createBaggage } from '../baggage/utils' ;
37
+ import { DiagAPI } from './diag' ;
37
38
38
39
const API_NAME = 'propagation' ;
39
40
const NOOP_TEXT_MAP_PROPAGATOR = new NoopTextMapPropagator ( ) ;
@@ -62,7 +63,7 @@ export class PropagationAPI {
62
63
* @returns true if the propagator was successfully registered, else false
63
64
*/
64
65
public setGlobalPropagator ( propagator : TextMapPropagator ) : boolean {
65
- return registerGlobal ( API_NAME , propagator ) ;
66
+ return registerGlobal ( API_NAME , propagator , DiagAPI . instance ( ) ) ;
66
67
}
67
68
68
69
/**
@@ -104,7 +105,7 @@ export class PropagationAPI {
104
105
105
106
/** Remove the global propagator */
106
107
public disable ( ) {
107
- unregisterGlobal ( API_NAME ) ;
108
+ unregisterGlobal ( API_NAME , DiagAPI . instance ( ) ) ;
108
109
}
109
110
110
111
public createBaggage = createBaggage ;
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ import {
33
33
setSpan ,
34
34
setSpanContext ,
35
35
} from '../trace/context-utils' ;
36
+ import { DiagAPI } from './diag' ;
36
37
37
38
const API_NAME = 'trace' ;
38
39
@@ -63,7 +64,11 @@ export class TraceAPI {
63
64
*/
64
65
public setGlobalTracerProvider ( provider : TracerProvider ) : boolean {
65
66
this . _proxyTracerProvider . setDelegate ( provider ) ;
66
- return registerGlobal ( API_NAME , this . _proxyTracerProvider ) ;
67
+ return registerGlobal (
68
+ API_NAME ,
69
+ this . _proxyTracerProvider ,
70
+ DiagAPI . instance ( )
71
+ ) ;
67
72
}
68
73
69
74
/**
@@ -82,7 +87,7 @@ export class TraceAPI {
82
87
83
88
/** Remove the global tracer provider */
84
89
public disable ( ) {
85
- unregisterGlobal ( API_NAME ) ;
90
+ unregisterGlobal ( API_NAME , DiagAPI . instance ( ) ) ;
86
91
this . _proxyTracerProvider = new ProxyTracerProvider ( ) ;
87
92
}
88
93
Original file line number Diff line number Diff line change 14
14
* limitations under the License.
15
15
*/
16
16
17
- import { diag } from '..' ;
17
+ import type { DiagAPI } from '../api/diag ' ;
18
18
import { ContextManager } from '../context/types' ;
19
19
import { DiagLogger } from '../diag' ;
20
20
import { _globalThis } from '../platform' ;
@@ -33,6 +33,7 @@ const _global = _globalThis as OTelGlobal;
33
33
export function registerGlobal < Type extends keyof OTelGlobalAPI > (
34
34
type : Type ,
35
35
instance : OTelGlobalAPI [ Type ] ,
36
+ diag : DiagAPI ,
36
37
allowOverride = false
37
38
) : boolean {
38
39
const api = ( _global [ GLOBAL_OPENTELEMETRY_API_KEY ] = _global [
@@ -77,7 +78,7 @@ export function getGlobal<Type extends keyof OTelGlobalAPI>(
77
78
return _global [ GLOBAL_OPENTELEMETRY_API_KEY ] ?. [ type ] ;
78
79
}
79
80
80
- export function unregisterGlobal ( type : keyof OTelGlobalAPI ) {
81
+ export function unregisterGlobal ( type : keyof OTelGlobalAPI , diag : DiagAPI ) {
81
82
diag . debug (
82
83
`@opentelemetry/api: Unregistering a global for ${ type } v${ VERSION } .`
83
84
) ;
You can’t perform that action at this time.
0 commit comments