Skip to content

trulens.connectors.snowflake.otel_exporter

trulens.connectors.snowflake.otel_exporter

Classes

TruLensSnowflakeSpanExporter

Bases: SpanExporter

Implementation of SpanExporter that flushes the spans in the TruLens session to a Snowflake Stage.

Attributes
enabled instance-attribute
enabled: bool = True

Whether the exporter is enabled.

connector instance-attribute
connector: SnowflakeConnector = connector

The database connector used to export the spans.

Functions

make_ai_gateway_otel_exporter

make_ai_gateway_otel_exporter(
    gateway_base_url: str,
    token: str,
    *,
    timeout: Optional[int] = None
) -> SpanExporter

Build an OTLP exporter targeting a Snowflake Cortex AI Gateway.

AI Gateways serve OTLP over HTTP/protobuf at <gateway_base_url>/telemetry/v1/traces (not gRPC), so the stock otel_exporter="otlp" path cannot reach them. This helper returns the correct exporter plus the auth header the gateway expects.

PARAMETER DESCRIPTION
gateway_base_url

Gateway URL up to and including the gateway name, e.g. https://<account-host>/api/v2/aigateways/<gateway>.

TYPE: str

token

Bearer token (e.g. programmatic access token) the gateway authenticates with.

TYPE: str

timeout

Optional export timeout in seconds.

TYPE: Optional[int] DEFAULT: None

RETURNS DESCRIPTION
SpanExporter

An OTLPSpanExporter (HTTP/protobuf) pointed at the gateway

SpanExporter

telemetry endpoint.