Skip to main content

Insights.TracesSettingsinterface

Settings for publishing io.Insights traces.

Properties (38)

Property Type Default Required Description
additionalAttributes⚓︎ { [x: string]: unknown; } | (() => { [x: string]: unknown; }) x x

Additional span attributes to publish as part of each span, specified as key/value pairs. You can use environment variables as values. Environment variables must start and end with a percent sign (e.g., %MyEnvVar%), and can contain a fallback value (e.g., %MyEnvVar?literalDefaultValue%).

additionalResourceAttributes⚓︎ { [x: string]: unknown; } | (() => { [x: string]: unknown; }) x x

Additional attributes to publish as part of the OTEL resource definition, specified as key/value pairs. You can use environment variables as values. Environment variables must start and end with a percent sign (e.g., %MyEnvVar%), and can contain a fallback value (e.g., %MyEnvVar?literalDefaultValue%).

A function is asked once, on the first read after the build, and its answer is kept: the SDK's resource is made once, at its creation, and the readers that look at the resource attributes on every span (the span filters' context, the sampler) see the same values.

addResourceAttributesToAttributes⚓︎ boolean false x

Whether to add resource attributes to span attributes.

attributeSettings⚓︎ { [x: string]: AttributeSettings; } x x

Controls the publishing of specific attributes, by name. An entry names an attribute by its flattened (dot-separated) name, or everything nested under it - "bounds" covers "bounds.left" - and the most specific entry is the one that applies to an attribute. See AttributeSettings for what an entry does, and attributeSettingsMode for whether the entries are a block list (the default) or an allow list.

Applies to everything written on every span - the filtering context, the additional attributes, the data added through addData, the otelSpanOptions attributes. A matching span filter's attributeSettings merge over these, by attribute name.

The "drop" and "mask" entries - never as an allow list - also apply to the resource attributes the spans are published with. A span filter's do not: the resource is the one all the spans share.

The trace metrics (insights_trace_count / _result / _duration) get the entries set here and the matching filter's as their most specific level, over each metric's own attributeSettings.

attributeSettingsMode⚓︎ AttributeSettingsMode x x

How the attributeSettings read: "blocklist" (the default) publishes everything except the attributes with a "drop" entry - an "allow" entry is the exception to a broader "drop" ("bounds" dropped, "bounds.width" allowed); "allowlist" publishes only the attributes with an "allow" or a "mask" entry. The most specific level that sets it applies - a matching span filter's, then this.

clickstream⚓︎ TracesSettings["clickstream"] true x

Controls the capturing of DOM events as spans in a Click Stream trace. Set to true or "sibling" to record event spans under a common starting span. Set to "nested" to record the first event span under the starting span and each subsequent event span under the previous event span. Set to false to disable Click Stream tracing. Use a ClickstreamTraceConfig object as a value to provide detailed event and span settings.

Capturing starts after the @interopio/browser library has been initialized. By default, only click events are captured. Each captured click event is recorded as a click span (e.g., interopio.api.clickstream.<app_name>.click). For invoked click event listeners to be captured, they must be registered via addEventListener() after the library initialization has completed. These event listeners will be captured as separate listener child spans (e.g., interopio.api.clickstream.<app_name>.click.listener) under the corresponding click span. If the event doesn't have listeners, or only listeners registered before library initialization, the click span won't contain child spans for the listeners.

concurrencyLimit⚓︎ number x x

Maximum number of concurrent trace export requests.

console⚓︎ boolean x x

If an OTEL TraceProvider isn't provided to the library, it will initialize its own.

If 'console' is 'true', TracerProvider will have a ConsoleTraceExporter.

contextManager⚓︎ (tracesSettings: TracesSettings, settings: Settings) => ContextManager x x

Allows specifying a constructor callback for creating the ContextManager instance.

countMetric⚓︎ string | boolean true x

If true or a string, span hits are published as a counter metric. If a string value is specified, this will be the name of the metric. Otherwise, the default "insights_trace_count" is used. Set to false or null to disable the metric. Spans opt in through the countMetric span creation option (see 'filters' and 'defaults').

