File tree Expand file tree Collapse file tree 4 files changed +26
-6
lines changed Expand file tree Collapse file tree 4 files changed +26
-6
lines changed Original file line number Diff line number Diff line change 1414)
1515
1616from snuba .settings .validation import validate_settings
17+ from snuba .utils .metrics .addr_config import get_statsd_addr
1718
1819# All settings must be uppercased, have a default value and cannot start with _.
1920# The Rust consumer relies on this to create a JSON file from the evaluated settings
122123]
123124
124125# Dogstatsd Options
125- DOGSTATSD_HOST : str | None = os .environ .get ("SNUBA_STATSD_HOST" ) or None
126- DOGSTATSD_PORT : int | None = int (os .environ .get ("SNUBA_STATSD_PORT" ) or 0 ) or None
126+ DOGSTATSD_HOST , DOGSTATSD_PORT = get_statsd_addr ()
127127DOGSTATSD_SAMPLING_RATES = {
128128 "metrics.processor.set.size" : 0.1 ,
129129 "metrics.processor.distribution.size" : 0.1 ,
Original file line number Diff line number Diff line change 11import os
22
3+ from snuba .utils .metrics .addr_config import get_statsd_addr
4+
35env = os .environ .get
46
57DEBUG = env ("DEBUG" , "0" ).lower () in ("1" , "true" )
1315USE_REDIS_CLUSTER = False
1416
1517# Dogstatsd Options
16- DOGSTATSD_HOST = env ("DOGSTATSD_HOST" )
17- DOGSTATSD_PORT = env ("DOGSTATSD_PORT" )
18+ DOGSTATSD_HOST , DOGSTATSD_PORT = get_statsd_addr ()
1819
1920SENTRY_DSN = env ("SENTRY_DSN" )
2021
Original file line number Diff line number Diff line change 11import os
22from typing import Set
33
4+ from snuba .utils .metrics .addr_config import get_statsd_addr
5+
46env = os .environ .get
57
68ALLOCATION_POLICY_ENABLED = False
1719USE_REDIS_CLUSTER = False
1820
1921# Dogstatsd Options
20- DOGSTATSD_HOST = env ("DOGSTATSD_HOST" )
21- DOGSTATSD_PORT = env ("DOGSTATSD_PORT" )
22+ DOGSTATSD_HOST , DOGSTATSD_PORT = get_statsd_addr ()
2223
2324# Dataset readiness states supported in this environment
2425SUPPORTED_STATES : Set [str ] = {"deprecate" , "complete" }
Original file line number Diff line number Diff line change 1+ import os
2+ from typing import Optional
3+
4+
5+ def get_statsd_addr () -> tuple [Optional [str ], Optional [int ]]:
6+ """Returns the address of the StatsD server."""
7+ snuba_statsd_address = os .environ .get ("SNUBA_STATSD_ADDR" )
8+ if snuba_statsd_address :
9+ ip , separator , port = snuba_statsd_address .rpartition (":" )
10+ assert separator == ":" , "SNUBA_STATSD_ADDR must be in the format of ip:port"
11+ return ip , int (port or 8125 )
12+
13+ dogstatsd_host = os .environ .get ("DOGSTATSD_HOST" )
14+ dogstatsd_port = os .environ .get ("DOGSTATSD_PORT" , "8125" )
15+ if dogstatsd_host and dogstatsd_port :
16+ return dogstatsd_host , int (dogstatsd_port )
17+
18+ return None , None
You can’t perform that action at this time.
0 commit comments