Skip to content
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

Fixed prometheus middleware. #175

Merged
merged 1 commit into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion taskiq/abc/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ async def startup(self) -> None:

for middleware in self.middlewares:
if middleware.__class__.startup != TaskiqMiddleware.startup:
await maybe_awaitable(middleware.startup)
await maybe_awaitable(middleware.startup())

await self.result_backend.startup()

Expand Down
16 changes: 0 additions & 16 deletions taskiq/middlewares/prometheus_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ def __init__(
) -> None:
super().__init__()

self.found_errors = None
self.received_tasks = None
self.success_tasks = None
self.saved_results = None
self.execution_time = None

metrics_path = metrics_path or Path(gettempdir()) / "taskiq_worker"

if not metrics_path.exists():
Expand Down Expand Up @@ -110,8 +104,6 @@ def pre_execute(
:param message: current message.
:return: message
"""
if self.received_tasks is None:
return message
self.received_tasks.labels(message.task_name).inc()
return message

Expand All @@ -126,12 +118,6 @@ def post_execute(
:param message: received message.
:param result: result of the execution.
"""
if ( # noqa: WPS337
self.success_tasks is None
or self.execution_time is None
or self.found_errors is None
):
return
if result.is_err:
self.found_errors.labels(message.task_name).inc()
else:
Expand All @@ -149,6 +135,4 @@ def post_save(
:param message: received message.
:param result: result of execution.
"""
if self.saved_results is None:
return
self.saved_results.labels(message.task_name).inc()