OpenGate/ Docs

Distributed Tracing (OTLP)

OpenGate IAM supports distributed tracing via OpenTelemetry (OTLP). Traces span all 10 microservices and export to Jaeger, Tempo, or any OTLP-compatible backend.

On this page


How Tracing Works

Browser Request
      │
      ▼
┌─────────────────────────────────┐
│ Gateway  traceId=abc123         │
│         spanId=span-001         │
└────────────────┬────────────────┘
                 │  Passes B3 / W3C headers
      ┌──────────┴───────────────────────┐
      ▼                                  ▼
┌──────────────┐                ┌──────────────┐
│ user-service │                │ realm-service│
│ spanId=002   │                │ spanId=003   │
└──────────────┘                └──────────────┘
      │                                  │
      └──────────────┬───────────────────┘
                     ▼
         ┌───────────────────────┐
         │  OTLP Collector       │
         │  (Jaeger / Tempo)     │
         └───────────────────────┘

Setup with Jaeger

docker-compose.tracing.ymlyaml
services:
jaeger:
  image: jaegertracing/all-in-one:1.55
  ports:
    - "16686:16686"   # Jaeger UI
    - "4317:4317"     # OTLP gRPC
    - "4318:4318"     # OTLP HTTP
  environment:
    COLLECTOR_OTLP_ENABLED: "true"

Open Jaeger UI at http://localhost:16686.


Spring Boot Configuration

Add the OpenTelemetry Spring Boot starter to each service:

build.gradle.ktskotlin
dependencies {
  implementation("io.micrometer:micrometer-tracing-bridge-otel")
  implementation("io.opentelemetry.instrumentation:opentelemetry-spring-boot-starter")
  implementation("io.opentelemetry:opentelemetry-exporter-otlp")
}
application.ymlyaml
management:
tracing:
  sampling:
    probability: 1.0    # 1.0 = 100% in dev, use 0.1 in prod

spring:
application:
  name: opengate-user-service

otel:
exporter:
  otlp:
    endpoint: http://localhost:4318
service:
  name: ${spring.application.name}
resource:
  attributes:
    deployment.environment: production

Trace Propagation

The gateway automatically propagates trace context using W3C Trace Context headers:

HeaderFormat
traceparent00-{traceId}-{spanId}-01
tracestateVendor-specific metadata

Logs automatically include traceId and spanId via MDC — correlate logs and traces in Grafana:

{
"timestamp": "2025-06-01T10:00:00Z",
"level": "INFO",
"logger": "io.opengate.iam.user.service.UserService",
"message": "User created: alice@example.com",
"traceId": "abc123def456",
"spanId": "span001",
"userId": "usr_abc123",
"realmId": "master"
}

Sampling in production

Use sampling.probability: 0.1 (10%) in production to reduce overhead. Increase to 1.0 temporarily for debugging.