Menu
Documentationbreadcrumb arrow OpenTelemetrybreadcrumb arrow Instrument an application

Instrument an application with OpenTelemetry

Instrumentation adds code to your application to collect telemetry data. This guide helps you set up OpenTelemetry instrumentation for your application.

Goal

Add instrumentation to your application to collect metrics, logs, and traces. Send this telemetry data to Grafana Cloud Application Observability or a self-managed backend.

Prerequisites

  • Access to code: You can modify or deploy your application code
  • Supported language: Your application uses Java, .NET, JavaScript, Python, PHP, Go, or another language supported by OpenTelemetry
  • Data destination: You have access to Grafana Cloud or self-managed Loki, Mimir, or Tempo

Note

For Kubernetes deployments, you don’t need direct code access if you use the OpenTelemetry Operator.

Instrumentation methods

Choose from the following instrumentation approaches:

Grafana distributions: OpenTelemetry SDKs from Grafana with additional features

Upstream distributions: OpenTelemetry SDKs maintained by the community

Grafana Beyla: Auto-instrument applications using eBPF technology

  • Grafana Beyla documentation
  • Works with all languages and frameworks
  • Requires no code changes
  • Requires Linux with Kernel 5.8 or higher with BPF Type Format (BTF) enabled

OpenTelemetry Operator: For Kubernetes deployments

Grafana Labs recommends that you set up OpenTelemetry components, including instrumentation and an OpenTelemetry Collector distribution, using one of the Grafana Cloud setup guides.

These opinionated guides make it easy to get started. They include all the binaries, configuration, and connection parameters you need to set up OpenTelemetry for Grafana Cloud.

Comparison of instrumentation methods

MethodCode changesLanguage supportUse case
Grafana OpenTelemetry JavaNot required (JVM agent)JavaOffers advanced instrumentation features and Grafana support.
Grafana OpenTelemetry .NETRequired.NETOffers advanced instrumentation features and Grafana support.
Upstream OpenTelemetry SDKsRequiredMultiple languagesProvides standard instrumentation with community support.
Grafana BeylaNot requiredAny languageEnables quick setup for any language, supports legacy applications, and requires Linux kernel 5.8+ with BTF enabled.
OpenTelemetry OperatorNot requiredMultiple languagesManages and injects instrumentation in Kubernetes deployments.

Next steps

After instrumenting your application, you need to configure your data pipeline:

  1. Set up an OpenTelemetry Collector distribution to process and forward telemetry data, or
  2. Send OTLP formatted telemetry data directly to a backend without using an OpenTelemetry Collector

When your data pipeline is configured, you can:

  • Create dashboards in Grafana to visualize your application metrics
  • Set up alerts for performance issues and anomalies
  • Use Explore to investigate traces and logs
  • Analyze application performance with Grafana Application Observability