# OpenTelemetry Collector for the Scrabble contour. Receives OTLP/gRPC from the
# three services (backend, gateway, connector — pkg/telemetry exports OTLP only),
# fans metrics out to a Prometheus scrape endpoint and traces to Tempo.
receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
  # Per-container resource metrics (CPU / memory / network) read straight from the
  # Docker API. This replaces cAdvisor, which on the contour host resolves only the
  # root cgroup (its /var/lib/docker is a separate XFS mount), and works the same in
  # prod. The collector reaches the socket via group_add in docker-compose.yml.
  # collection_interval matches Prometheus' 30s scrape. container.cpu.utilization is a
  # gauge where 100 == one core (it mirrors `docker stats` CPU%).
  docker_stats:
    endpoint: unix:///var/run/docker.sock
    # The receiver defaults to Docker API 1.25, but the daemon's minimum is 1.40
    # (server speaks up to 1.54); pin a version both the receiver's client and the
    # daemon accept, else the receiver fails to start ("client version too old").
    api_version: "1.44"
    collection_interval: 30s
    metrics:
      container.cpu.utilization:
        enabled: true

processors:
  batch: {}

exporters:
  # Exposes the collected metrics for Prometheus to scrape (otelcol:9464/metrics).
  # add_metric_suffixes:false keeps the instrument names verbatim (no _seconds /
  # _total unit/type suffixes) so the dashboards' PromQL matches the names defined
  # in code; resource_to_telemetry_conversion promotes service.name to a label.
  prometheus:
    endpoint: 0.0.0.0:9464
    add_metric_suffixes: false
    resource_to_telemetry_conversion:
      enabled: true
  # Forwards traces to Tempo's OTLP ingest.
  otlp/tempo:
    endpoint: tempo:4317
    tls:
      insecure: true

service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [batch]
      exporters: [otlp/tempo]
    metrics:
      receivers: [otlp, docker_stats]
      processors: [batch]
      exporters: [prometheus]
