Skip to main content

OpenLLMetry

OpenLLMetry instruments your LLM application with OpenTelemetry and emits standard OTLP data. To send it to Logz.io, point the Traceloop SDK at an OpenTelemetry collector and configure the collector with the Logz.io exporters.

Before you begin, you'll need:

  • An LLM application (OpenAI, Anthropic, LangChain, LlamaIndex, and more)
  • An active Logz.io account
  • Port 4318 available on the collector host

Instrument your application​

Follow the Traceloop installation guide for your language:

LanguageGuide
PythonGetting started with Python
Node.jsGetting started with Node.js
Next.jsGetting started with Next.js
GoGetting started with Go
RubyGetting started with Ruby

Point the SDK at your collector​

Set the following environment variables for your application:

export TRACELOOP_BASE_URL=http://<<COLLECTOR-HOST>>:4318

If your SDK supports it, you can also send prompts and completions as log events:

export TRACELOOP_LOGGING_ENABLED=true
  • Replace <<COLLECTOR-HOST>> with the hostname of the OpenTelemetry collector, for example localhost.
  • The service name shown in Logz.io comes from the SDK's app_name (appName in Node.js) initialization option. See the Traceloop configuration options.

Download and configure the OpenTelemetry collector​

Create a dedicated directory on the collector host and download the OpenTelemetry collector contrib for your operating system.

note

This integration uses OpenTelemetry Collector Contrib, not the OpenTelemetry Collector Core.

Create a config.yaml file with the following content:

receivers:
otlp:
protocols:
http:
endpoint: "0.0.0.0:4318"

processors:
batch:
tail_sampling:
policies:
[
{
name: policy-errors,
type: status_code,
status_code: {status_codes: [ERROR]}
},
{
name: policy-slow,
type: latency,
latency: {threshold_ms: 1000}
},
{
name: policy-random-ok,
type: probabilistic,
probabilistic: {sampling_percentage: 10}
}
]

exporters:
logzio/traces:
account_token: <<TRACING-SHIPPING-TOKEN>>
region: <<LOGZIO_ACCOUNT_REGION_CODE>>
headers:
user-agent: logzio-opentelemetry-traces
logzio/logs:
account_token: <<LOG-SHIPPING-TOKEN>>
region: <<LOGZIO_ACCOUNT_REGION_CODE>>
headers:
user-agent: logzio-opentelemetry-logs
prometheusremotewrite/logzio:
endpoint: https://<<LISTENER-HOST>>:8053
headers:
Authorization: Bearer <<PROMETHEUS-METRICS-SHIPPING-TOKEN>>
user-agent: logzio-opentelemetry-metrics
target_info:
enabled: false

service:
pipelines:
traces:
receivers: [otlp]
processors: [tail_sampling, batch]
exporters: [logzio/traces]
logs:
receivers: [otlp]
processors: [batch]
exporters: [logzio/logs]
metrics:
receivers: [otlp]
processors: [batch]
exporters: [prometheusremotewrite/logzio]
  • Replace <<TRACING-SHIPPING-TOKEN>> with the token of the account you want to ship to.
  • Replace <<LOGZIO_ACCOUNT_REGION_CODE>> with the applicable region code.
  • Replace <<LOG-SHIPPING-TOKEN>> with the log shipping token of the account you want to ship to.
  • Replace <<LISTENER-HOST>> with the Logz.io listener URL for your region.
  • Replace <<PROMETHEUS-METRICS-SHIPPING-TOKEN>> with a token for the metrics account you want to ship to.
tip

Not every OpenLLMetry SDK emits all three signals. Check your SDK's guide and the Traceloop configuration options for what it exports, and remove any pipeline you don't need.

Tail sampling​

tail_sampling defines which traces to sample after all spans in a request are completed. By default, it collects all traces with an error span, traces slower than 1000 ms, and 10% of all other traces.

Additional policy configurations can be added to the processor. For more details, refer to the OpenTelemetry Documentation.

The configurable parameters in the Logz.io default configuration are:

ParameterDescriptionDefault
threshold_msThreshold for the span latency - traces slower than this value will be included.1000
sampling_percentagePercentage of traces to sample using the probabilistic policy.10

Start the collector​

Run the following command:

<path/to>/otelcol-contrib --config ./config.yaml
  • Replace <path/to> with the path to the directory where you downloaded the collector.

To run the collector in Docker instead, mount the configuration file:

docker run \
-p 4318:4318 \
-v <PATH-TO>/config.yaml:/etc/otelcol-contrib/config.yaml \
otel/opentelemetry-collector-contrib:<VERSION>
  • Replace <PATH-TO> with the path to the config.yaml file on your system.
  • Replace <VERSION> with the collector version to run (see available versions).
note

When running the OTEL collector in a Docker container, your application should run in separate containers on the same host network. Ensure all containers share the same network. Using Docker Compose ensures that all containers, including the OTEL collector, share the same network configuration automatically.

View your data in Logz.io​

Run your LLM application to generate some data, then give it time to process:

  • Traces appear in your Tracing dashboard. Each LLM call is a span, with the model, prompt, completion and token usage as span attributes.
  • Metrics appear in your Metrics dashboard, under metric names starting with gen_ai_, llm_ or db_.
  • Logs appear in Explore.