DevLearn
Back to Platform & Architecture
platform

OpenTelemetry

Unified traces, metrics, and logs for cloud-native observability

OpenTelemetry — Overview

Unified traces, metrics, and logs for cloud-native observability

OpenTelemetry (OTel) provides vendor-neutral instrumentation for distributed tracing, metrics, and logs. Auto-instrumentation for Spring Boot, manual spans for payment flows, export to Jaeger/Tempo/Prometheus via OTLP collector.

// Spring Boot 3 — OpenTelemetry
// build.gradle: io.opentelemetry.instrumentation:opentelemetry-spring-boot-starter

// application.yml
management:
  otlp:
    tracing:
      endpoint: http://otel-collector:4318/v1/traces

// Manual span for payment trace
@Autowired Tracer tracer;

public PaymentResult pay(PaymentRequest req) {
  Span span = tracer.spanBuilder("payment.authorize").startSpan();
  try (Scope scope = span.makeCurrent()) {
    span.setAttribute("payment.amount", req.getAmount());
    span.setAttribute("merchant.id", req.getMerchantId());
    return acquirer.authorize(req);
  } finally {
    span.end();
  }
}
Tip: Propagate trace context (traceparent header) across Kafka — use OpenTelemetry Kafka instrumentation.