UNPKG

@zendesk/retrace

Version:

define and capture Product Operation Traces along with computed metrics with an optional friendly React beacon API

52 lines (51 loc) 3.44 kB
import type { SpanAndAnnotationForMatching, SpanMatcherFn } from './matchSpan'; import type { ChildOperationSpan, ComponentRenderSpan, PARENT_SPAN, Span } from './spanTypes'; import type { RecordedSpan, RecordedSpanAndAnnotation, TraceRecording, TraceRecordingBase } from './traceRecordingTypes'; import type { RelationSchemasBase, TraceContext } from './types'; export interface EmbeddedEntry { count: number; totalDuration: number; spans: { startOffset: number; duration: number; error?: true | undefined; }[]; } export interface SpanSummaryAttributes { [typeAndName: string]: { [attributeName: string]: unknown; }; } export interface RumTraceRecording<SelectedRelationNameT extends keyof RelationSchemasT, RelationSchemasT extends RelationSchemasBase<RelationSchemasT>> extends TraceRecordingBase<SelectedRelationNameT, RelationSchemasT> { embeddedSpans: { [typeAndName: string]: EmbeddedEntry; }; nonEmbeddedSpans: string[]; /** * Merged attributes of the spans with the same type and name. * If attributes changed, most recent ones overwrite older ones. */ spanAttributes: SpanSummaryAttributes; longestSpan: (RecordedSpanAndAnnotation<RelationSchemasT> & { key: string; }) | undefined; childOperations: Record<string, ChildOperationData<RelationSchemasT>>; [key: string]: unknown; } export declare function isRenderEntry<RelationSchemasT extends RelationSchemasBase<RelationSchemasT>>(span: Span<RelationSchemasT> | RecordedSpan<RelationSchemasT>): span is ComponentRenderSpan<RelationSchemasT>; export declare const defaultEmbedSpanSelector: <RelationSchemasT extends RelationSchemasBase<RelationSchemasT>>(spanAndAnnotation: SpanAndAnnotationForMatching<RelationSchemasT>) => boolean; export declare function getSpanSummaryAttributes<RelationSchemasT extends RelationSchemasBase<RelationSchemasT>>(recordedItems: readonly RecordedSpanAndAnnotation<RelationSchemasT>[]): SpanSummaryAttributes; export declare function findLongestSpan<RelationSchemasT extends RelationSchemasBase<RelationSchemasT>>(spanAndAnnotations: readonly RecordedSpanAndAnnotation<RelationSchemasT>[], filter?: (spanAndAnnotation: RecordedSpanAndAnnotation<RelationSchemasT>) => boolean): RecordedSpanAndAnnotation<RelationSchemasT> | undefined; type RoundFunction = (x: number) => number; export declare function recursivelyRoundValues<T extends object>(obj: T, roundFunc?: RoundFunction): T; type ChildOperationData<RelationSchemasT extends RelationSchemasBase<RelationSchemasT>> = Omit<ChildOperationSpan<RelationSchemasT>, typeof PARENT_SPAN | 'getParentSpan' | 'entries'> & { operationRelativeStartTime: number; operationRelativeEndTime: number; }; export declare function convertTraceToRUM<const SelectedRelationNameT extends keyof RelationSchemasT, const RelationSchemasT extends RelationSchemasBase<RelationSchemasT>, const VariantsT extends string>({ traceRecording, context, embedSpanSelector, keepComputedRenderBeaconSpanAttributes, }: { traceRecording: TraceRecording<SelectedRelationNameT, RelationSchemasT>; context: TraceContext<SelectedRelationNameT, RelationSchemasT, VariantsT>; embedSpanSelector?: SpanMatcherFn<SelectedRelationNameT, RelationSchemasT, VariantsT>; keepComputedRenderBeaconSpanAttributes?: string[] | false; }): RumTraceRecording<SelectedRelationNameT, RelationSchemasT>; export {};