defaults⚓︎ SpanCreationOptions x x

Default settings if appropriate entries aren't found in 'filters' and 'sampling' collections.

durationMetric⚓︎ string | boolean true x

If true or a string, span durations are published as a histogram metric. If a string value is specified, this will be the name of the metric. Otherwise, the default "insights_trace_duration" is used. Set to false or null to disable the metric. Spans opt in through the durationMetric span creation option (see 'filters' and 'defaults').

enabled⚓︎ boolean false

Whether tracing functionality is enabled. If disabled, API is still usable, but methods are no-ops.

filters⚓︎ SpanFilter[] x x

Array of filter entries used to determine whether a particular operation will create a tracing span, and what verbosity level will apply to attributes added to that span.

If no matching filter entry is found, the settings from 'default' are used.

headers⚓︎ { [x: string]: string; } | (() => { [x: string]: string; }) | (() => Promise<{ [x: string]: string; }>) x x

Additional headers to send in HTTP requests, e.g. when using HTTP exporters.

instrumentAppStartup⚓︎ boolean | AppStartupTraceConfig true x

If true (or a configuration object), io.Insights will instrument and trace the application startup process automatically: a root "interopio.api.appStartup" span starting at the runtime's time origin, under which spans created during the startup window are nested (via the propagation defaults). In browsers the root carries child spans and KPIs reconstructed from the performance timeline (navigation phases, paints, long tasks, startup-window web vitals, lifecycle transitions). The configuration object switches the root span's parenting of the startup window's spans and each of those aspects off individually - see AppStartupTraceConfig; everything in it defaults to on.

The uncaught errors, the slowest resource loads and the long tasks of the startup window are published under the root as the spans of the dedicated instrumentations - "interopio.api.instrumentation.errors.*", ".resource" and ".eventLoopBlocking", with the same attributes - so they look the same whether instrumentErrors / instrumentResources / instrumentEventLoop is on (which then publishes them) or off (this trace does). Errors are counted on the root (lifecycle.errorCount) either way, and perf.vitals.cls is the same session-window score instrumentWebVitals reports, for the startup window.

Also works in NodeJS: the root span opens at process start and the startup window nesting applies, but the browser performance-timeline children are not produced. The window closes on parentSpanTimeoutMs or an explicit startupTraceFinished() call ("loader" mode behaves as "any" in Node - there is no loader signal). When the platform provides a root propagation info, the startup span is parented under it.

instrumentErrors⚓︎ boolean | ErrorInstrumentationConfig false x

If true (or a configuration object with enabled), uncaught errors and unhandled promise rejections are published as error spans ("interopio.api.instrumentation.error" / ".unhandledRejection"), including errors buffered before initialization by the pre-init recorder. Capped per session to guard against error storms. When enabled, the app startup trace defers its own error capture to this instrumentation, and the pre-init recorder (when installed) captures errors from page start - opt out of that with the configuration object's preInit: false.

Also works in NodeJS, via process.uncaughtExceptionMonitor - a behavior-preserving hook: the process still crashes exactly as it would have. The span processors are force-flushed immediately, so the crash span is exported whenever anything keeps the process alive past the crash (an application 'uncaughtException' handler, a graceful shutdown); on a hard crash the export cannot complete and the span is lost with the process. Under Node's default unhandled-rejections=throw mode, crash-grade unhandled rejections are reported too; non-crashing rejection observation is deliberately not done in Node, because subscribing to process.unhandledRejection would suppress Node's default crash semantics.

instrumentEventLoop⚓︎ boolean | EventLoopInstrumentationConfig false x

If true (or a configuration object), event loop responsiveness is instrumented: slow input events (Event Timing API) and main-thread-blocking long frames (Long Animation Frames API, falling back to Long Tasks) are published as spans ("interopio.api.instrumentation.inputDelay" / ".eventLoopBlocking"), with the input-delay spans carrying the same element-describing attributes as the clickstream spans. Optional histogram metrics can be enabled via the configuration object. Entries recorded before initialization are replayed from the performance buffers. A hidden document renders no frames, so while it is hidden its long tasks are published from the Long Tasks timeline instead (measurement: "longtask", without script attribution): a window that does its initialization before it is shown is seen blocking all the same.

Every span is a child of one "interopio.api.instrumentation.eventLoop.session" span that lives as long as the page - a trace of its own, linked to the startup span when the instrumentation starts during the startup window - and carries the running totals as attributes (inputDelayCount / inputDelayTotalMs / inputDelayMaxMs, blockingCount / blockingTotalMs / blockingMaxMs), updated as the entries come and counting on past the span caps. It ends when the page goes away (pagehide, flushed) or at the final export, so it arrives after its children.

instrumentNavigation⚓︎ boolean false x

If true, in-page (SPA) navigations - history pushState/replaceState, popstate and hashchange - are published as spans ("interopio.api.instrumentation.navigation") with the sanitized from/to URLs. Same-URL state updates are not reported.

instrumentRequests⚓︎ boolean | RequestTraceConfig false x

If true (or a configuration object with enabled: true), io.Insights will instrument and trace XMLHttpRequest and fetch() requests automatically. When enabled, the pre-init recorder (when installed) also captures requests from page start - opt out of that with the configuration object's preInit: false.

instrumentResources⚓︎ boolean | ResourceInstrumentationConfig false x

If true (or a configuration object), resource loads (scripts, stylesheets, images, fonts, ...) are published as spans ("interopio.api.instrumentation.resource") with their real timings from the resource timing buffer, including resources loaded before initialization, a cacheState attribute ("hit", "revalidated", "network", or "unknown" - cross-origin resources without a Timing-Allow-Origin header withhold cache provenance), and the nonzero connection-phase timings (dns/connect/tls/ttfb). By default fetch/XHR resources are excluded (the request instrumentation covers them in more detail; see skipRequests), as are telemetry uploads. Optional histogram/counter metrics can be enabled via the configuration object. When enabled, the app startup trace defers its slowest-resource child spans to this instrumentation.

instrumentWebSockets⚓︎ boolean | WebSocketInstrumentationConfig false x

If true (or a configuration object), WebSocket connections are instrumented: each connection that opens is published as a span ("interopio.api.instrumentation.webSocket.lifetime") covering its whole lifetime - backdated to the construction, until the close - with the connect duration, negotiated protocol, close code/reason/wasClean, and message/byte totals in both directions. Abnormal closures (code 1006) mark the span as ERROR. A connection that never opens has no lifetime span: its connect span carries the failure. Optional message/byte counters and a connect-duration histogram can be enabled via the configuration object. The handshake of each connection is a span of its own besides ("interopio.api.instrumentation.webSocket.connect", exported at the open, linked to the connection span - see trace). A connection still open when the page is unloaded for good (pagehide, not an entry into the back/forward cache) gets its span ended there, with the counts so far and endedByShutdown: true, endedByShutdownReason: "pagehide" - no close code, the status left alone - and flushed, since the socket dies with the page and its close event would come too late or not at all; a handshake still going on is ended the same way, without a status. The counts are also kept on the span as the messages flow (a moment stale at most), for the case where the flushOnClose handling ends the span first. Telemetry endpoints are never instrumented; the io.Connect gateway connection is tracked by default (its lifecycle is platform-health telemetry - exclude it with ignoreGateway), and ignorePattern can exclude other infrastructure sockets.

When the pre-init module (early.js) is loaded, sockets are tracked from page start: connections that closed before initialization become retroactive spans, and connections still open are adopted with spans starting at their true construction time and counters carried across - a socket opened at bootstrap is fully observed. Without the pre-init module, sockets constructed before initialization are not observed at all.

instrumentWebVitals⚓︎ boolean | WebVitalsInstrumentationConfig false x

If true (or a configuration object), session-level Web Vitals are tracked: CLS (cumulative layout shift, session-window algorithm), INP (interaction to next paint, the web-vitals estimation over Event Timing entries) and the final LCP. A "interopio.api.instrumentation.webVitals" span with the current values is published each time the page becomes hidden (when the values changed), and optional histogram metrics record one terminal sample per page at pagehide. Complements the startup trace's perf.vitals, which cover only the startup window - CLS accumulates and INP is defined over the whole session.

