पाठ 7 / 25
Zero-Code Instrumentation
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.
Starting services with zero-code instrumentation
Commands follow the official getting-started guides; check them for your versions.
# 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.jarStart 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.
त्वरित जाँच: Which environment variable sets the service name for OpenTelemetry SDKs?
- OTEL_SERVICE_NAME
- SERVICE
- OTEL_NAME_OF_APP
- APP_TRACE_ID
Answer
OTEL_SERVICE_NAME — A standard SDK environment variable.