File tree 4 files changed +30
-10
lines changed
4 files changed +30
-10
lines changed Original file line number Diff line number Diff line change @@ -1173,7 +1173,7 @@ export class Trace<
1173
1173
onEnd (
1174
1174
traceRecording : TraceRecording < SelectedRelationNameT , RelationSchemasT > ,
1175
1175
) : void {
1176
- this . traceUtilities . cleanupCurrentTrace ( this )
1176
+ this . traceUtilities . onEndTrace ( this )
1177
1177
this . traceUtilities . reportFn ( traceRecording , this )
1178
1178
}
1179
1179
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import type { Span } from './spanTypes'
9
9
import type { AllPossibleTraces } from './Trace'
10
10
import { Tracer } from './Tracer'
11
11
import type {
12
+ AllPossibleTraceContexts ,
12
13
CompleteTraceDefinition ,
13
14
ComputedValueDefinitionInput ,
14
15
RelationSchemasBase ,
@@ -28,12 +29,11 @@ export class TraceManager<
28
29
private currentTrace : AllPossibleTraces < RelationSchemasT > | undefined =
29
30
undefined
30
31
31
- get currentTracerContext ( ) {
32
+ get currentTracerContext ( ) :
33
+ | AllPossibleTraceContexts < RelationSchemasT , string >
34
+ | undefined {
32
35
if ( ! this . currentTrace ) return undefined
33
- return {
34
- definition : this . currentTrace . definition ,
35
- input : this . currentTrace . input ,
36
- }
36
+ return this . currentTrace
37
37
}
38
38
39
39
constructor (
@@ -52,7 +52,7 @@ export class TraceManager<
52
52
}
53
53
this . currentTrace = newTrace
54
54
} ,
55
- cleanupCurrentTrace : ( traceToCleanUp ) => {
55
+ onEndTrace : ( traceToCleanUp ) => {
56
56
if ( traceToCleanUp === this . currentTrace ) {
57
57
this . currentTrace = undefined
58
58
}
Original file line number Diff line number Diff line change 8
8
type CompleteTraceDefinition ,
9
9
type ComputedSpanDefinitionInput ,
10
10
type ComputedValueDefinitionInput ,
11
+ type DraftTraceContext ,
11
12
type RelationSchemasBase ,
12
13
type TraceDefinitionModifications ,
13
14
type TraceManagerUtilities ,
@@ -219,6 +220,16 @@ export class Tracer<
219
220
trace . transitionDraftToActive ( inputAndDefinitionModifications )
220
221
}
221
222
223
+ getCurrentTrace = ( ) :
224
+ | DraftTraceContext < SelectedRelationNameT , RelationSchemasT , VariantsT >
225
+ | undefined => {
226
+ const trace = this . traceUtilities . getCurrentTrace ( )
227
+ if ( ! trace || trace . sourceDefinition !== this . definition ) {
228
+ return undefined
229
+ }
230
+ return trace
231
+ }
232
+
222
233
defineComputedSpan = (
223
234
definition : ComputedSpanDefinitionInput <
224
235
SelectedRelationNameT ,
Original file line number Diff line number Diff line change @@ -171,9 +171,7 @@ export interface TraceManagerUtilities<
171
171
newTrace : AllPossibleTraces < RelationSchemasT > ,
172
172
reason : TraceReplaceInterruptionReason ,
173
173
) => void
174
- cleanupCurrentTrace : (
175
- traceToCleanUp : AllPossibleTraces < RelationSchemasT > ,
176
- ) => void
174
+ onEndTrace : ( traceToCleanUp : AllPossibleTraces < RelationSchemasT > ) => void
177
175
getCurrentTrace : ( ) => AllPossibleTraces < RelationSchemasT > | undefined
178
176
}
179
177
@@ -574,6 +572,17 @@ export interface DraftTraceContext<
574
572
>
575
573
}
576
574
575
+ export type AllPossibleTraceContexts <
576
+ RelationSchemasT ,
577
+ VariantsT extends string ,
578
+ > = {
579
+ [ SelectedRelationNameT in keyof RelationSchemasT ] : DraftTraceContext <
580
+ SelectedRelationNameT ,
581
+ RelationSchemasT ,
582
+ VariantsT
583
+ >
584
+ } [ keyof RelationSchemasT ]
585
+
577
586
export interface TraceContext <
578
587
SelectedRelationNameT extends keyof RelationSchemasT ,
579
588
RelationSchemasT ,
You can’t perform that action at this time.
0 commit comments