4
4
*/
5
5
6
6
'use strict'
7
- const { otelSynthesis } = require ( '../symbols' )
8
- const FakeSpan = require ( '../otel/fake-span' )
9
7
10
8
module . exports = class Context {
11
- constructor ( transaction , segment , parentContext ) {
9
+ constructor ( transaction , segment ) {
12
10
this . _transaction = transaction
13
11
this . _segment = segment
14
- this . _otelCtx = parentContext ? new Map ( parentContext ) : new Map ( )
15
12
}
16
13
17
14
get segment ( ) {
@@ -26,83 +23,23 @@ module.exports = class Context {
26
23
* Constructs a new context from segment about to be bound to context manager
27
24
* along with the current transaction.
28
25
*
29
- * If agent is in otel bridge mode it will also bind a FakeSpan to the otel ctx.
30
- *
31
26
* @param {object } params to function
32
27
* @param {TraceSegment } params.segment segment to bind to context
33
28
* @param {Transaction } params.transaction active transaction
34
29
* @returns {Context } a newly constructed context
35
30
*/
36
31
enterSegment ( { segment, transaction = this . _transaction } ) {
37
- if ( transaction ?. agent ?. otelSpanKey ) {
38
- this . _otelCtx . set ( transaction . agent . otelSpanKey , new FakeSpan ( segment , transaction ) )
39
- }
40
32
return new this . constructor ( transaction , segment , this . _otelCtx )
41
33
}
42
34
43
35
/**
44
36
* Constructs a new context from transaction about to be bound to context manager.
45
37
* It uses the trace root segment as the segment in context.
46
38
*
47
- * If agent is in otel bridge mode it will also bind a FakeSpan to the otel ctx.
48
- *
49
- * @param {object } params to function
50
- * @param {TraceSegment } params.segment transaction trace root segment
51
- * @param {Transaction } params.transaction transaction to bind to context
52
- * @param transaction
39
+ * @param {Transaction } transaction transaction to bind to context
53
40
* @returns {Context } a newly constructed context
54
41
*/
55
42
enterTransaction ( transaction ) {
56
- if ( transaction ?. agent ?. otelSpanKey ) {
57
- this . _otelCtx . set ( transaction . agent . otelSpanKey , new FakeSpan ( transaction . trace . root , transaction ) )
58
- }
59
- return new this . constructor ( transaction , transaction . trace . root , this . _otelCtx )
60
- }
61
-
62
- /**
63
- * Required for bridging OTEL data into the agent.
64
- *
65
- * @param {string } key Stored entity name to retrieve.
66
- *
67
- * @returns {* } The stored value.
68
- */
69
- getValue ( key ) {
70
- return this . _otelCtx . get ( key )
71
- }
72
-
73
- /**
74
- * Required for bridging OTEL data into the agent.
75
- *
76
- * @param {string } key Name for stored value.
77
- * @param {* } value Value to store.
78
- *
79
- * @returns {object } The context manager object.
80
- */
81
- setValue ( key , value ) {
82
- let ctx
83
-
84
- if ( value [ otelSynthesis ] && value [ otelSynthesis ] . segment && value [ otelSynthesis ] . transaction ) {
85
- const { segment, transaction } = value [ otelSynthesis ]
86
- segment . start ( )
87
- ctx = new this . constructor ( transaction , segment , this . _otelCtx )
88
- } else {
89
- ctx = new this . constructor ( this . _transaction , this . _segment , this . _otelCtx )
90
- }
91
-
92
- ctx . _otelCtx . set ( key , value )
93
- return ctx
94
- }
95
-
96
- /**
97
- * Required for bridging OTEL data into the agent.
98
- *
99
- * @param {string } key Named value to remove from the store.
100
- *
101
- * @returns {object } The context manager object.
102
- */
103
- deleteValue ( key ) {
104
- const ctx = new this . constructor ( this . _transaction , this . _segment , this . _otelCtx )
105
- ctx . _otelCtx . delete ( key )
106
- return ctx
43
+ return new this . constructor ( transaction , transaction . trace . root )
107
44
}
108
45
}
0 commit comments