Skip to content

Commit 66a8a37

Browse files
committed
fix: SpanMatchCriteria takes in scopeKeys, not scope
1 parent b5db390 commit 66a8a37

File tree

4 files changed

+147
-100
lines changed

4 files changed

+147
-100
lines changed

src/v3/ActiveTrace.ts

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,13 @@ export class TraceStateMachine<ScopeT extends ScopeBase> {
149149
// does span satisfy any of the "interruptOn" definitions
150150
if (this.context.definition.interruptOn) {
151151
for (const definition of this.context.definition.interruptOn) {
152-
if (doesEntryMatchDefinition(spanAndAnnotation, definition)) {
152+
if (
153+
doesEntryMatchDefinition(
154+
spanAndAnnotation,
155+
definition,
156+
this.context.input.scope,
157+
)
158+
) {
153159
return {
154160
transitionToState: 'interrupted',
155161
interruptionReason: 'matched-on-interrupt',
@@ -160,7 +166,13 @@ export class TraceStateMachine<ScopeT extends ScopeBase> {
160166

161167
for (let i = 0; i < this.context.definition.requiredToEnd.length; i++) {
162168
const definition = this.context.definition.requiredToEnd[i]!
163-
if (doesEntryMatchDefinition(spanAndAnnotation, definition)) {
169+
if (
170+
doesEntryMatchDefinition(
171+
spanAndAnnotation,
172+
definition,
173+
this.context.input.scope,
174+
)
175+
) {
164176
// remove the index of this definition from the list of requiredToEnd
165177
this.context.requiredToEndIndexChecklist.delete(i)
166178

@@ -236,7 +248,11 @@ export class TraceStateMachine<ScopeT extends ScopeBase> {
236248
for (const definition of this.context.definition.requiredToEnd) {
237249
const { span } = spanAndAnnotation
238250
if (
239-
doesEntryMatchDefinition(spanAndAnnotation, definition) &&
251+
doesEntryMatchDefinition(
252+
spanAndAnnotation,
253+
definition,
254+
this.context.input.scope,
255+
) &&
240256
definition.isIdle &&
241257
'isIdle' in span &&
242258
span.isIdle
@@ -252,7 +268,13 @@ export class TraceStateMachine<ScopeT extends ScopeBase> {
252268
// does span satisfy any of the "debouncedOn" and if so, restart our debounce timer
253269
if (this.context.definition.debounceOn) {
254270
for (const definition of this.context.definition.debounceOn) {
255-
if (doesEntryMatchDefinition(spanAndAnnotation, definition)) {
271+
if (
272+
doesEntryMatchDefinition(
273+
spanAndAnnotation,
274+
definition,
275+
this.context.input.scope,
276+
)
277+
) {
256278
// Sometimes spans are processed out of order, we update the lastRelevant if this span ends later
257279
if (
258280
spanAndAnnotation.annotation.operationRelativeEndTime >
@@ -367,7 +389,13 @@ export class TraceStateMachine<ScopeT extends ScopeBase> {
367389
// transition to complete state with the 'matched-on-interrupt' interruptionReason
368390
if (this.context.definition.interruptOn) {
369391
for (const definition of this.context.definition.interruptOn) {
370-
if (doesEntryMatchDefinition(spanAndAnnotation, definition)) {
392+
if (
393+
doesEntryMatchDefinition(
394+
spanAndAnnotation,
395+
definition,
396+
this.context.input.scope,
397+
)
398+
) {
371399
return {
372400
transitionToState: 'complete',
373401
interruptionReason: 'matched-on-interrupt',
@@ -570,7 +598,11 @@ export class ActiveTrace<ScopeT extends ScopeBase> {
570598
const matchingRecordedEntries = this.recordedItems.filter(
571599
(spanAndAnnotation) =>
572600
matches.some((matchCriteria) =>
573-
doesEntryMatchDefinition(spanAndAnnotation, matchCriteria),
601+
doesEntryMatchDefinition(
602+
spanAndAnnotation,
603+
matchCriteria,
604+
this.input.scope,
605+
),
574606
),
575607
)
576608

@@ -588,10 +620,14 @@ export class ActiveTrace<ScopeT extends ScopeBase> {
588620
this.definition.computedSpanDefinitions.forEach((definition) => {
589621
const { startSpan, endSpan, name } = definition
590622
const matchingStartEntry = this.recordedItems.find((spanAndAnnotation) =>
591-
doesEntryMatchDefinition(spanAndAnnotation, startSpan),
623+
doesEntryMatchDefinition(
624+
spanAndAnnotation,
625+
startSpan,
626+
this.input.scope,
627+
),
592628
)
593629
const matchingEndEntry = this.recordedItems.find((spanAndAnnotation) =>
594-
doesEntryMatchDefinition(spanAndAnnotation, endSpan),
630+
doesEntryMatchDefinition(spanAndAnnotation, endSpan, this.input.scope),
595631
)
596632

597633
if (matchingStartEntry && matchingEndEntry) {

0 commit comments

Comments
 (0)