Skip to content

Commit

Permalink
* Added a couple of more metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
korsakovs committed Feb 25, 2024
1 parent a3d86d7 commit 71694c2
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion thankyou/slackbot/utils/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from timeit import default_timer as timer
from typing import Callable

from prometheus_client import Histogram
from prometheus_client import Histogram, Counter as PrometheusCounter
from slack_bolt import App
from slack_sdk import WebClient

Expand Down Expand Up @@ -83,6 +83,17 @@ def is_socket_mode() -> bool:
labelnames=["merci_handler", "merci_handler_type"],
)

events_counter = PrometheusCounter(
name='slack_handler_number_of_events',
documentation='The total number of requests received',
)


errors_counter = PrometheusCounter(
name='slack_handler_number_of_errors',
documentation='The total number of errors happened while processing requests',
)


class EventType(Enum):
Event = "event"
Expand Down Expand Up @@ -115,8 +126,12 @@ def wrapper(*args, **kwargs):
start = timer()
try:
return func(*args, **kwargs)
except Exception:
errors_counter.inc(1)
raise
finally:
# logger.info(f"Sending metrics for {func.__name__}")
events_counter.inc(1)
metric_wrapper.observe(timer() - start)

return wrapper
Expand Down

0 comments on commit 71694c2

Please sign in to comment.