Skip to content

Commit cd101a4

Browse files
committed
fix: additions from lotus integration, sess 1
1 parent 8674402 commit cd101a4

7 files changed

+21
-9
lines changed

src/v3/hooks.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ export const generateUseBeacon =
3434
const renderCountRef = useRef(0)
3535
renderCountRef.current += 1
3636

37-
const attributes = {
38-
...config.attributes,
39-
renderCount: renderCountRef.current,
40-
}
37+
const { attributes } = config
4138

4239
const status = config.error ? 'error' : 'ok'
4340

@@ -47,6 +44,7 @@ export const generateUseBeacon =
4744
duration: 0,
4845
attributes,
4946
status,
47+
renderCount: renderCountRef.current,
5048
})
5149

5250
traceManager.processSpan(renderStartTaskEntry)
@@ -60,6 +58,7 @@ export const generateUseBeacon =
6058
duration: performance.now() - renderStartTaskEntry.startTime.now,
6159
status,
6260
attributes,
61+
renderCount: renderCountRef.current,
6362
}),
6463
)
6564
})
@@ -75,6 +74,7 @@ export const generateUseBeacon =
7574
errorInfo: errorBoundaryMetadata?.errorInfo,
7675
duration: 0,
7776
status: errorBoundaryMetadata?.error ? 'error' : 'ok',
77+
renderCount: renderCountRef.current,
7878
})
7979
traceManager.processSpan(unmountEntry)
8080
},

src/v3/matchSpan.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ export type SpanMatcherFn<ScopeT extends ScopeBase> = ((
1616
SpanMatcherTags
1717

1818
export interface SpanMatchDefinition<ScopeT extends ScopeBase> {
19+
// IMPLEMENTATION TODO: take in scope as a second parameter
1920
name?: string | RegExp | ((name: string) => boolean)
21+
// IMPLEMENTATION TODO: take in scope as a second parameter
2022
performanceEntryName?: string | RegExp | ((name: string) => boolean)
2123
type?: SpanType
2224
status?: SpanStatus
2325
attributes?: Attributes
2426
scopes?: (keyof ScopeT)[]
27+
// IMPLEMENTATION TODO: take in scope as a second parameter
2528
occurrence?: number | ((occurrence: number) => boolean)
2629
isIdle?: boolean
2730
}

src/v3/spanTypes.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,10 @@ export interface SpanBase<ScopeT extends ScopeBase> {
9595

9696
export interface ComponentRenderSpan<ScopeT extends ScopeBase>
9797
extends Omit<SpanBase<ScopeT>, 'scope' | 'attributes'>,
98-
BeaconConfig<ScopeT> {
98+
BeaconConfig<ScopeT> {
9999
type: ComponentLifecycleSpanType
100100
errorInfo?: ErrorInfo
101+
renderCount: number
101102
}
102103

103104
export type InitiatorType =
@@ -126,17 +127,22 @@ export type InitiatorType =
126127

127128
export interface ResourceSpan<ScopeT extends ScopeBase>
128129
extends SpanBase<ScopeT> {
130+
type: 'resource',
129131
resourceDetails: {
130132
initiatorType: InitiatorType
131133
query: Record<string, string | string[]>
132134
hash: string
133135
}
134136
}
137+
138+
export interface PerformanceEntrySpan<ScopeT extends ScopeBase> extends SpanBase<ScopeT> {
139+
type: Exclude<NativePerformanceEntryType, 'resource'>
140+
}
141+
135142
/**
136143
* All possible trace entries
137144
*/
138-
139145
export type Span<ScopeT extends ScopeBase> =
140-
| SpanBase<ScopeT>
146+
| PerformanceEntrySpan<ScopeT>
141147
| ComponentRenderSpan<ScopeT>
142148
| ResourceSpan<ScopeT>

src/v3/traceManager.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,4 +591,6 @@ describe('TraceManager', () => {
591591
expect(report.interruptionReason).toBe('timeout')
592592
})
593593
})
594+
595+
// TESTING TODO: add test cases with getQuietWindowDuration
594596
})

src/v3/traceManager.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export class TraceManager<ScopeT extends ScopeBase> {
6565
computedValueDefinitions,
6666
}
6767

68+
// TESTING TODO: Add tests for define computed span and define computed value
6869
return {
6970
defineComputedSpan: (definition) => {
7071
computedSpanDefinitions.push(definition)

src/v3/traceRecordingTypes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,6 @@ export interface ComputedValueDefinition<
8585
matches: [...MatchersT]
8686
computeValueFromMatches: (
8787
// as many matches as match of type Span<ScopeT>
88-
matches: MapTuple<MatchersT, SpanAndAnnotation<ScopeT>>,
88+
...matches: MapTuple<MatchersT, SpanAndAnnotation<ScopeT>[]>
8989
) => number | string | boolean
9090
}

src/v3/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export interface TraceDefinition<ScopeT extends ScopeBase> {
8686
*/
8787
name: string
8888

89-
type: TraceType
89+
type?: TraceType
9090

9191
// TODO: implement this with typechecking
9292
// to ensure we cannot start a trace without the required scope keys

0 commit comments

Comments
 (0)