version: "2"
services:

  # Jaeger
  jaeger-all-in-one:
    image: jaegertracing/all-in-one:latest
    ports:
      - "16686:16686"
      - "14268"
      - "14250"

  # Zipkin
  zipkin-all-in-one:
    image: openzipkin/zipkin:latest
    ports:
      - "9411:9411"

  # Collector
  otel-collector:
    image: ${OTELCOL_IMG}
    command: ["--config=/etc/otel-collector-config.yaml", "${OTELCOL_ARGS}"]
    volumes:
      - ./otel-collector-config.yaml:/etc/otel-collector-config.yaml
    ports:
      - "1888:1888"   # pprof extension
      - "8888:8888"   # Prometheus metrics exposed by the collector
      - "8889:8889"   # Prometheus exporter metrics
      - "13133:13133" # health_check extension
      - "4317"        # OTLP gRPC receiver
      - "55670:55679" # zpages extension
    depends_on:
      - jaeger-all-in-one
      - zipkin-all-in-one

  # Agent
  otel-agent:
    image: ${OTELCOL_IMG}
    command: ["--config=/etc/otel-agent-config.yaml", "${OTELCOL_ARGS}"]
    volumes:
      - ./otel-agent-config.yaml:/etc/otel-agent-config.yaml
    ports:
      - "8887:8888"   # Prometheus metrics exposed by the agent
      - "14250"       # Jaeger grpc receiver
      - "14268"       # Jaeger http thrift receiver
      - "55678"       # OpenCensus receiver
      - "4317"        # OTLP gRPC receiver
      - "9411"        # Zipkin receiver
      - "1777:1777"   # pprof extension
      - "55679:55679" # zpages extension
      - "13133"       # health_check
    depends_on:
      - otel-collector

  # Synthetic load generators
  jaeger-emitter:
    image: omnition/synthetic-load-generator:1.0.25
    environment:
      - JAEGER_COLLECTOR_URL=http://otel-agent:14268
    depends_on:
      - otel-agent

  zipkin-emitter:
    image: omnition/synthetic-load-generator:1.0.25
    environment:
      - ZIPKINV2_JSON_URL=http://otel-agent:9411/api/v2/spans
    depends_on:
      - otel-agent

  metrics-load-generator:
    build:
      dockerfile: $PWD/app/Dockerfile
      context: ./app
    environment:
      - OTEL_AGENT_ENDPOINT=otel-agent:4317
    depends_on:
      - otel-agent

  prometheus:
    container_name: prometheus
    image: prom/prometheus:latest
    volumes:
      - ./prometheus.yaml:/etc/prometheus/prometheus.yml
    ports:
      - "9090:9090"
