Conversation
The *_topic_delta_seconds lag gauges were only visible as metrics, so a microservice falling behind (and silently skipping data trimmed from its streams) went unnoticed. Add a TopicLagMonitor (Ruby and Python) that publishes warn/critical/recovery notifications with hysteresis and alerts when data was trimmed before it could be processed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3952 +/- ##
==========================================
+ Coverage 80.08% 80.21% +0.12%
==========================================
Files 901 903 +2
Lines 68356 68618 +262
Branches 2645 2698 +53
==========================================
+ Hits 54743 55042 +299
+ Misses 12946 12909 -37
Partials 667 667
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
|
||
| def db_shard_for(topic) | ||
| # Target topics carry the target name as a Redis hashtag, e.g. SCOPE__DECOM__{TGT}__PKT | ||
| match = topic.match(/\{([^}]+)\}/) |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


What
Adds a
TopicLagMonitor(Rubyopenc3/utilities/topic_lag_monitor.rband Pythonopenc3/utilities/topic_lag_monitor.py). It is wired into every microservice that already reported a*_topic_delta_secondsgauge: decom, log, text_log, interface cmd, router tlm, and tsdb ingest.The monitor keeps setting the existing gauge. On top of that it:
XINFO STREAM(at most once per second per topic). It compares the stream'smax-deleted-entry-idto the last id this consumer processed. If unread entries were deleted, it publishes one ALERT covering all affected topics, listing each topic and roughly how many seconds were skipped. This alert is rate limited.XINFOfrom the target hashtag in the topic name ({TARGET}), falling back to the microservice'sdb_shard.Notifications go through the existing Logger
notification/alerttypes, so they show up in the Notifications menu with no frontend changes.Why
The lag gauges were only visible as metrics (charted in Enterprise System Health, invisible in Core). A microservice that couldn't keep up, or that lost data to stream trimming, gave users no indication.
Configuration (env vars)
OPENC3_LAG_WARN_SECONDS0disables notifications and alerts; the gauge is still set.OPENC3_LAG_CRITICAL_SECONDSOPENC3_LAG_CLEAR_SECONDSOPENC3_LAG_RENOTIFY_SECONDSNotes
max-deleted-entry-id. On servers without that field it skips the check.Testing
spec/utilities/topic_lag_monitor_spec.rb(16 examples) andtest/utilities/test_topic_lag_monitor.py(16 tests). They cover the thresholds, hysteresis and recovery, stepping down from critical, rate limiting, env config, lost-data detection, alert aggregation,XINFOrate limiting, db_shard lookup, and error handling.bundle exec rspec spec/microservices spec/utilities spec/models spec/topics: 1493 examples, 0 failures.uv run pytest ./test: 3045 passed.uv run ruff check openc3: clean.🤖 Generated with Claude Code