Skip to main content
Connect OpenLLMetry to Elastic APM to visualize LLM traces in Kibana’s native APM interface. This integration uses OpenTelemetry Protocol (OTLP) to route traces from your application through an OpenTelemetry Collector to Elastic APM Server.
This integration requires an OpenTelemetry Collector to route traces between Traceloop OpenLLMetry client and Elastic APM Server. Elastic APM Server 8.x+ supports OTLP natively.

Quick Start

1

Install OpenLLMetry

Install the Traceloop SDK alongside your LLM provider client:
2

Configure OpenTelemetry Collector

Configure your OpenTelemetry Collector to receive traces from OpenLLMetry and forward them to APM Server.Create an otel-collector-config.yaml file:
In production, enable TLS and use APM Server secret tokens for authentication. Set tls.insecure: false and configure headers: Authorization: Bearer <token>.
3

Initialize Traceloop

Import and initialize Traceloop before any LLM imports:
The app_name parameter sets the service name visible in Kibana APM’s service list.
4

View Traces in Kibana

Navigate to Kibana’s APM interface:
  1. Open Kibana at http://localhost:5601
  2. Go to Observability → APM → Services
  3. Click on your service name (e.g., your-service-name)
  4. View transactions and trace timelines with full LLM metadata
Each LLM call appears as a span containing:
  • Model name (gen_ai.request.model)
  • Token usage (gen_ai.usage.input_tokens, gen_ai.usage.output_tokens)
  • Prompts and completions (configurable)
  • Request duration and latency

Environment Variables

Configure OpenLLMetry behavior using environment variables:
Set TRACELOOP_TRACE_CONTENT=false in production to prevent logging sensitive prompt content.

Using Workflow Decorators

For complex applications with multiple steps, use workflow decorators to create hierarchical traces:
In Kibana APM, you’ll see:
  • recipe_workflow.workflow as the parent transaction
  • generate_recipe.task as a child span
  • openai.chat.completions as the LLM API span with full metadata

Example Trace Visualization

Trace View

Trace Details

Captured Metadata

OpenLLMetry automatically captures these attributes in each LLM span: Request Attributes:
  • gen_ai.request.model - Model identifier
  • gen_ai.request.temperature - Sampling temperature
  • gen_ai.system - Provider name (OpenAI, Anthropic, etc.)
Response Attributes:
  • gen_ai.response.model - Actual model used
  • gen_ai.response.id - Unique response identifier
  • gen_ai.response.finish_reason - Completion reason
Token Usage:
  • gen_ai.usage.input_tokens - Input token count
  • gen_ai.usage.output_tokens - Output token count
  • llm.usage.total_tokens - Total tokens
Content (if enabled):
  • gen_ai.prompt.{N}.content - Prompt messages
  • gen_ai.completion.{N}.content - Generated completions

Production Considerations

Disable prompt/completion logging in production:
This prevents sensitive data from being stored in Elasticsearch.

Resources