@docx-editor.dev/telemetry/otel

OpenTelemetry: metrics and traces through the OpenTelemetry SDK you already run. This entry depends only on @opentelemetry/api; your SDK decides where data goes (OTLP to a collector, Datadog, Grafana, Honeycomb, New Relic, and others).

Functions (1)

otelExporterfunctionSource ↗

Record metrics and traces with OpenTelemetry. The exporter reads the global providers at each use, so it can be created before your SDK starts.

Metrics use the names in METRICS. Each document open becomes a docx_editor.document.open span, with an error status when it is refused. Other events become events on the active span; without one, a failure gets a short span of its own.

declare function otelExporter(options?: OtelExporterOptions): TelemetryExporter;
```ts
import { createTelemetry } from '@docx-editor.dev/telemetry';
import { otelExporter } from '@docx-editor.dev/telemetry/otel';

// Before or after your OpenTelemetry SDK starts: the exporter reads the global providers at
// each use.
export const telemetry = createTelemetry({ exporters: [otelExporter()] });
```

Interfaces (2)

OtelExporterOptionsinterfaceSource ↗

Options for [otelExporter](otelExporter).

interface OtelExporterOptions
MemberTypeSummary
meterProvider?MeterProviderDefaults to the global provider your SDK registered.
parentContext?() => Context | undefinedThe parent of each `docx_editor.document.open` span. Browsers have no async context, so without this the span is a root span. Return your page-load or route span's context.
scope?stringInstrumentation scope name. Defaults to `@docx-editor.dev/telemetry`.
tracerProvider?TracerProviderDefaults to the global provider your SDK registered.

TelemetryExporterinterfaceSource ↗

Where telemetry goes. Implement event, metric, or both.

An exporter never throws into the editor or the server: a failure is caught and reported once through onExporterError.

interface TelemetryExporter
```ts
const toMyLogger: TelemetryExporter = {
  name: 'my-logger',
  event: (event) => myLogger.warn(event.kind, { code: 'code' in event ? event.code : undefined }),
};
```
MemberTypeSummary
attachCalled once when a telemetry client or room server takes the exporter. An exporter that holds events, such as a batching one, reads `consented()` before it sends, so events queued before consent was withdrawn are discarded, not sent.
declareStart a series at zero before its first measurement. A scraper that sees a counter first at 1 cannot count that first increase, so the room server declares its known series when it starts. Optional: an exporter without it creates each series at its first measurement.
event
flushSend anything buffered. Called by `flush()` and when a page is hidden.
forgetDrop a series that no longer exists, such as a closed room's per-room gauge. Optional: an exporter without it keeps the series until it expires on its own.
metric
namestringShown in `onExporterError` reports.
shutdownFlush and release resources. Called by `shutdown()`.