Skip to content

Commit eb60912

Browse files
committed
feat: allow using statsd server to export metric
1 parent e88ce30 commit eb60912

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -- coding: UTF-8 --
22
import os
3+
import socket
34

45
worker_class = "gevent"
56
workers = int(os.getenv("WORKERS", "4"))
@@ -9,3 +10,10 @@
910
loglevel = os.environ.get("LOG_LEVEL", "info")
1011
errorlog = os.environ.get("ERROR_LOG", "-")
1112
accesslog = os.environ.get("ACCESS_LOG", "-")
13+
14+
15+
_statsd_host = os.getenv("STATSD_HOST")
16+
_statsd_port = os.getenv("STATSD_PORT")
17+
if _statsd_host and _statsd_port:
18+
statsd_host = f"{_statsd_host}:{_statsd_port}"
19+
statsd_prefix = socket.gethostname()

docker/docker-compose.example.yaml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,38 @@ services:
77
- POSTGRES_DB=sentry
88
- POSTGRES_USER=sentry
99
- POSTGRES_PASSWORD=sentry
10+
profiles:
11+
- data
1012
ports:
1113
- 5432:5432
1214
volumes:
1315
- "controllerdata:/var/lib/postgresql/data"
1416

1517
redis:
1618
image: 'bitnami/redis:latest'
19+
profiles:
20+
- data
1721
environment:
1822
- ALLOW_EMPTY_PASSWORD=yes
1923
ports:
2024
- 6379:6379
2125

2226
static:
23-
image: spklabs/sentry-dynamic-sampling-controller-static:latest
27+
image: spklabs/sentry-dynamic-sampling-controller-static:alpha
2428
ports:
2529
- 8081:80
30+
profiles:
31+
- app
2632
app:
27-
image: spklabs/sentry-dynamic-sampling-controller:latest
33+
image: spklabs/sentry-dynamic-sampling-controller:alpha
2834
depends_on:
2935
- postgres
3036
- redis
3137
- static
3238
ports:
3339
- 8080:8000
40+
profiles:
41+
- app
3442
environment:
3543
- ENV=debug
3644
- SECRET_KEY="very_secret"
@@ -57,5 +65,17 @@ services:
5765
- OIDC_RP_SIGN_ALGO=RS256
5866
- STATIC_URL=http://localhost:8081/static
5967

68+
statsd-exporter:
69+
image: prom/statsd-exporter:v0.23.0
70+
ports:
71+
- "9125:9125/udp"
72+
- "9102:9102"
73+
profiles:
74+
- metrics
75+
volumes:
76+
- ./etc/statsd.conf:/statsd/statsd.conf
77+
command:
78+
- --statsd.mapping-config=/statsd/statsd.conf
79+
6080
volumes:
6181
controllerdata:

docker/etc/statsd.conf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
mappings:
2+
- match: "*.gunicorn.request.status.*"
3+
help: "gunicorn response code"
4+
name: "gunicorn_response_code"
5+
labels:
6+
app: "$1"
7+
status: "$2"
8+
- match: "*.gunicorn.workers"
9+
name: "gunicorn_workers"
10+
labels:
11+
app: "$1"
12+
- match: "*.gunicorn.requests"
13+
name: "gunicorn_requests"
14+
labels:
15+
app: "$1"
16+
- match: "*.gunicorn.request.duration"
17+
name: "gunicorn_request_duration"
18+
labels:
19+
app: "$1"

0 commit comments

Comments
 (0)