Skip to content

Commit

Permalink
feat(relay): Introduce options to global config (#61024)
Browse files Browse the repository at this point in the history
Setup infrastructure to add options to the global config, also update
the global config endpoint to signal relay the global config is fully
ready.
  • Loading branch information
Dav1dde authored Dec 5, 2023
1 parent 62ef714 commit b577848
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/sentry/api/endpoints/relay/project_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def _post(self, request: Request):

if version == "3" and request.relay_request_data.get("global"):
response["global"] = get_global_config()
response["global_status"] = "ready"

if self._should_post_or_schedule(version, request):
# Always compute the full config. It's invalid to send partial
Expand Down
26 changes: 24 additions & 2 deletions src/sentry/relay/globalconfig.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
from sentry.relay.config.measurements import get_measurements_config
from typing import Any, Dict, List, TypedDict

import sentry.options
from sentry.relay.config.measurements import MeasurementsConfig, get_measurements_config
from sentry.utils import metrics

# List of options to include in the global config.
RELAY_OPTIONS: List[str] = []


class GlobalConfig(TypedDict, total=False):
measurements: MeasurementsConfig
options: Dict[str, Any]


@metrics.wraps("relay.globalconfig.get")
def get_global_config():
"""Return the global configuration for Relay."""
return {

global_config: GlobalConfig = {
"measurements": get_measurements_config(),
}

options = dict()
for option in RELAY_OPTIONS:
if (value := sentry.options.get(option)) is not None:
options[option] = value

if options:
global_config["options"] = options

return global_config
1 change: 1 addition & 0 deletions tests/sentry/api/endpoints/test_relay_projectconfigs_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,5 @@ def test_return_project_and_global_config(
"configs": {default_projectkey.public_key: {"is_mock_config": True}},
"pending": [],
"global": {"global_mock_config": True},
"global_status": "ready",
}

0 comments on commit b577848

Please sign in to comment.