Skip to content

Commit

Permalink
FIX: metric name in hooks is accidentally broken in 8.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Perestoronin authored and eigenein committed Jul 17, 2023
1 parent 669d3bf commit a0b33eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions tests/test_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def test_args(**kwargs):
assert "response" in kwargs
assert "exception" in kwargs
assert "metric" in kwargs
assert "name" in kwargs["metric"]
return dict()

def test_metadata(*args, **kwargs):
Expand Down
7 changes: 6 additions & 1 deletion time_execution/timed.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ def __exit__(

# Apply the registered hooks, and collect the metadata they might
# return to be stored with the metrics.
metadata = self._apply_hooks(hooks=hooks, response=self.result, exception=__exc_val, metric=metric)
metadata = self._apply_hooks(
hooks=hooks,
response=self.result,
exception=__exc_val,
metric={**metric, "name": self._fqn},
)

metric.update(metadata)
write_metric(name=self._fqn, **metric)
Expand Down

0 comments on commit a0b33eb

Please sign in to comment.