Skip to content

Commit

Permalink
fix prometheus invalid metric name (#849)
Browse files Browse the repository at this point in the history
* fix

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
Spycsh and pre-commit-ci[bot] authored Nov 4, 2024
1 parent a6998a1 commit acf07cd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions comps/cores/mega/http_service.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

import re
from typing import Optional

from fastapi import FastAPI
Expand Down Expand Up @@ -35,8 +36,10 @@ def __init__(
self._app = self._create_app()

# remove part before '@', used by register_microservice() callers, and
# part after '/', added by MicroService(), to get real service name
suffix = self.title.split("/")[0].split("@")[-1].lower()
# part after '/', added by MicroService(), to get real service name, and
# convert invalid characters to '_'
suffix = re.sub(r"[^a-zA-Z0-9]", "_", self.title.split("/")[0].split("@")[-1].lower())

instrumentator = Instrumentator(
inprogress_name=f"http_requests_inprogress_{suffix}",
should_instrument_requests_inprogress=True,
Expand Down

0 comments on commit acf07cd

Please sign in to comment.