Skip to content

reduce cardinality of metrics #1593

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions packages/service-library/src/servicelib/monitor_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,23 @@

SERVICE_STARTED_LABELS: List[str] = [
"user_id",
"project_id",
"service_uuid",
"service_key",
"service_tag",
"service_type",
]

SERVICE_STOPPED_LABELS: List[str] = [
"user_id",
"project_id",
"service_uuid",
"service_key",
"service_tag",
"service_type",
"result",
]


def add_instrumentation(app: web.Application, reg: CollectorRegistry, app_name: str) -> None:
def add_instrumentation(
app: web.Application, reg: CollectorRegistry, app_name: str
) -> None:

app[kSERVICE_STARTED] = Counter(
name="services_started_total",
Expand Down Expand Up @@ -63,16 +61,12 @@ def service_started(
# pylint: disable=too-many-arguments
app: web.Application,
user_id: str,
project_id: str,
service_uuid: str,
service_key: str,
service_tag: str,
service_type: Union[ServiceType, str],
) -> None:
app[kSERVICE_STARTED].labels(
user_id=user_id,
project_id=project_id,
service_uuid=service_uuid,
service_key=service_key,
service_tag=service_tag,
service_type=service_type,
Expand All @@ -83,17 +77,13 @@ def service_stopped(
# pylint: disable=too-many-arguments
app: web.Application,
user_id: str,
project_id: str,
service_uuid: str,
service_key: str,
service_tag: str,
service_type: Union[ServiceType, str],
result: Union[ServiceResult, str],
) -> None:
app[kSERVICE_STOPPED].labels(
user_id=user_id,
project_id=project_id,
service_uuid=service_uuid,
service_key=service_key,
service_tag=service_tag,
service_type=service_type,
Expand Down
10 changes: 1 addition & 9 deletions services/director/src/simcore_service_director/producer.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,13 +756,7 @@ async def start_service(
node_details = containers_meta_data[0]
if config.MONITORING_ENABLED:
service_started(
app,
user_id,
project_id,
node_uuid,
service_key,
service_tag,
"DYNAMIC",
app, user_id, service_key, service_tag, "DYNAMIC",
)
# we return only the info of the main service
return node_details
Expand Down Expand Up @@ -939,8 +933,6 @@ async def stop_service(app: web.Application, node_uuid: str) -> None:
service_stopped(
app,
"undefined_user",
"undefined project",
node_uuid,
service_details["service_key"],
service_details["service_version"],
"DYNAMIC",
Expand Down
4 changes: 0 additions & 4 deletions services/sidecar/src/simcore_service_sidecar/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,6 @@ async def _run_container(self):
{
"metrics": "service_started",
"user_id": self.user_id,
"project_id": self.task.project_id,
"service_uuid": self.task.node_id,
"service_type": "COMPUTATIONAL",
"service_key": self.task.image["name"],
"service_tag": self.task.image["tag"],
Expand Down Expand Up @@ -319,8 +317,6 @@ async def _run_container(self):
{
"metrics": "service_stopped",
"user_id": self.user_id,
"project_id": self.task.project_id,
"service_uuid": self.task.node_id,
"service_type": "COMPUTATIONAL",
"service_key": self.task.image["name"],
"service_tag": self.task.image["tag"],
Expand Down
4 changes: 0 additions & 4 deletions services/sidecar/tests/integration/test_sidecar.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ def _assert_incoming_data_logs(
assert len(instrumentation_messages[task]) == 2, f"{instrumentation_messages}"
assert instrumentation_messages[task][0]["metrics"] == "service_started"
assert instrumentation_messages[task][0]["user_id"] == user_id
assert instrumentation_messages[task][0]["project_id"] == project_id
assert instrumentation_messages[task][0]["service_uuid"] == task
assert instrumentation_messages[task][0]["service_type"] == "COMPUTATIONAL"
# the key is of type simcore/services/comp|dynamic/service_name
assert (
Expand All @@ -116,8 +114,6 @@ def _assert_incoming_data_logs(

assert instrumentation_messages[task][1]["metrics"] == "service_stopped"
assert instrumentation_messages[task][1]["user_id"] == user_id
assert instrumentation_messages[task][1]["project_id"] == project_id
assert instrumentation_messages[task][1]["service_uuid"] == task
assert instrumentation_messages[task][1]["service_type"] == "COMPUTATIONAL"
# the key is of type simcore/services/comp|dynamic/service_name
assert (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ async def _publish_messages(
instrumentation_start_message = instrumentation_stop_message = {
"metrics": "service_started",
"user_id": user_id,
"project_id": project_id,
"service_uuid": node_uuid,
"service_type": "COMPUTATIONAL",
"service_key": "some/service/awesome/key",
"service_tag": "some-awesome-tag",
Expand Down