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
4318available on the collector host
Instrument your application
Follow the Traceloop installation guide for your language:
| Language | Guide |
|---|---|
| Python | Getting started with Python |
| Node.js | Getting started with Node.js |
| Next.js | Getting started with Next.js |
| Go | Getting started with Go |
| Ruby | Getting 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 examplelocalhost. - The service name shown in Logz.io comes from the SDK's
app_name(appNamein 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.
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.
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:
| Parameter | Description | Default |
|---|---|---|
| threshold_ms | Threshold for the span latency - traces slower than this value will be included. | 1000 |
| sampling_percentage | Percentage 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 theconfig.yamlfile on your system. - Replace
<VERSION>with the collector version to run (see available versions).
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: