# Zero-Code Instrumentation — OpenTelemetry

Source: https://www.skillbyai.com/en/opentelemetry/i-auto

> Agents and auto-instrumentation.

## Telemetry without code changes

Most languages offer **zero-code** (automatic) instrumentation that hooks into popular frameworks and libraries (HTTP servers and clients, database drivers, messaging) and creates spans and metrics automatically. Java uses a **Java agent** JAR; Python uses the `opentelemetry-instrument` wrapper; Node.js uses a register hook; .NET has an automatic instrumentation package. Configuration is mostly via standard **environment variables** such as `OTEL_SERVICE_NAME` and `OTEL_EXPORTER_OTLP_ENDPOINT`. On Kubernetes, the OpenTelemetry Operator can inject agents into pods.

## Zero-code first, manual where it matters

Automatic instrumentation covers frameworks and libraries; manual instrumentation adds business context.

![Three ideas: zero-code instrumentation, manual spans, resources and conventions.](assets/figures/opentelemetry/section-3-map.svg) — Figure 3.1 — Zero-code, manual spans and resources.

## Starting services with zero-code instrumentation

Commands follow the official getting-started guides; check them for your versions.

```bash
# Python
pip install opentelemetry-distro opentelemetry-exporter-otlp
opentelemetry-bootstrap -a install          # installs instrumentations for detected libraries
export OTEL_SERVICE_NAME=orders-api
export OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317
opentelemetry-instrument python app.py

# Java
export OTEL_SERVICE_NAME=payment-service
export OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318
java -javaagent:./opentelemetry-javaagent.jar -jar payment-service.jar
```

## Start with zero-code, then add detail

Automatic instrumentation gives a service map and latency breakdown on day one; add manual spans where business logic needs visibility.

**Quiz:** Which environment variable sets the service name for OpenTelemetry SDKs?

- [x] OTEL_SERVICE_NAME
- [ ] SERVICE
- [ ] OTEL_NAME_OF_APP
- [ ] APP_TRACE_ID

*Answer:* OTEL_SERVICE_NAME. A standard SDK environment variable.
