File tree Expand file tree Collapse file tree 3 files changed +35
-16
lines changed
sentry_dynamic_sampling_lib Expand file tree Collapse file tree 3 files changed +35
-16
lines changed Original file line number Diff line number Diff line change 66
77import psutil
88
9+ from sentry_dynamic_sampling_lib .config import (
10+ CONTROLLER_HOST ,
11+ CONTROLLER_PATH ,
12+ METRIC_INTERVAL ,
13+ METRIC_PATH ,
14+ POLL_INTERVAL ,
15+ )
916from sentry_dynamic_sampling_lib .sampler import TraceSampler
1017
1118if TYPE_CHECKING :
@@ -34,13 +41,13 @@ def init_wrapper():
3441
3542 sentry_sdk : sentry_sdk_type = importlib .import_module ("sentry_sdk" )
3643 client = sentry_sdk .Hub .current .client
37- controller_host = os . getenv ( "SENTRY_CONTROLLER_HOST" )
38- controller_path = os . getenv ( "SENTRY_CONTROLLER_PATH" , "/sentry/apps/{}/" )
39- metric_path = os . getenv (
40- "SENTRY_CONTROLLER_METRIC_PATH" , "/sentry/apps/{}/metrics/{}/"
41- )
42- poll_interval = int ( os . getenv ( "SENTRY_CONTROLLER_POLL_INTERVAL" , "30" ))
43- metric_interval = int ( os . getenv ( "SENTRY_CONTROLLER_METRIC_INTERVAL" , "300" ))
44+
45+ controller_host = CONTROLLER_HOST
46+ controller_path = CONTROLLER_PATH
47+ metric_path = METRIC_PATH
48+ poll_interval = POLL_INTERVAL
49+ metric_interval = METRIC_INTERVAL
50+
4451 if controller_host :
4552 app_key = build_app_key (client .options )
4653 controller_endpoint = urljoin (controller_host , controller_path )
Original file line number Diff line number Diff line change 1+ import os
2+
3+ # default value overridden by controller
4+ DEFAULT_IGNORED_PATH = {"/health" , "/healthz" , "/health/" , "/healthz/" }
5+ DEFAULT_IGNORED_TASK = set ()
6+ DEFAULT_SAMPLE_RATE = 0.0
7+
8+ # controller variables
9+ CONTROLLER_HOST = os .getenv ("SENTRY_CONTROLLER_HOST" )
10+ CONTROLLER_PATH = os .getenv ("SENTRY_CONTROLLER_PATH" , "/sentry/apps/{}/" )
11+ METRIC_PATH = os .getenv ("SENTRY_CONTROLLER_METRIC_PATH" , "/sentry/apps/{}/metrics/{}/" )
12+ POLL_INTERVAL = int (os .getenv ("SENTRY_CONTROLLER_POLL_INTERVAL" , "60" ))
13+ METRIC_INTERVAL = int (os .getenv ("SENTRY_CONTROLLER_METRIC_INTERVAL" , "600" ))
Original file line number Diff line number Diff line change 22from enum import Enum
33from threading import RLock
44
5+ from sentry_dynamic_sampling_lib .config import (
6+ DEFAULT_IGNORED_PATH ,
7+ DEFAULT_IGNORED_TASK ,
8+ DEFAULT_SAMPLE_RATE ,
9+ )
510from sentry_dynamic_sampling_lib .utils import synchronized
611
712
813class Config :
914 def __init__ (self ) -> None :
1015 self ._lock = RLock ()
11- self ._sample_rate = 0.0
12- self ._ignored_paths = {
13- "/health" ,
14- "/healthz" ,
15- "/health/" ,
16- "/healthz/" ,
17- }
18-
19- self ._ignored_tasks = set ()
16+ self ._sample_rate = DEFAULT_SAMPLE_RATE
17+ self ._ignored_paths = DEFAULT_IGNORED_PATH
18+ self ._ignored_tasks = DEFAULT_IGNORED_TASK
2019
2120 @property
2221 @synchronized
You can’t perform that action at this time.
0 commit comments