@zendesk/react-measure-timing-hooks
Version:
react hooks for measuring time to interactive and time to render of components
26 lines (25 loc) • 2.47 kB
TypeScript
import type { FinalState } 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>): TraceRecording<SelectedRelationNameT, RelationSchemasT>['computedSpans'];
export declare function createTraceRecording<const SelectedRelationNameT extends keyof RelationSchemasT, const RelationSchemasT, const VariantsT extends string>(context: TraceContext<SelectedRelationNameT, RelationSchemasT, VariantsT>, { transitionFromState, interruptionReason, cpuIdleSpanAndAnnotation, completeSpanAndAnnotation, lastRequiredSpanAndAnnotation, }: FinalState<RelationSchemasT>): TraceRecording<SelectedRelationNameT, RelationSchemasT>;