Every report is a child of one "interopio.api.instrumentation.webVitals.session" span that lives as long as the page - a trace of its own, linked to the startup span when the instrumentation starts during the startup window - and carries the current CLS, INP, LCP and interaction count as attributes, updated as they come. It ends when the page goes away (pagehide, flushed) or at the final export, so it arrives after its children.

parentFromOTELContext⚓︎ boolean false x

If true, a span whose parent is not given explicitly (the propagation info argument of withSpan, getPropagationInfo) takes the span active in the OTEL context as its parent, whoever started it: an io.Insights span, or a span the OTEL SDK API started directly (tracer.startActiveSpan). A span the SDK started between two io.Insights spans is a parent then, instead of being skipped, and the io.Insights spans created under a span the SDK started nest under it instead of starting traces of their own. The nearest io.Insights span still sets the policy (forceChildTracing).

Needs a ContextManager (useOTELContextManager, contextManager, or one the host application registered): without one no span is ever active in the OTEL context, and the parent is resolved as if the option were off.

parentNameLimit⚓︎ number x x

Maximum length for parent operation names in span hierarchies.

processorSettings⚓︎ BatchSpanProcessorBrowserConfig x x

Configuration for the batch span processor buffer settings.

propagator⚓︎ (tracesSettings: TracesSettings, settings: Settings) => TextMapPropagator x x

Allows specifying a constructor callback for creating the TextMapPropagator instance.

restoreCurrentTracingState⚓︎ boolean false x

If true, Traces.currentTracingState is put back to what it was when a span's callback returns, so a span created synchronously after a nested span - in the same callback - still has its parent. Otherwise the state is cleared when a callback returns, and only the first nested span of a callback nests under it: the behaviour so far.

resultMetric⚓︎ string | boolean true x

If true or a string, span results (status codes) are published as a counter metric. If a string value is specified, this will be the name of the metric. Otherwise, the default "insights_trace_result" is used. Set to false or null to disable the metric. Spans opt in through the resultMetric span creation option (see 'filters' and 'defaults').

sampler⚓︎ (defaultSampler: Sampler, tracesSettings: TracesSettings, settings: Settings) => Sampler x x

Allows specifying a constructor callback for creating the Sampler instance.

sampling⚓︎ SamplingSettings[] x x

Array of sampling setting entries used to determine whether a span will be sampled.

If no matching sampling setting entry is found, the settings from 'defaults' are used.

spanExporters⚓︎ (exporterSettings: OTLPExporterNodeConfigBase, tracesSettings: TracesSettings, settings: Settings) => SpanExporter[] x x

Allows specifying a constructor callback for creating the SpanExporter instances.

spanProcessors⚓︎ (processorSettings: BatchSpanProcessorBrowserConfig | undefined, exporterSettings: OTLPExporterNodeConfigBase, tracesSettings: TracesSettings, settings: Settings) => SpanProcessor[] x x

Allows specifying a constructor callback for creating the SpanProcessor instances.

timeoutMillis⚓︎ number 10000ms. x

Maximum time the OTLP exporter will wait for each batch export.

tracerProvider⚓︎ (tracerProviderSettings: TracerConfig, tracesSettings: TracesSettings, settings: Settings) => TracerProvider x x

Allows specifying a constructor callback for creating the tracerProvider instance.

url⚓︎ string x x

If an OTEL TraceProvider isn't provided to the library, it will initialize its own.

If 'url' is specified, TracerProvider will have an OTLPTraceExporter using this destination URL.

useDefaultFilters⚓︎ boolean true. x

If true, use a predefined list of filters for well-known platform traces.

useOTELContextManager⚓︎ boolean false x

If true, the library will use the ContextManager provided by the active OTEL SDK to manage and derive propagation information to ensure spans created across asynchronous operations are properly nested.

Otherwise, use Traces.currentTracingState to set and retrieve propagation info across asynchronous operations manually.

See https://opentelemetry.io/docs/languages/js/propagation/ and https://opentelemetry.io/docs/languages/js/context/#context-manager for more information.