# Both services build from the same Dockerfile and export to the same # collector; only the service name and its own env differ. x-otel-env: &otel OTEL_RESOURCE_ATTRIBUTES: service.version=0.0.1 OTEL_EXPORTER_OTLP_ENDPOINT: http://otel-collector:4318 services: postgres: image: postgres:16-alpine environment: POSTGRES_USER: coffee POSTGRES_PASSWORD: coffee POSTGRES_DB: coffee healthcheck: test: ["CMD-SHELL", "pg_isready -U coffee"] interval: 2s timeout: 2s retries: 15 otel-collector: image: otel/opentelemetry-collector-contrib:latest command: ["--config=/etc/otelcol/config.yaml"] volumes: - ./otel-collector-config.yaml:/etc/otelcol/config.yaml:ro environment: MONOSCOPE_OTLP_ENDPOINT: ${MONOSCOPE_OTLP_ENDPOINT} MONOSCOPE_API_KEY: ${MONOSCOPE_API_KEY} ports: - "4317:4317" - "4318:4318" barista: build: {context: ., args: {SERVICE: barista}} environment: <<: *otel OTEL_SERVICE_NAME: barista JAM_RATE: "0.25" # crank to 0.50 live for dashboard drama FAIL_RATE: "0.10" JAM_MS: "3000" depends_on: [otel-collector] orders: build: {context: ., args: {SERVICE: orders}} environment: <<: *otel OTEL_SERVICE_NAME: orders DATABASE_URL: postgres://coffee:coffee@postgres:5432/coffee?sslmode=disable BARISTA_URL: http://barista:8081 ports: - "${ORDERS_PORT:-8080}:8080" depends_on: postgres: condition: service_healthy barista: condition: service_started otel-collector: condition: service_started # Optional load generator: docker compose --profile load up loadgen: image: curlimages/curl:latest profiles: ["load"] entrypoint: ["/bin/sh", "/loadgen.sh"] volumes: - ./loadgen.sh:/loadgen.sh:ro depends_on: [orders]