-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathsend_metrics.py
37 lines (31 loc) · 1.09 KB
/
send_metrics.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from platform import python_implementation, python_version
import yggdrasil_engine
from yggdrasil_engine.engine import UnleashEngine
from UnleashClient.api import send_metrics
from UnleashClient.constants import CLIENT_SPEC_VERSION
from UnleashClient.utils import LOGGER
def aggregate_and_send_metrics(
url: str,
app_name: str,
instance_id: str,
connection_id: str,
headers: dict,
custom_options: dict,
request_timeout: int,
engine: UnleashEngine,
) -> None:
metrics_bucket = engine.get_metrics()
metrics_request = {
"appName": app_name,
"instanceId": instance_id,
"connectionId": connection_id,
"bucket": metrics_bucket,
"platformName": python_implementation(),
"platformVersion": python_version(),
"yggdrasilVersion": yggdrasil_engine.__yggdrasil_core_version__,
"specVersion": CLIENT_SPEC_VERSION,
}
if metrics_bucket:
send_metrics(url, metrics_request, headers, custom_options, request_timeout)
else:
LOGGER.debug("No feature flags with metrics, skipping metrics submission.")