MyObservability

🟦 Automatic Instrumentation

Without being required to modify the source code you can collect telemetry from an application using automatic instrumentation.

Zero-code instrumentation adds the OpenTelemetry API and SDK capabilities to your application typically as an agent or agent-like installation.

Additionally, zero-code instrumentation lets you configure the Instrumentation Libraries and exporters loaded.

You can configure zero-code instrumentation through environment variables and other language-specific mechanisms, such as system properties or arguments passed to initialization methods. To get started, you only need a service name configured so that you can identify the service in the observability backend of your choice.

⚠️ Note: Some language do not support auto instrumentation.

Other configuration options are available, including:


🟩 Common options


🧱 Ex:Java Based Application instrumentation

Step:1 - Download OpenTelemetry Java Agent

opentelemetry-javaagent.jar from Releases of the Opentelemetry-java-instrumentation repository and place the JAR in your preferred directory. The JAR file contains the agent and instrumentation libraries.

Java Agent Location: OpenTelemetry Java Agent

Step:2 - Configuring the agent

You can pass configuration properties via the -D flag.

java -javaagent:path/to/opentelemetry-javaagent.jar \
     -Dotel.service.name=your-service-name \
     -Dotel.traces.exporter=zipkin \
     -jar myapp.jar

————————- OR —————————-

You can also environment variables to configure the agent:

  1. Configure Environment variable
export OTEL_LOGS_EXPORTER="none"
export OTEL_METRICS_EXPORTER="none"
export OTEL_TRACES_EXPORTER="otlp"
export OTEL_SERVICE_NAME=your-service-name \
export OTEL_TRACES_EXPORTER=zipkin
  1. Configure agent: java -javaagent:path/to/opentelemetry-javaagent.jar -jar myapp.jar

🧱 Ex: Python based application instrumentation

Step:1 - Download OpenTelemetry agent through pip

pip install opentelemetry-distro opentelemetry-exporter-otlp

Step:2 - Auto instrument using following command

opentelemetry-bootstrap --action=install

Step-3: Export traces (Ex: Splunk)

opentelemetry-instrument \
    --traces_exporter console,otlp \
    --metrics_exporter console \
    --service_name your-service-name \
    --exporter_otlp_endpoint 0.0.0.0:4317 \
    python myapp.py

————————- OR —————————-

export OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.<your-realm>.signalfx.com/v2/trace
export OTEL_EXPORTER_OTLP_HEADERS="X-SF-TOKEN=<your-access-token>"
export OTEL_TRACES_EXPORTER=otlp
export OTEL_METRICS_EXPORTER=none 

opentelemetry-instrument python myapp.py


🧱 Ex: JavaScript application instrumentation

Step-1: Install appropriate package

npm install --save @opentelemetry/api
npm install --save @opentelemetry/auto-instrumentations-node

Step-2: Configure the module

env OTEL_TRACES_EXPORTER=otlp OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=your-endpoint node --require @opentelemetry/auto-instrumentations-node/register app.js

————————- OR —————————-

export OTEL_TRACES_EXPORTER="otlp"
export OTEL_EXPORTER_OTLP_ENDPOINT="your-endpoint"
export OTEL_NODE_RESOURCE_DETECTORS="env,host,os"
export OTEL_SERVICE_NAME="your-service-name"
export NODE_OPTIONS="--require @opentelemetry/auto-instrumentations-node/register"
node app.js

✅ Next Chapter: Sampling

✅ Main Page: Click Here