Threads AI

otel

An Exporter that sends each span of every thread in the store once, when it closes, to an OpenTelemetry collector over OTLP/HTTP JSON.

Pass it as host({telemetry: otel()}), or call sync() yourself. Settings not given as options come from the standard OTEL_EXPORTER_OTLP_* variables; semantic conventions core v1.41.1. Setup errors are thrown here: invalid_config names the option or variable.

Import from @threads/otel (TypeScript) or threads.otel (Python).

function otel(options?: {
  store?: Store;
  endpoint?: string;
  headers?: Record<string, string>;
  service?: string;
  name?: string;
  content?: boolean;
}): Exporter

Parameters

storeStore

The store whose threads are exported, every tenant. Omitted: the store of the host it is passed to; sync() outside a host without one is invalid_config. See Store.

endpointstring

The collector's traces URL, used as is. Omitted: the traces variable as is, else the generic one with /v1/traces appended; neither set is invalid_config naming both.

headersRecord<string, string>

Request headers, such as a vendor's API key. Omitted: the variables (k=v,k=v, percent-decoded). They are credentials: never logged or put in an error.

servicestring

The resource's service.name. Omitted: OTEL_SERVICE_NAME, else service.name in OTEL_RESOURCE_ATTRIBUTES, else threads.

namestring

Names this exporter's cursor (observer otel:<name>), so two exporters with different names each send every span, to different collectors. Omitted: the observer is otel.

contentbooleandefault false

true: tool spans also carry the tool arguments and result preview, and model spans the response text, as logged (already redacted). Prompts are never exported.

Returns

Exporter

Throws ConfigError with one of these codes: invalid_config.

Edit on GitHub

On this page