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

fix prometheus rebalance typo #26

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
14 changes: 7 additions & 7 deletions faust/sensors/prometheus.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,17 @@ def _initialize_metrics(self) -> None:
)
self.assign_latency = Histogram("assign_latency", "Assignment latency in ms")

# Revalances
# Rebalances
self.total_rebalances = Gauge("total_rebalances", "Total rebalances")
self.total_rebalances_recovering = Gauge(
"total_rebalances_recovering", "Total rebalances recovering"
)
self.revalance_done_consumer_latency = Histogram(
"revalance_done_consumer_latency",
self.rebalance_done_consumer_latency = Histogram(
"rebalance_done_consumer_latency",
"Consumer replying that rebalance is done to broker in ms",
)
self.revalance_done_latency = Histogram(
"revalance_done_latency", "Revalance finished latency in ms"
self.rebalance_done_latency = Histogram(
"rebalance_done_latency", "Rebalance finished latency in ms"
)

# Count Metrics by name
Expand Down Expand Up @@ -296,15 +296,15 @@ def on_rebalance_return(self, app: AppT, state: typing.Dict) -> None:
super().on_rebalance_return(app, state)
self.total_rebalances.dec()
self.total_rebalances_recovering.inc()
self.revalance_done_consumer_latency.observe(
self.rebalance_done_consumer_latency.observe(
self.ms_since(state["time_return"])
)

def on_rebalance_end(self, app: AppT, state: typing.Dict) -> None:
"""Cluster rebalance fully completed (including recovery)."""
super().on_rebalance_end(app, state)
self.total_rebalances_recovering.dec()
self.revalance_done_latency.observe(self.ms_since(state["time_end"]))
self.rebalance_done_latency.observe(self.ms_since(state["time_end"]))

def count(self, metric_name: str, count: int = 1) -> None:
"""Count metric by name."""
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/sensors/test_prometheus.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,13 @@ def test_on_rebalance(self):
client.on_rebalance_return(app, state)
client.total_rebalances.dec.assert_called_once()
client.total_rebalances_recovering.inc.assert_called()
client.revalance_done_consumer_latency.observe.assert_called_once_with(
client.rebalance_done_consumer_latency.observe.assert_called_once_with(
client.ms_since(state["time_return"])
)

client.on_rebalance_end(app, state)
client.total_rebalances_recovering.dec.assert_called()
client.revalance_done_latency.observe(client.ms_since(state["time_end"]))
client.rebalance_done_latency.observe(client.ms_since(state["time_end"]))

def test_on_web_request(self, request, response, view):
response.status = 404
Expand Down