How to implement OpenTelemetry in production
OpenTelemetry is the open standard for generating and sending logs, traces and metrics. This guide lays out the steps to take it to production without slowing your team down: what to instrument first, how to set up the Collector, and which mistakes to avoid.
The pieces, in two minutes
- SDK or auto-instrumentation agent: runs inside your application and generates the telemetry.
- OTLP: the protocol it travels over. gRPC uses port
4317and HTTP uses4318. - Collector: a separate process that receives, processes and forwards telemetry. It is built from receivers, processors and exporters.
- Semantic conventions: the standard attribute names (
service.name,http.response.status_code). They are what lets any platform understand your data. - Backend: where the data is stored and queried. OpenTelemetry doesn't include one: you choose it.
Step 1. Start with one service, using auto-instrumentation
Java, .NET, Python and Node.js have automatic instrumentation: you add an agent or a package at startup and get traces for HTTP calls, database calls and queues without touching the code. It's the fastest way to see value.
Pick a service on the path of an important flow, not the easiest one. Configuration goes in through environment variables, the same in every language:
export OTEL_SERVICE_NAME="checkout-api"
export OTEL_RESOURCE_ATTRIBUTES="deployment.environment.name=production,service.version=1.42.0"
export OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4318"
export OTEL_EXPORTER_OTLP_PROTOCOL="http/protobuf"Manual instrumentation comes later, and only where it adds value: the business steps that automatic instrumentation can't guess (an approved payment, an issued policy).
Step 2. Put a Collector in the middle
Applications can export straight to the backend, but in production it's better to have them talk to a nearby Collector. You get three things: retries and buffering if the destination stops responding, one place to filter or enrich, and the freedom to change destination without redeploying your applications.
A minimal, safe Collector for production:
receivers:
otlp:
protocols:
grpc: { endpoint: 0.0.0.0:4317 }
http: { endpoint: 0.0.0.0:4318 }
processors:
memory_limiter: # always first: keeps the Collector from running out of memory
check_interval: 1s
limit_percentage: 80
spike_limit_percentage: 20
resourcedetection: # adds host, cloud and Kubernetes to every item
detectors: [env, system]
batch: {} # always last: groups the sends
exporters:
otlphttp:
endpoint: https://ingest.oneglass.io
headers:
Authorization: "Api-Token ${env:ONEGLASS_INGEST_KEY}"
X-Tenant-ID: "${env:ONEGLASS_TENANT_ID}"
service:
pipelines:
traces: { receivers: [otlp], processors: [memory_limiter, resourcedetection, batch], exporters: [otlphttp] }
metrics: { receivers: [otlp], processors: [memory_limiter, resourcedetection, batch], exporters: [otlphttp] }
logs: { receivers: [otlp], processors: [memory_limiter, resourcedetection, batch], exporters: [otlphttp] }The exporter in the example points at OneGlass; with any other OTLP destination, only the endpoint and the headers change. The exact values for your workspace are in the quickstart.
Agent or gateway?
The two forms work together. An agent Collector on each host or node also collects log files and system metrics. A central gateway Collector receives from all the agents and is where you apply shared rules. To start, the agent alone is enough.
Step 3. Take care of resource attributes
The quality of everything downstream depends on a few well-set attributes:
service.name: required. Without it, everything shows up asunknown_service.service.version: so you can tell which version introduced a problem.deployment.environment.name: so production doesn't get mixed with testing.- Infrastructure ones (
host.name,k8s.namespace.name,k8s.pod.name): let the Collector add them, not each application.
Use the semantic convention names, and don't invent your own for things that already have one. That's what makes your data useful on any platform.
Step 4. Decide what to keep
In production, volume grows fast, and so does cost. Three levers, from simplest to finest:
- Filter noise in the Collector: health checks, debug logs, metrics nobody looks at.
- Sampling at the source (head sampling): the SDK decides when a request starts whether to record it. Cheap, but it can drop the very request that failed.
- Sampling at the end (tail sampling): a gateway Collector sees the whole trace and keeps every trace that had errors or was slow, plus a fraction of the rest.
Metrics aren't sampled. If they weigh too much, the problem is usually cardinality: an attribute with thousands of distinct values, such as a user ID.
Step 5. Logs: start with what you already have
You don't need to rewrite how your applications log. The Collector can read the log files that already exist and send them over OTLP. The jump in quality comes when the log carries the ID of the active trace: then you go from a slow trace to its logs in one click. Auto-instrumentation libraries add it on their own in most languages.
Common mistakes
- Forgetting
service.name. It's the number one cause of "I don't see my data". - Leaving out
memory_limiter. A traffic spike takes down the Collector, and all your telemetry with it. - Putting sensitive data in attributes. Passwords, tokens or personal data don't belong in telemetry. If they can slip in, mask them in the Collector.
- Instrumenting everything before looking at anything. One well-instrumented service that people use teaches you more than twenty half-done ones.
- Configuring each Collector by hand. With ten it's annoying; with a hundred it's impossible. The OpAMP protocol exists to manage them remotely.
With OneGlass
OneGlass is an observability platform built natively on OpenTelemetry, made in Argentina. It receives standard OTLP, so everything in this guide applies as is. If you don't want to maintain Collectors by hand, OneGlass Pipelines manages them remotely over OpAMP, and the OneGlass agent installs with one line.