Skip to main content
Access via:io.insights.traces

TracesManagerinterface

Traces API.

Properties (9)

Property Type Default Required Description
clickstreamMarker⚓︎ MarkerSpanCallback x x

Optional callback function to programmatically create marker spans in the Clickstream trace. Allows applications to mark specific user interaction events beyond automatic click tracking (e.g., custom UI interactions, gesture events, programmatic actions).

The callback receives:

  • source: A descriptive name for the marker (e.g., "user-swiped-left", "custom-button-action")
  • data: Optional span data organized by verbosity level for detailed context

Returns either PropagationInfo to link the marker span to other traces, or void.

Works in conjunction with the clickstream setting to track detailed user interaction patterns.

currentTracingState⚓︎ TracingState | null x

The tracing state representing the currently active trace and span, if any.

endOpenSpans⚓︎ (reason?: string) => number x x

Ends every span that is still open, so that it gets exported: a span is only exported once it has ended, and whatever is still open when the process goes away is lost. The spans are ended as they stand and marked with an endedByShutdown attribute (and endedByShutdownReason, when a reason is given). Called by waitForFinalExport(); call it directly ahead of any other last flush.

flush⚓︎ (timeoutMs?: number) => Promise<void> x x

Exports the spans that have ended so far, waiting for up to timeoutMs. Unlike waitForFinalExport() it leaves the spans that are still open alone - for a flush at a point where the application may go on running. Never rejects.

instrumentElectronNet⚓︎ (netModule: unknown) => void x x

Instruments Electron's main-process net module (net.request and net.fetch) with the request spans (source "interopio.api.instrumentation.electronNet" / ".fetch") and the same request metrics as the renderer fetch/XHR instrumentation. The net module is injected by the caller - io.Connect Desktop's bootstrap, guarded by instrumentRequests.platform - because the io.Insights packages have no electron dependency. Honors the instrumentRequests configuration (ignore/match patterns, ignoreTelemetryURLs, errorStatusCodes, spanNames, metric flags); no-op when instrumentRequests is disabled.

settings⚓︎ TracesSettings x

Traces settings.

started⚓︎ boolean x

Whether or not this instance is started.

startupTraceFinished⚓︎ (reason?: string) => void x x

Called by the application to signify that its startup has completed and no further spans should be nested under the startup trace.

It also tells io.Connect Desktop, by invoking the platform's "T42.ACS.AppStartupFinished" interop method: what the platform's appStartMeasurement "explicit" counts as the application having started. The method is invoked with the interop API the library was built with - Builder.withInterop (@interopio/core passes its own), or the interop argument of the traces plugin's newTracesManager - and with no other: without one, nothing is told. Where that API can list the registered methods (methods), the method is looked for first and invoked only when the platform has registered it; an API without methods is invoked without the lookup. Best effort - a failing invocation is swallowed, and nothing is tried again later - not for the platform's own loader signal, and once per page load: a later call that finds the platform told already tells it nothing more.

userJourneyMarker⚓︎ MarkerSpanCallback x x

Optional callback function to programmatically create marker spans in the User Journey trace. Allows applications to mark significant points in a user's journey through the application (e.g., navigation events, key user actions, milestone completions).

The callback receives:

  • source: A descriptive name for the marker (e.g., "user-navigated-to-dashboard")
  • data: Optional span data organized by verbosity level for detailed context

Returns either PropagationInfo to link the marker span to other traces, or void.

Works in conjunction with the userJourney setting to track the user's entire session flow.

14 Methods

setFilterConfig()⚓︎

(filters: SpanFilter[]) => void

Allows updating the configured filters.

