1. Instrumenting #
OTel or EDOT SDKs.
Automatic instrumentation #
# Java : agent EDOT (ou agent OpenTelemetry Java)
export OTEL_SERVICE_NAME=checkout
export OTEL_EXPORTER_OTLP_ENDPOINT=http://collector:4318
export OTEL_RESOURCE_ATTRIBUTES=deployment.environment=prod,service.version=1.4.2
java -javaagent:elastic-otel-javaagent.jar -jar checkout.jarGood to know: EDOT SDKs are distributions of OpenTelemetry SDKs with defaults tuned for Elastic; standard OpenTelemetry SDKs work too.
2. In Kibana #
Services, transactions, map.
APM views #
With the EDOT Collector (Elastic's APM connector and processor), Kibana shows each service's latency, throughput, error rate, dependencies and the service map. A trace opens as a waterfall with its spans.
FROM traces-*.otel-*
| WHERE resource.attributes.service.name == "checkout" AND status.code == "Error"
| KEEP @timestamp, trace_id, name, duration
| SORT @timestamp DESC | LIMIT 203. Sampling and correlating #
Keeping what matters.
Tail sampling #
processors:
tail_sampling:
decision_wait: 10s
policies:
- { name: erreurs, type: status_code, status_code: { status_codes: [ERROR] } }
- { name: lentes, type: latency, latency: { threshold_ms: 800 } }
- { name: echantillon, type: probabilistic, probabilistic: { sampling_percentage: 10 } }Common mistake: Sampling in the SDKs AND in the Collector unknowingly: you keep 10% of 10%, and APM metrics computed on the remaining spans become wrong. Compute APM metrics before sampling.
Linking logs and traces #
When the SDK injects trace_id and span_id into logs (OTel appenders for log4j, logback, Python logging), Kibana jumps from a trace to its logs and back.
