Skip to content

Commit

Permalink
FIX: pass the same metric instance to the hooks
Browse files Browse the repository at this point in the history
Although, it isn't much of a bug, but this PR restores the 7.x behaviour for the hooks that relied on having the very same `metric` instance being passed to each hook.
  • Loading branch information
Pavel Perestoronin authored and eigenein committed Aug 31, 2023
1 parent a0b33eb commit f921346
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions time_execution/timed.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __exit__(
) -> None:
duration_millis = round(default_timer() - self._start_time, 3) * 1000.0

metric = {settings.duration_field: duration_millis, "hostname": SHORT_HOSTNAME}
metric = {settings.duration_field: duration_millis, "hostname": SHORT_HOSTNAME, "name": self._fqn}

origin = getattr(settings, "origin", None)
if origin:
Expand All @@ -74,11 +74,11 @@ def __exit__(
hooks=hooks,
response=self.result,
exception=__exc_val,
metric={**metric, "name": self._fqn},
metric=metric,
)

metric.update(metadata)
write_metric(name=self._fqn, **metric)
write_metric(**metric) # type: ignore[arg-type]

def _apply_hooks(self, hooks, response, exception, metric) -> Dict:
metadata = dict()
Expand Down

0 comments on commit f921346

Please sign in to comment.