Skip to content

gracefully handle and warn about zero-gap between events for frequency estimate - #87

Merged
WarningRan merged 1 commit into
mainfrom
tolerant_zero_gap
Mar 25, 2026
Merged

WarningRan merged 1 commit into
mainfrom
tolerant_zero_gap

Conversation

@lasch

@lasch lasch commented Mar 17, 2026

Copy link
Copy Markdown
Member

More gracefully handle division by zero in src/aiu_trace_analyzer/pipeline/normalize.py and add user feedback:

Changes made:

  1. Added a new TraceWarning called "zero_gap_time" to track events with identical timestamps
  2. Added check for gap_time > 0 before calculating frequency
  3. When gap_time is 0, the code now:
    • Increments the warning counter via self.warnings["zero_gap_time"].update()
    • Falls back to using dur_freq instead of attempting division by zero

Users will now receive feedback about how many events had identical timestamps, helping them identify potential timestamp issues in their trace data. The warning message explains that this causes unreliable interval-based frequency calculation.

…y estimate

Signed-off-by: Lars Schneidenbach <schneidenbach@us.ibm.com>

@WarningRan WarningRan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Fix is correct and well-scoped. gap_time can't be negative (sorted upstream), dur_freq fallback is safe (dur == 0 already filtered by sane_event()). Warning follows existing pattern.

@WarningRan
WarningRan merged commit 3731c9f into main Mar 25, 2026
2 checks passed
@WarningRan
WarningRan deleted the tolerant_zero_gap branch March 25, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants