@zendesk/retrace
Version:
define and capture Product Operation Traces along with computed metrics with an optional friendly React beacon API
42 lines (41 loc) • 2.82 kB
TypeScript
import type { Observable } from 'rxjs';
import type { AllPossibleAddSpanToRecordingEvents, AllPossibleDefinitionModifiedEvents, AllPossibleRequiredSpanSeenEvents, AllPossibleStateTransitionEvents, AllPossibleTraceStartEvents } from './debugTypes';
import { type SpanMatch } from './matchSpan';
import type { SpanAnnotationRecord } from './spanAnnotationTypes';
import type { Span } from './spanTypes';
import { Tracer } from './Tracer';
import type { AllPossibleTraceContexts, ComputedValueDefinitionInput, RelationSchemasBase, ReportErrorFn, SpanDeduplicationStrategy, TraceDefinition, TraceManagerConfig } from './types';
/**
* Class representing the centralized trace manager.
* Usually you'll have a single instance of this class in your app.
*/
export declare class TraceManager<const RelationSchemasT extends RelationSchemasBase<RelationSchemasT>> {
readonly performanceEntryDeduplicationStrategy?: SpanDeduplicationStrategy<RelationSchemasT>;
private currentTrace;
private eventSubjects;
get currentTracerContext(): AllPossibleTraceContexts<RelationSchemasT, string> | undefined;
constructor(configInput: Omit<TraceManagerConfig<RelationSchemasT>, 'reportWarningFn'> & {
reportWarningFn?: ReportErrorFn<RelationSchemasT>;
});
/**
* Subscribe to events from a trace and forward them to the TraceManager subjects
*/
private subscribeToTraceEvents;
/**
* Observable for events from all traces
* @param event The event type to observe
* @returns An Observable that emits events of the specified type from all traces
*/
when(event: 'trace-start'): Observable<AllPossibleTraceStartEvents<RelationSchemasT>>;
when(event: 'state-transition'): Observable<AllPossibleStateTransitionEvents<RelationSchemasT>>;
when(event: 'required-span-seen'): Observable<AllPossibleRequiredSpanSeenEvents<RelationSchemasT>>;
when(event: 'add-span-to-recording'): Observable<AllPossibleAddSpanToRecordingEvents<RelationSchemasT>>;
when(event: 'definition-modified'): Observable<AllPossibleDefinitionModifiedEvents<RelationSchemasT>>;
private utilities;
createTracer<const SelectedRelationNameT extends keyof RelationSchemasT, const VariantsT extends string, const ComputedValueTuplesT extends {
[K in keyof ComputedValueTuplesT]: SpanMatch<NoInfer<SelectedRelationNameT>, RelationSchemasT, NoInfer<VariantsT>>[];
}>(traceDefinition: TraceDefinition<SelectedRelationNameT, RelationSchemasT, VariantsT, {
[K in keyof ComputedValueTuplesT]: ComputedValueDefinitionInput<NoInfer<SelectedRelationNameT>, RelationSchemasT, NoInfer<VariantsT>, ComputedValueTuplesT[K]>;
}>): Tracer<SelectedRelationNameT, RelationSchemasT, VariantsT>;
processSpan(span: Span<RelationSchemasT>): SpanAnnotationRecord | undefined;
}