Skip to content

Commit c025875

Browse files
authored
reduce cardinality of metrics (#1593)
* remove node uuid and project uuid from metrics labels to reduce memory footprint
1 parent 6f50e8e commit c025875

File tree

3 files changed

+7
-25
lines changed

3 files changed

+7
-25
lines changed

packages/service-library/src/servicelib/monitor_services.py

+3-13
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,23 @@
1010

1111
SERVICE_STARTED_LABELS: List[str] = [
1212
"user_id",
13-
"project_id",
14-
"service_uuid",
1513
"service_key",
1614
"service_tag",
1715
"service_type",
1816
]
1917

2018
SERVICE_STOPPED_LABELS: List[str] = [
2119
"user_id",
22-
"project_id",
23-
"service_uuid",
2420
"service_key",
2521
"service_tag",
2622
"service_type",
2723
"result",
2824
]
2925

3026

31-
def add_instrumentation(app: web.Application, reg: CollectorRegistry, app_name: str) -> None:
27+
def add_instrumentation(
28+
app: web.Application, reg: CollectorRegistry, app_name: str
29+
) -> None:
3230

3331
app[kSERVICE_STARTED] = Counter(
3432
name="services_started_total",
@@ -63,16 +61,12 @@ def service_started(
6361
# pylint: disable=too-many-arguments
6462
app: web.Application,
6563
user_id: str,
66-
project_id: str,
67-
service_uuid: str,
6864
service_key: str,
6965
service_tag: str,
7066
service_type: Union[ServiceType, str],
7167
) -> None:
7268
app[kSERVICE_STARTED].labels(
7369
user_id=user_id,
74-
project_id=project_id,
75-
service_uuid=service_uuid,
7670
service_key=service_key,
7771
service_tag=service_tag,
7872
service_type=service_type,
@@ -83,17 +77,13 @@ def service_stopped(
8377
# pylint: disable=too-many-arguments
8478
app: web.Application,
8579
user_id: str,
86-
project_id: str,
87-
service_uuid: str,
8880
service_key: str,
8981
service_tag: str,
9082
service_type: Union[ServiceType, str],
9183
result: Union[ServiceResult, str],
9284
) -> None:
9385
app[kSERVICE_STOPPED].labels(
9486
user_id=user_id,
95-
project_id=project_id,
96-
service_uuid=service_uuid,
9787
service_key=service_key,
9888
service_tag=service_tag,
9989
service_type=service_type,

services/director/src/simcore_service_director/producer.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -756,13 +756,7 @@ async def start_service(
756756
node_details = containers_meta_data[0]
757757
if config.MONITORING_ENABLED:
758758
service_started(
759-
app,
760-
user_id,
761-
project_id,
762-
node_uuid,
763-
service_key,
764-
service_tag,
765-
"DYNAMIC",
759+
app, user_id, service_key, service_tag, "DYNAMIC",
766760
)
767761
# we return only the info of the main service
768762
return node_details
@@ -939,8 +933,6 @@ async def stop_service(app: web.Application, node_uuid: str) -> None:
939933
service_stopped(
940934
app,
941935
"undefined_user",
942-
"undefined project",
943-
node_uuid,
944936
service_details["service_key"],
945937
service_details["service_version"],
946938
"DYNAMIC",

services/web/server/src/simcore_service_webserver/computation_subscribe.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from tenacity import retry
1111

1212
from servicelib.application_keys import APP_CONFIG_KEY
13-
from servicelib.monitor_services import service_started, service_stopped
13+
from servicelib.monitor_services import service_started, service_stopped, SERVICE_STARTED_LABELS, SERVICE_STOPPED_LABELS
1414
from servicelib.rabbitmq_utils import RabbitMQRetryPolicyUponInitialization
1515
from simcore_sdk.config.rabbit import Config as RabbitConfig
1616

@@ -82,11 +82,11 @@ async def instrumentation_message_handler(
8282
data = json.loads(message.body)
8383
if data["metrics"] == "service_started":
8484
service_started(
85-
app, **{key: value for key, value in data.items() if key != "metrics"}
85+
app, **{key: data[key] for key in SERVICE_STARTED_LABELS}
8686
)
8787
elif data["metrics"] == "service_stopped":
8888
service_stopped(
89-
app, **{key: value for key, value in data.items() if key != "metrics"}
89+
app, **{key: data[key] for key in SERVICE_STOPPED_LABELS}
9090
)
9191
await message.ack()
9292

0 commit comments

Comments
 (0)