Skip to content

Production-ready OpenTelemetry instrumentation examples for Go, Python, Node.js, Ruby, Java, PHP, and more. Send traces, metrics, and logs to Last9 or any OTLP-compatible backend.

License

Notifications You must be signed in to change notification settings

last9/opentelemetry-examples

Repository files navigation

OpenTelemetry Examples

License: MIT OpenTelemetry Last9 PRs Welcome

Production-ready examples for instrumenting applications with OpenTelemetry and sending telemetry data (traces, metrics, and logs) to Last9 or any OTLP-compatible observability platform.

Why This Repository?

Getting OpenTelemetry instrumentation right can be tricky. This repository provides:

  • Copy-paste ready examples - Each example is a complete, working application
  • Real-world patterns - Covers HTTP servers, databases, message queues, external APIs, and more
  • Multiple languages - Go, Python, JavaScript/Node.js, Ruby, Java, PHP, .NET, and Elixir
  • Cloud-native deployments - AWS (ECS, Lambda, EC2), GCP (Cloud Run), Kubernetes
  • Collector configurations - Ready-to-use OTel Collector configs for various use cases

Quick Start

  1. Get your OTLP credentials from Last9 (or use any OTLP-compatible backend)

  2. Set environment variables:

    export OTEL_EXPORTER_OTLP_ENDPOINT="https://otlp.last9.io"
    export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Basic <YOUR_AUTH_TOKEN>"
  3. Browse the language directories below and follow the README in each example

Examples by Language

Go (go/)

Framework Description Signals
Gin Web framework with middleware instrumentation Traces, Metrics
Gin + Redis Gin with Redis client tracing Traces, Metrics
Chi Lightweight router instrumentation Traces, Metrics
Gorilla Mux Classic router with OTel middleware Traces
net/http Standard library HTTP server Traces
FastHTTP High-performance HTTP framework Traces
Beego Full-featured web framework Traces
Iris Fast web framework Traces
gRPC gRPC server and client instrumentation Traces
gRPC-Gateway REST to gRPC gateway with tracing Traces
Kafka (Sarama) Kafka producer/consumer with Sarama Traces
Kafka (Confluent) Kafka with Confluent client Traces
SQLX SQL database instrumentation Traces
PGX PostgreSQL driver tracing Traces
eBPF eBPF-based instrumentation Traces

Python (python/)

Framework Description Signals
FastAPI Modern async API framework Traces, Metrics
FastAPI + Uvicorn Production ASGI deployment Traces, Metrics
Flask Lightweight WSGI framework Traces
Django Full-featured web framework Traces
Sanic Async web framework Traces
GCP Cloud Functions Serverless function instrumentation Traces

JavaScript / Node.js (javascript/)

Framework Description Signals
Express Classic Node.js framework (JS & TS) Traces, Metrics
Fastify Fast and low overhead framework Traces
NestJS Enterprise Node.js framework Traces
Next.js React framework with SSR Traces
Koa Expressive middleware framework Traces
Hono Ultrafast web framework Traces
Polka Micro web server Traces
GraphQL GraphQL server instrumentation Traces
Sails MVC framework Traces
Winston Logging library integration Logs
Cloudflare Workers Edge runtime with itty-router Traces

Ruby (ruby/)

Framework Description Signals
Rails API Modern Rails API-only app Traces
Rails 5.2 Legacy Rails support Traces
Sinatra Lightweight DSL framework Traces
Roda Routing tree framework Traces
Karafka Kafka for Ruby Traces
File Logs Log file collection Logs

Java (java/)

Framework Description Signals
Spring Boot Popular Java framework Traces, Metrics
Tomcat Servlet container Traces

PHP (php/)

Framework Description Signals
Laravel Popular PHP framework Traces
WordPress Plugin WordPress instrumentation Traces
Core PHP 7.3 Vanilla PHP instrumentation Traces
Core PHP 8 Modern PHP instrumentation Traces

Other Languages

Directory Language Framework Description
dotnet/ .NET ASP.NET Core Web API example
elixir/ Elixir Phoenix Functional web framework

Frontend

Directory Framework Description
react/ React SPA instrumentation
angular/ Angular SPA instrumentation

Cloud & Infrastructure

AWS (aws/)

Example Description
ECS Fargate Container deployment with OTel sidecar
Lambda (Go) Serverless Go function
EC2 Virtual machine deployment
RDS PostgreSQL + ECS Database monitoring with CDK/CloudFormation

GCP (gcp/)

Example Description
Cloud Run Serverless containers (Go, Python, Node.js, Java)

OpenTelemetry Collector (otel-collector/)

Pre-configured collector setups for common use cases:

Configuration Description
Kubernetes Operator K8s native deployment
OTel Operator Auto-instrumentation for K8s
Fluent Bit Log collection pipeline
Logstash ELK stack integration
FireLens AWS FireLens for ECS
Apache Server Apache httpd metrics
Nginx Metrics Nginx server metrics
MariaDB Database metrics
Oracle Oracle DB monitoring
YACE Metrics AWS CloudWatch exporter

Migration Guides

Directory Description
datadog-k8s-operator/ Migrate from Datadog Agent to OpenTelemetry

Documentation

Last9 Integration Guides

Getting Started

Go Frameworks

Python Frameworks

JavaScript/Node.js Frameworks

Ruby Frameworks

Java Frameworks

Other Languages

Cloud & Infrastructure

Messaging & Databases

External Resources

Works With Any OTLP Backend

While these examples are configured for Last9, they work with any OTLP-compatible backend:

  • Grafana Cloud / Tempo / Mimir
  • Honeycomb
  • Jaeger
  • Zipkin
  • Datadog
  • New Relic
  • Dynatrace
  • Splunk
  • And many more...

Just update the OTEL_EXPORTER_OTLP_ENDPOINT and authentication headers for your backend.

Contributing

We welcome contributions! Whether it's adding new framework examples, improving documentation, or fixing bugs - PRs are appreciated.

License

This project is licensed under the MIT License - see the LICENSE file for details.


Last9
Built with love by Last9
High cardinality observability, simplified.

About

Production-ready OpenTelemetry instrumentation examples for Go, Python, Node.js, Ruby, Java, PHP, and more. Send traces, metrics, and logs to Last9 or any OTLP-compatible backend.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 7