@zendesk/retrace
Version:
define and capture Product Operation Traces along with computed metrics with an optional friendly React beacon API
30 lines (29 loc) • 2.58 kB
TypeScript
import type { SpanAndAnnotation } from './spanAnnotationTypes';
import type { FinalTransition } from './Trace';
import type { TraceRecording } from './traceRecordingTypes';
import type { TraceContext } from './types';
/**
* ### Deriving SLIs and other metrics from a trace
*
* ℹ️ It is our recommendation that the primary way of creating duration metrics would be to derive them from data in the trace.
*
* Instead of the traditional approach of capturing isolated metrics imperatively in the code,
* the **trace** model allows us the flexibility to define and compute any number of metrics from the **trace recording**.
*
* We can distinguish the following types of metrics:
*
* 1. **Duration of a Computed Span** — the time between any two **spans** that appeared in the **trace**. For example:
* 1. _time between the user’s click on a ticket_ and _everything in the ticket page has fully rendered with content_ (duration of the entire operation)
* 2. _time between the user’s click on a ticket_ and _the moment the first piece of the ticket UI was displayed_ (duration of a segment of the operation)
*
* 2. **Computed Values** — any numerical value derived from the **spans** or their attributes. For example:
* 1. _The total number of times the log component re-rendered while loading the ticket_
* 2. _The total number of requests made while loading the ticket_
* 3. _The total number of iframe apps were initialized while loading the ticket_
*/
export declare function getComputedValues<SelectedRelationNameT extends keyof RelationSchemasT, RelationSchemasT, const VariantsT extends string>(context: TraceContext<SelectedRelationNameT, RelationSchemasT, VariantsT>): TraceRecording<SelectedRelationNameT, RelationSchemasT>['computedValues'];
export declare function getComputedSpans<SelectedRelationNameT extends keyof RelationSchemasT, RelationSchemasT, const VariantsT extends string>(context: TraceContext<SelectedRelationNameT, RelationSchemasT, VariantsT>, finalState?: {
completeSpanAndAnnotation?: SpanAndAnnotation<RelationSchemasT>;
cpuIdleSpanAndAnnotation?: SpanAndAnnotation<RelationSchemasT>;
}): TraceRecording<SelectedRelationNameT, RelationSchemasT>['computedSpans'];
export declare function createTraceRecording<const SelectedRelationNameT extends keyof RelationSchemasT, const RelationSchemasT, const VariantsT extends string>(context: TraceContext<SelectedRelationNameT, RelationSchemasT, VariantsT>, transition: FinalTransition<RelationSchemasT>): TraceRecording<SelectedRelationNameT, RelationSchemasT>;