DEV Community

Alex Spinov
Alex Spinov

Posted on

OpenTelemetry Has a Free Observability Standard — Traces, Metrics, and Logs Without Vendor Lock-in

Datadog costs $23/host/month. New Relic's free tier ends fast. OpenTelemetry sends your data to ANY backend — switch providers without changing your code.

What is OpenTelemetry?

OpenTelemetry (OTel) is a vendor-neutral observability standard. It provides APIs, SDKs, and a collector for traces, metrics, and logs. Your instrumentation stays the same — only the backend changes.

Why OpenTelemetry Is the Standard

1. Instrument Once, Export Anywhere

import { NodeSDK } from '@opentelemetry/sdk-node';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';

const sdk = new NodeSDK({
  traceExporter: new OTLPTraceExporter({
    url: 'http://localhost:4318/v1/traces',
    // Switch backends by changing this URL:
    // Grafana Tempo, Jaeger, Zipkin, Datadog, Honeycomb, etc.
  }),
  instrumentations: [getNodeAutoInstrumentations()],
});

sdk.start();
Enter fullscreen mode Exit fullscreen mode

2. Auto-Instrumentation

npm install @opentelemetry/auto-instrumentations-node
Enter fullscreen mode Exit fullscreen mode

This ONE package automatically instruments:

  • HTTP/HTTPS requests
  • Express/Fastify/Koa routes
  • PostgreSQL/MySQL queries
  • Redis commands
  • MongoDB operations
  • gRPC calls
  • AWS SDK calls

Zero code changes in your application.

3. Custom Spans

import { trace } from '@opentelemetry/api';

const tracer = trace.getTracer('my-service');

async function processOrder(orderId: string) {
  return tracer.startActiveSpan('processOrder', async (span) => {
    span.setAttribute('order.id', orderId);

    const items = await tracer.startActiveSpan('fetchItems', async (childSpan) => {
      const result = await db.query('SELECT * FROM items WHERE order_id = $1', [orderId]);
      childSpan.setAttribute('items.count', result.length);
      childSpan.end();
      return result;
    });

    await tracer.startActiveSpan('chargePayment', async (childSpan) => {
      await stripe.charges.create({ amount: calculateTotal(items) });
      childSpan.end();
    });

    span.setStatus({ code: SpanStatusCode.OK });
    span.end();
  });
}
Enter fullscreen mode Exit fullscreen mode

4. Metrics

import { metrics } from '@opentelemetry/api';

const meter = metrics.getMeter('my-service');

const requestCounter = meter.createCounter('http_requests_total', {
  description: 'Total HTTP requests',
});

const latencyHistogram = meter.createHistogram('http_request_duration_ms', {
  description: 'HTTP request latency',
});

app.use((req, res, next) => {
  const start = Date.now();
  res.on('finish', () => {
    requestCounter.add(1, { method: req.method, path: req.path, status: res.statusCode });
    latencyHistogram.record(Date.now() - start, { method: req.method });
  });
  next();
});
Enter fullscreen mode Exit fullscreen mode

5. The Collector (Route Data Anywhere)

# otel-collector-config.yaml
receivers:
  otlp:
    protocols:
      http:
        endpoint: 0.0.0.0:4318

processors:
  batch:
    timeout: 5s

exporters:
  otlp/jaeger:
    endpoint: jaeger:4317
  prometheus:
    endpoint: 0.0.0.0:8889

service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [batch]
      exporters: [otlp/jaeger]
    metrics:
      receivers: [otlp]
      processors: [batch]
      exporters: [prometheus]
Enter fullscreen mode Exit fullscreen mode

Free Backends

Backend Type Free Tier
Jaeger Traces Self-hosted (free)
Grafana Tempo Traces 50GB/month
Zipkin Traces Self-hosted (free)
Prometheus Metrics Self-hosted (free)
Grafana Loki Logs 50GB/month

Getting Started

npm install @opentelemetry/sdk-node \
  @opentelemetry/auto-instrumentations-node \
  @opentelemetry/exporter-trace-otlp-http
Enter fullscreen mode Exit fullscreen mode

The Bottom Line

OpenTelemetry is the CNCF standard for observability. Instrument once, switch backends freely. No vendor lock-in, no $23/host/month surprise bills.


Need data tools? I build scraping solutions. Check my Apify actors or email spinov001@gmail.com.

Top comments (0)