-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompose.yaml
More file actions
112 lines (107 loc) · 3.43 KB
/
Copy pathcompose.yaml
File metadata and controls
112 lines (107 loc) · 3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
services:
app:
build:
context: ./app
dockerfile: Dockerfile
container_name: litestar-app
env_file:
- path: .env
required: false
ports:
- "8080:8080"
environment:
- DATABASE_URL=postgresql+asyncpg://${DB_USERNAME:-postgres}:${DB_PASSWORD:?DB_PASSWORD is required}@postgres:5432/${DB_NAME:-articles}
- NOTIFY_URL=http://notify:8081/notify
- OTEL_SERVICE_NAME=litestar-postgres-app
- OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318
- OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
- OTEL_RESOURCE_ATTRIBUTES=${OTEL_RESOURCE_ATTRIBUTES:-deployment.environment=development,service.version=1.0.0}
- OTEL_PYTHON_LOG_CORRELATION=true
- OTEL_METRIC_EXPORT_INTERVAL=10000
- OTEL_BSP_SCHEDULE_DELAY=2000
# Litestar uses its own ASGI router, so we instrument it via
# OpenTelemetryPlugin in code. Disable the generic ASGI auto-patch
# to make the choice explicit (and avoid double-handling).
- OTEL_PYTHON_DISABLED_INSTRUMENTATIONS=asgi
depends_on:
postgres:
condition: service_healthy
otel-collector:
condition: service_started
notify:
condition: service_healthy
networks:
- app-network
notify:
build:
context: ./notify
dockerfile: Dockerfile
container_name: litestar-notify
env_file:
- path: .env
required: false
ports:
- "8081:8081"
environment:
- OTEL_SERVICE_NAME=litestar-postgres-notify
- OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318
- OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
- OTEL_RESOURCE_ATTRIBUTES=${OTEL_RESOURCE_ATTRIBUTES:-deployment.environment=development,service.version=1.0.0}
- OTEL_PYTHON_LOG_CORRELATION=true
- OTEL_METRIC_EXPORT_INTERVAL=10000
- OTEL_BSP_SCHEDULE_DELAY=2000
- OTEL_PYTHON_DISABLED_INSTRUMENTATIONS=asgi
depends_on:
otel-collector:
condition: service_started
healthcheck:
test: ["CMD", "curl", "-fsS", "http://localhost:8081/health"]
interval: 5s
timeout: 3s
retries: 5
start_period: 10s
networks:
- app-network
postgres:
image: postgres:18-alpine
container_name: litestar-postgres
environment:
- POSTGRES_USER=${DB_USERNAME:-postgres}
- POSTGRES_PASSWORD=${DB_PASSWORD:?DB_PASSWORD is required}
- POSTGRES_DB=${DB_NAME:-articles}
ports:
- "5432:5432"
volumes:
- postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_USERNAME:-postgres} -d ${DB_NAME:-articles}"]
interval: 5s
timeout: 5s
retries: 5
networks:
- app-network
otel-collector:
image: otel/opentelemetry-collector-contrib:0.153.0
container_name: litestar-otel-collector
volumes:
- ./config/otel-config.yaml:/etc/otelcol-contrib/config.yaml
ports:
- "4317:4317" # OTLP gRPC
- "4318:4318" # OTLP HTTP
- "13133:13133" # health_check
env_file:
- path: .env
required: false
environment:
- SCOUT_ENDPOINT=${SCOUT_ENDPOINT:-http://localhost:4318}
- SCOUT_CLIENT_ID=${SCOUT_CLIENT_ID:-}
- SCOUT_CLIENT_SECRET=${SCOUT_CLIENT_SECRET:-}
- SCOUT_TOKEN_URL=${SCOUT_TOKEN_URL:-}
- SCOUT_ENVIRONMENT=${SCOUT_ENVIRONMENT:-development}
networks:
- app-network
volumes:
postgres-data:
networks:
app-network:
driver: bridge