@@ -18,11 +18,9 @@ import { Context, createContextKey } from '@opentelemetry/context-base';
18
18
import { Baggage , NoopSpan , Span , SpanContext } from '../' ;
19
19
20
20
/**
21
- * Active span key
21
+ * span key
22
22
*/
23
- const ACTIVE_SPAN_KEY = createContextKey (
24
- 'OpenTelemetry Context Key ACTIVE_SPAN'
25
- ) ;
23
+ const SPAN_KEY = createContextKey ( 'OpenTelemetry Context Key SPAN' ) ;
26
24
27
25
/**
28
26
* Shared key for indicating if instrumentation should be suppressed beyond
@@ -38,49 +36,45 @@ const SUPPRESS_INSTRUMENTATION_KEY = createContextKey(
38
36
const BAGGAGE_KEY = createContextKey ( 'OpenTelemetry Baggage Key' ) ;
39
37
40
38
/**
41
- * Return the active span if one exists
39
+ * Return the span if one exists
42
40
*
43
41
* @param context context to get span from
44
42
*/
45
- export function getActiveSpan ( context : Context ) : Span | undefined {
46
- return ( context . getValue ( ACTIVE_SPAN_KEY ) as Span ) || undefined ;
43
+ export function getSpan ( context : Context ) : Span | undefined {
44
+ return ( context . getValue ( SPAN_KEY ) as Span ) || undefined ;
47
45
}
48
46
49
47
/**
50
- * Set the active span on a context
48
+ * Set the span on a context
51
49
*
52
50
* @param context context to use as parent
53
51
* @param span span to set active
54
52
*/
55
- export function setActiveSpan ( context : Context , span : Span ) : Context {
56
- return context . setValue ( ACTIVE_SPAN_KEY , span ) ;
53
+ export function setSpan ( context : Context , span : Span ) : Context {
54
+ return context . setValue ( SPAN_KEY , span ) ;
57
55
}
58
56
59
57
/**
60
- * Wrap extracted span context in a NoopSpan and set as active span in a new
58
+ * Wrap span context in a NoopSpan and set as span in a new
61
59
* context
62
60
*
63
61
* @param context context to set active span on
64
62
* @param spanContext span context to be wrapped
65
63
*/
66
- export function setExtractedSpanContext (
64
+ export function setSpanContext (
67
65
context : Context ,
68
66
spanContext : SpanContext
69
67
) : Context {
70
- return setActiveSpan ( context , new NoopSpan ( spanContext ) ) ;
68
+ return setSpan ( context , new NoopSpan ( spanContext ) ) ;
71
69
}
72
70
73
71
/**
74
- * Get the span context of the parent span if it exists,
75
- * or the extracted span context if there is no active
76
- * span.
72
+ * Get the span context of the span if it exists.
77
73
*
78
74
* @param context context to get values from
79
75
*/
80
- export function getParentSpanContext (
81
- context : Context
82
- ) : SpanContext | undefined {
83
- return getActiveSpan ( context ) ?. context ( ) ;
76
+ export function getSpanContext ( context : Context ) : SpanContext | undefined {
77
+ return getSpan ( context ) ?. context ( ) ;
84
78
}
85
79
86
80
/**
0 commit comments