Skip to main content

Overview

@core-ai/axiom provides middleware that records model operations as OpenTelemetry GenAI spans for Axiom. Axiom automatically provisions a GenAI dashboard for datasets that receive spans with gen_ai.* attributes. The package exposes Axiom-named middleware factories and an exporter helper for Axiom’s OTLP traces endpoint. The middleware emits the same OpenTelemetry GenAI semantic convention attributes as @core-ai/opentelemetry.

Installation

@opentelemetry/api is a peer dependency. You also need an Axiom API token and dataset name.

Configure Axiom export

Create and start an OpenTelemetry SDK before you create or call traced models.
createAxiomExporterOptions returns the Axiom OTLP traces endpoint and the required Authorization and X-Axiom-Dataset headers.
Set endpoint only when you need to send traces through a proxy or custom collector.

Usage

Chat models

All four chat operations (generate, stream, generateObject, streamObject) are traced. For streaming operations, the span stays open until the stream completes and captures the final usage and finish reason.

Embedding models

Image models

Options

All three factory functions accept an optional AxiomMiddlewareOptions object:

recordContent

When true, input messages, tool definitions, and output content are recorded as span attributes. Defaults to false to avoid sending sensitive data to Axiom.

tracerName

The OpenTelemetry tracer name. Defaults to 'core-ai'.

Axiom dashboard

Axiom automatically creates the Generative AI Overview dashboard when your dataset receives spans with attributes.gen_ai.operation.name. You can query AI spans in Axiom with APL:

Span attributes

Spans follow OpenTelemetry GenAI semantic conventions and include Axiom-recognized attributes: When recordContent is enabled, input messages and output content are recorded as additional attributes. Errors are recorded with error.type and the span status is set to ERROR.