Skip to content

Commit f2b5d52

Browse files
xnanodaxniieani
authored andcommitted
fix: update rename from entry to span for util file + test file
1 parent 13ed846 commit f2b5d52

File tree

2 files changed

+32
-32
lines changed

2 files changed

+32
-32
lines changed

src/v3/doesEntryMatchDefinition.test.ts

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { doesEntryMatchDefinition } from './doesEntryMatchDefinition'
2-
import type { ScopeBase, SpanAnnotation } from './types'
32
import type {
43
ComponentRenderSpan,
54
Span,
65
SpanBase,
76
SpanMatcher,
87
} from './spanTypes'
8+
import type { ScopeBase, SpanAnnotation } from './types'
99

1010
// Mock data for TraceEntryBase
1111
interface TestScopeT extends ScopeBase {
@@ -62,7 +62,7 @@ describe('doesEntryMatchDefinition', () => {
6262
it('should return true for a matching entry based on name', () => {
6363
const matcher: SpanMatcher<TestScopeT> = { name: 'testEntry' }
6464
const mockEntryAndAnnotation = {
65-
entry: mockEntryBase,
65+
span: mockEntryBase,
6666
annotation: mockAnnotation,
6767
}
6868
expect(doesEntryMatchDefinition(mockEntryAndAnnotation, matcher)).toBe(
@@ -75,7 +75,7 @@ describe('doesEntryMatchDefinition', () => {
7575
name: (name: string) => name.startsWith('test'),
7676
}
7777
const mockEntryAndAnnotation = {
78-
entry: mockEntryBase,
78+
span: mockEntryBase,
7979
annotation: mockAnnotation,
8080
}
8181
expect(doesEntryMatchDefinition(mockEntryAndAnnotation, matcher)).toBe(
@@ -88,20 +88,20 @@ describe('doesEntryMatchDefinition', () => {
8888
name: /^test/,
8989
}
9090
const mockEntryAndAnnotation = {
91-
entry: mockEntryBase,
91+
span: mockEntryBase,
9292
annotation: mockAnnotation,
9393
}
9494
expect(doesEntryMatchDefinition(mockEntryAndAnnotation, matcher)).toBe(
9595
true,
9696
)
9797
})
9898

99-
it('should return false for a non-matching entry based on name', () => {
99+
it('should return false for a non-matching span based on name', () => {
100100
const matcher: SpanMatcher<TestScopeT> = {
101101
name: 'nonMatchingEntry',
102102
}
103103
const mockEntryAndAnnotation = {
104-
entry: mockEntryBase,
104+
span: mockEntryBase,
105105
annotation: mockAnnotation,
106106
}
107107
expect(doesEntryMatchDefinition(mockEntryAndAnnotation, matcher)).toBe(
@@ -111,12 +111,12 @@ describe('doesEntryMatchDefinition', () => {
111111
})
112112

113113
describe('performanceEntryName', () => {
114-
it('should return true for a matching entry based on performanceEntryName', () => {
114+
it('should return true for a matching span based on performanceEntryName', () => {
115115
const matcher: SpanMatcher<TestScopeT> = {
116116
performanceEntryName: 'testEntry',
117117
}
118118
const mockEntryAndAnnotation = {
119-
entry: mockPerformanceEntry,
119+
span: mockPerformanceEntry,
120120
annotation: mockAnnotation,
121121
}
122122
expect(doesEntryMatchDefinition(mockEntryAndAnnotation, matcher)).toBe(
@@ -129,7 +129,7 @@ describe('doesEntryMatchDefinition', () => {
129129
performanceEntryName: 'nonMatchingEntry',
130130
}
131131
const mockEntryAndAnnotation = {
132-
entry: mockPerformanceEntry,
132+
span: mockPerformanceEntry,
133133
annotation: mockAnnotation,
134134
}
135135
expect(doesEntryMatchDefinition(mockEntryAndAnnotation, matcher)).toBe(
@@ -143,7 +143,7 @@ describe('doesEntryMatchDefinition', () => {
143143
it('should return true for matching attributes', () => {
144144
const matcher: SpanMatcher<TestScopeT> = { type: 'element' }
145145
const mockEntryAndAnnotation = {
146-
entry: mockEntryBase,
146+
span: mockEntryBase,
147147
annotation: mockAnnotation,
148148
}
149149
expect(doesEntryMatchDefinition(mockEntryAndAnnotation, matcher)).toBe(
@@ -156,7 +156,7 @@ describe('doesEntryMatchDefinition', () => {
156156
type: 'component-render',
157157
}
158158
const mockEntryAndAnnotation = {
159-
entry: mockEntryBase,
159+
span: mockEntryBase,
160160
annotation: mockAnnotation,
161161
}
162162
expect(doesEntryMatchDefinition(mockEntryAndAnnotation, matcher)).toBe(
@@ -172,7 +172,7 @@ describe('doesEntryMatchDefinition', () => {
172172
name: 'testEntry',
173173
}
174174
const mockEntryAndAnnotation = {
175-
entry: mockComponentEntry,
175+
span: mockComponentEntry,
176176
annotation: mockAnnotation,
177177
}
178178
expect(doesEntryMatchDefinition(mockEntryAndAnnotation, matcher)).toBe(
@@ -186,7 +186,7 @@ describe('doesEntryMatchDefinition', () => {
186186
name: 'nonMatchingEntry',
187187
}
188188
const mockEntryAndAnnotation = {
189-
entry: mockComponentEntry,
189+
span: mockComponentEntry,
190190
annotation: mockAnnotation,
191191
}
192192
expect(doesEntryMatchDefinition(mockEntryAndAnnotation, matcher)).toBe(
@@ -200,7 +200,7 @@ describe('doesEntryMatchDefinition', () => {
200200
it('should return true when status does match', () => {
201201
const matcher: SpanMatcher<TestScopeT> = { status: 'ok' }
202202
const mockEntryAndAnnotation = {
203-
entry: mockEntryBase,
203+
span: mockEntryBase,
204204
annotation: mockAnnotation,
205205
}
206206
expect(doesEntryMatchDefinition(mockEntryAndAnnotation, matcher)).toBe(
@@ -211,7 +211,7 @@ describe('doesEntryMatchDefinition', () => {
211211
it('should return false when status does not match', () => {
212212
const matcher: SpanMatcher<TestScopeT> = { status: 'error' }
213213
const mockEntryAndAnnotation = {
214-
entry: mockEntryBase,
214+
span: mockEntryBase,
215215
annotation: mockAnnotation,
216216
}
217217
expect(doesEntryMatchDefinition(mockEntryAndAnnotation, matcher)).toBe(
@@ -228,7 +228,7 @@ describe('doesEntryMatchDefinition', () => {
228228
occurrence: 1,
229229
}
230230
const mockEntryAndAnnotation = {
231-
entry: mockEntryBase,
231+
span: mockEntryBase,
232232
annotation: mockAnnotation,
233233
}
234234
// Assuming occurrence logic is implemented in the function
@@ -243,7 +243,7 @@ describe('doesEntryMatchDefinition', () => {
243243
occurrence: 2,
244244
}
245245
const mockEntryAndAnnotation = {
246-
entry: mockEntryBase,
246+
span: mockEntryBase,
247247
annotation: mockAnnotation,
248248
}
249249
// Assuming occurrence logic is implemented in the function
@@ -259,7 +259,7 @@ describe('doesEntryMatchDefinition', () => {
259259
attributes: { attr1: 'value1' },
260260
}
261261
const mockEntryAndAnnotation = {
262-
entry: mockEntryBase,
262+
span: mockEntryBase,
263263
annotation: mockAnnotation,
264264
}
265265
expect(doesEntryMatchDefinition(mockEntryAndAnnotation, matcher)).toBe(
@@ -272,7 +272,7 @@ describe('doesEntryMatchDefinition', () => {
272272
attributes: { attr1: 'wrongValue' },
273273
}
274274
const mockEntryAndAnnotation = {
275-
entry: mockEntryBase,
275+
span: mockEntryBase,
276276
annotation: mockAnnotation,
277277
}
278278
expect(doesEntryMatchDefinition(mockEntryAndAnnotation, matcher)).toBe(
@@ -290,7 +290,7 @@ describe('doesEntryMatchDefinition', () => {
290290
},
291291
}
292292
const mockEntryAndAnnotation = {
293-
entry: mockEntryBase,
293+
span: mockEntryBase,
294294
annotation: mockAnnotation,
295295
}
296296
expect(doesEntryMatchDefinition(mockEntryAndAnnotation, matcher)).toBe(
@@ -307,7 +307,7 @@ describe('doesEntryMatchDefinition', () => {
307307
},
308308
}
309309
const mockEntryAndAnnotation = {
310-
entry: mockEntryBase,
310+
span: mockEntryBase,
311311
annotation: mockAnnotation,
312312
}
313313
expect(doesEntryMatchDefinition(mockEntryAndAnnotation, matcher)).toBe(
@@ -324,7 +324,7 @@ describe('doesEntryMatchDefinition', () => {
324324

325325
it('should return true for isIdle matching', () => {
326326
const mockEntryAndAnnotation = {
327-
entry: mockComponentEntry,
327+
span: mockComponentEntry,
328328
annotation: mockAnnotation,
329329
}
330330
expect(
@@ -335,7 +335,7 @@ describe('doesEntryMatchDefinition', () => {
335335
it('should return false for non-matching isIdle', () => {
336336
const mockEntry = { ...mockComponentEntry, isIdle: false }
337337
const mockEntryAndAnnotation = {
338-
entry: mockEntry,
338+
span: mockEntry,
339339
annotation: mockAnnotation,
340340
}
341341
expect(
@@ -357,7 +357,7 @@ describe('doesEntryMatchDefinition', () => {
357357
type: 'element',
358358
}
359359
const mockEntryAndAnnotation = {
360-
entry: mockPerformanceEntry,
360+
span: mockPerformanceEntry,
361361
annotation: mockAnnotation,
362362
}
363363
expect(doesEntryMatchDefinition(mockEntryAndAnnotation, matcher)).toBe(
@@ -377,7 +377,7 @@ describe('doesEntryMatchDefinition', () => {
377377
type: 'element',
378378
}
379379
const mockEntryAndAnnotation = {
380-
entry: mockPerformanceEntry,
380+
span: mockPerformanceEntry,
381381
annotation: mockAnnotation,
382382
}
383383
expect(doesEntryMatchDefinition(mockEntryAndAnnotation, matcher)).toBe(

src/v3/doesEntryMatchDefinition.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { ScopeBase, SpanAndAnnotationEntry } from './types'
21
import { SpanMatcher } from './spanTypes'
2+
import { ScopeBase, SpanAndAnnotationEntry } from './types'
33

44
/**
55
* Matches criteria against a performance entry event.
@@ -45,18 +45,18 @@ export function doesEntryMatchDefinition<ScopeT extends ScopeBase>(
4545
!attributes ||
4646
Boolean(
4747
span.attributes &&
48-
Object.entries(attributes).every(
49-
([key, value]) => span.attributes?.[key] === value,
50-
),
48+
Object.entries(attributes).every(
49+
([key, value]) => span.attributes?.[key] === value,
50+
),
5151
)
5252

5353
const matchesScope =
5454
!scope ||
5555
Boolean(
5656
span.scope &&
57-
Object.entries(scope).every(
58-
([key, value]) => span.scope?.[key] === value,
59-
),
57+
Object.entries(scope).every(
58+
([key, value]) => span.scope?.[key] === value,
59+
),
6060
)
6161

6262
const spanIsIdle = 'isIdle' in span ? span.isIdle : false

0 commit comments

Comments
 (0)