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 6
6
7
7
import psutil
8
8
9
+ from sentry_dynamic_sampling_lib .config import (
10
+ CONTROLLER_HOST ,
11
+ CONTROLLER_PATH ,
12
+ METRIC_INTERVAL ,
13
+ METRIC_PATH ,
14
+ POLL_INTERVAL ,
15
+ )
9
16
from sentry_dynamic_sampling_lib .sampler import TraceSampler
10
17
11
18
if TYPE_CHECKING :
@@ -34,13 +41,13 @@ def init_wrapper():
34
41
35
42
sentry_sdk : sentry_sdk_type = importlib .import_module ("sentry_sdk" )
36
43
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
+
44
51
if controller_host :
45
52
app_key = build_app_key (client .options )
46
53
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 2
2
from enum import Enum
3
3
from threading import RLock
4
4
5
+ from sentry_dynamic_sampling_lib .config import (
6
+ DEFAULT_IGNORED_PATH ,
7
+ DEFAULT_IGNORED_TASK ,
8
+ DEFAULT_SAMPLE_RATE ,
9
+ )
5
10
from sentry_dynamic_sampling_lib .utils import synchronized
6
11
7
12
8
13
class Config :
9
14
def __init__ (self ) -> None :
10
15
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
20
19
21
20
@property
22
21
@synchronized
You can’t perform that action at this time.
0 commit comments