-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from kozalosev/issue/11-metrics
Add Prometheus counter for chosen inline result [regex] support of crypto assets with ticker of 4+ chars Simplify import paths [tests] fix time zone in mock data
- Loading branch information
Showing
12 changed files
with
70 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"""Module for management of Prometheus metrics""" | ||
|
||
from typing import Dict | ||
from prometheus_client import start_http_server, Counter | ||
|
||
from .abc import TextProcessor | ||
|
||
_COUNTER_PREFIX = "used_processor_" | ||
_counters: Dict[str, Counter] = {} | ||
|
||
|
||
def register(*processors: TextProcessor) -> None: | ||
"""Registers counter metrics for all processors""" | ||
for proc in processors: | ||
_counters[proc.snake_case_name] = Counter(_COUNTER_PREFIX + proc.snake_case_name, f"{proc.name} usage") | ||
|
||
|
||
def inc(query_id: str) -> None: | ||
""" | ||
Increments the counter | ||
:param query_id: in format ``{index_number}:{proc_name}`` | ||
""" | ||
proc_name = "".join(query_id.split(':')[1:]) | ||
_counters[proc_name].inc() | ||
|
||
|
||
def serve(port: int) -> None: | ||
"""Runs a WSGI server for metrics""" | ||
start_http_server(port) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
aiotg==1.0.0 | ||
git+https://github.com/kozalosev/aiotg@feature/chosen_inline_result#egg=aiotg | ||
aiohttp==3.8.4 | ||
klocmod==0.3.0 | ||
requests==2.28.2 | ||
prometheus-client==0.16.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters