Skip to content

Commit

Permalink
Merge pull request #4618 from zenoss/bugfix/ZEN-35156.7x
Browse files Browse the repository at this point in the history
Initialize events so that zenhub metrics can decrement.
  • Loading branch information
jpeacock-zenoss authored Nov 20, 2024
2 parents 7492972 + 0c51ce6 commit 7b1b1a0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
18 changes: 9 additions & 9 deletions Products/ZenHub/server/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,18 @@ class _CompletedData(_StartedData):
result = attr.ib(default=_UNSPECIFIED)

def __attrs_post_init__(self):
if (
sum(
1
for name in ("result", "error", "retry")
if getattr(self, name) is _UNSPECIFIED
)
!= 2
):
unspecified = tuple(
name
for name in ("result", "error", "retry")
if getattr(self, name) is _UNSPECIFIED
)
if len(unspecified) != 2:
raise TypeError(
"At least one of fields 'result', 'retry', and 'error' "
"must be specified"
"must be given an argument"
)
for name in unspecified:
object.__setattr__(self, name, None)


@implementer(IServiceCallReceivedEvent)
Expand Down
3 changes: 2 additions & 1 deletion Products/ZenHub/server/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def decrementLegacyMetricCounters(event):
global _legacy_worklist_counters
for key in (event.priority, "total"):
_legacy_worklist_counters[key] -= 1
# If the count falls below zero, there's a bug and should be logged.
# If the count falls below zero,
# there's a bug and should be logged.
if _legacy_worklist_counters[key] < 0:
log.warn(
"Counter is negative worklist=%s value=%s",
Expand Down

0 comments on commit 7b1b1a0

Please sign in to comment.