On the startup span buffer (BufferingTracesManager), which has no settings of its own: gives it the filters the real manager is going to match the spans against. A span that a filter disables for certain (enabled: false - going by the span's source and the context it was created with) is then not buffered: its callback runs as that of a disabled span does, and the spans created inside it nest under the nearest buffered ancestor. Not when something is asked of the span although it is disabled - countMetricOnDisabledSpans, resultMetricOnDisabledSpans, durationMetricOnDisabledSpans, log.onDisabledSpans or stopPropagationIfSpanIsDisabled, set by a filter that may match the span, by a default filter of its options or by the options themselves: such a span is buffered, and handled by the real manager at the replay, like every other span (what the defaults of the traces settings ask is not seen: the buffer does not have them). Only a plain enabled: false is acted on while buffering - every other span is buffered, and every other filter property applied, by the real manager at the replay.

Parameters (1)

Name Type Required Description
filters⚓︎ SpanFilter[] x

start()⚓︎

() => Promise<void>

Starts publishing data.

stop()⚓︎

() => Promise<void>

Stops publishing data.

waitForFinalExport()⚓︎

(timeoutMs?: number) => Promise<void>

Waits for any pending data to be published, with the option to specify a timeout.

Parameters (1)

Name Type Required Description
timeoutMs⚓︎ number x

maximum time to wait for export

withSequenceSpan()⚓︎

<T>(source: string, callback: | WithSpanCallback<T>) => Promise<T>

Allows creating a span for a named trace.

Parameters (2)

Name Type Required Description
source⚓︎ string

The name of the span to create. The name of the trace will be .start, and if one doesn't exist, it will be created.

callback⚓︎ | WithSpanCallback<T>

Logic to execute in the span.

withSequenceSpan()⚓︎

<T>(source: string, filteringContext: | FilteringContext | null, callback: | WithSpanCallback<T>) => Promise<T>

Allows creating a span for a named trace.

Parameters (3)

Name Type Required Description
source⚓︎ string

The name of the span to create. The name of the trace will be .start, and if one doesn't exist, it will be created.

filteringContext⚓︎ | FilteringContext | null

Filtering context used to match against the tracing filtering configuration.

callback⚓︎ | WithSpanCallback<T>

Logic to execute in the span.

withSequenceSpan()⚓︎

<T>(source: string, filteringContext: | FilteringContext | null, options: | WithSpanOptions | null, callback: | WithSpanCallback<T>) => Promise<T>

Allows creating a span for a named trace.

Parameters (4)

Name Type Required Description
source⚓︎ string

The name of the span to create. The name of the trace will be .start, and if one doesn't exist, it will be created.

filteringContext⚓︎ | FilteringContext | null

Filtering context used to match against the tracing filtering configuration.

options⚓︎ | WithSpanOptions | null

Options to use when creating the span.

callback⚓︎ | WithSpanCallback<T>

Logic to execute in the span.

withSequenceSpanEx()⚓︎

<T>(source: string, traceName: | string | null, callback: | WithSpanCallback<T>) => Promise<T>

Allows creating a span for a named trace.

Parameters (3)

Name Type Required Description
source⚓︎ string

The name of the span to create.

traceName⚓︎ | string | null

The name of the trace to nest the span in. If one doesn't exist, it will be created.

callback⚓︎ | WithSpanCallback<T>

Logic to execute in the span.

withSequenceSpanEx()⚓︎

<T>(source: string, traceName: | string | null, filteringContext: | FilteringContext | null, callback: | WithSpanCallback<T>) => Promise<T>

Allows creating a span for a named trace.

Parameters (4)

Name Type Required Description
source⚓︎ string

The name of the span to create.

traceName⚓︎ | string | null

The name of the trace to nest the span in. If one doesn't exist, it will be created.

filteringContext⚓︎ | FilteringContext | null

Filtering context used to match against the tracing filtering configuration.

callback⚓︎ | WithSpanCallback<T>

Logic to execute in the span.

withSequenceSpanEx()⚓︎

<T>(source: string, traceName: | string | null, filteringContext: | FilteringContext | null, options: | WithSpanOptions | null, callback: | WithSpanCallback<T>) => Promise<T>

Allows creating a span for a named trace.

Parameters (5)

Name Type Required Description
source⚓︎ string

The name of the span to create.

traceName⚓︎ | string | null

The name of the trace to nest the span in. If one doesn't exist, it will be created.

filteringContext⚓︎ | FilteringContext | null

Filtering context used to match against the tracing filtering configuration.

options⚓︎ | WithSpanOptions | null

Options to use when creating the span.

callback⚓︎ | WithSpanCallback<T>

Logic to execute in the span.

withSpan()⚓︎

<T>(source: string, callback: WithSpanCallback<T>) => T

Allows creating a span for the currently active trace. If one doesn't exist, it will be created.

Parameters (2)

Name Type Required Description
source⚓︎ string

The name of the span to create.

callback⚓︎ WithSpanCallback<T>

Logic to execute in the span.

withSpan()⚓︎

<T>(source: string, filteringContext: FilteringContext, callback: WithSpanCallback<T>) => T

Allows creating a span for the currently active trace. If one doesn't exist, it will be created.

Parameters (3)

Name Type Required Description
source⚓︎ string

The name of the span to create.

filteringContext⚓︎ FilteringContext

Filtering context used to match against the tracing filtering configuration.

callback⚓︎ WithSpanCallback<T>

Logic to execute in the span.

withSpan()⚓︎

<T>(source: string, filteringContext: FilteringContext, propagationInfo: PropagationInfo | PropagationInfoCarrier | null, callback: WithSpanCallback<T>) => T

Allows creating a span for the currently active trace or a specified trace. If one doesn't exist, it will be created.

Parameters (4)

Name Type Required Description
source⚓︎ string

The name of the span to create.

filteringContext⚓︎ FilteringContext

Filtering context used to match against the tracing filtering configuration.

propagationInfo⚓︎ PropagationInfo | PropagationInfoCarrier | null

Span and trace id to use for manually nesting the new trace.

callback⚓︎ WithSpanCallback<T>

Logic to execute in the span.

withSpan()⚓︎

<T>(source: string, filteringContext: FilteringContext, propagationInfo: PropagationInfo | PropagationInfoCarrier | null, options: WithSpanOptions | null, callback: WithSpanCallback<T>) => T

Allows creating a span for the currently active trace or a specified trace. If one doesn't exist, it will be created.

Parameters (5)

Name Type Required Description
source⚓︎ string

The name of the span to create.

filteringContext⚓︎ FilteringContext

Filtering context used to match against the tracing filtering configuration.

propagationInfo⚓︎ PropagationInfo | PropagationInfoCarrier | null

Span and trace id to use for manually nesting the new trace.

options⚓︎ WithSpanOptions | null

Options to use when creating the span.

callback⚓︎ WithSpanCallback<T>

Logic to execute in the span.