feat(metrics): expose dropped messages count as the droppedMsgs Prometheus counter#317
Open
dmytro-landiak wants to merge 7 commits into
Open
feat(metrics): expose dropped messages count as the droppedMsgs Prometheus counter#317dmytro-landiak wants to merge 7 commits into
dmytro-landiak wants to merge 7 commits into
Conversation
…s counter Registers a Micrometer Counter named droppedMsgs (no tags) inside TbMessageStatsReportClientImpl and exposes it through the existing /actuator/prometheus endpoint. The counter is registered before the historical-data-report.enabled early-exit so it works even when historical persistence is disabled. Adds the dedicated reportDroppedMsgs(int count) interface method; call-site migration follows in subsequent commits. Refs #303
…DroppedMsgs Migrates 10 call sites (8 files) from reportStats(DROPPED_MSGS) to the dedicated reportDroppedMsgs(1) method introduced in the previous commit. Batched-count call sites (4 remaining) are migrated separately. Refs #303
Migrates the remaining 4 call sites (4 files) that pass an explicit count to reportStats(DROPPED_MSGS, n). No call sites now use the generic reportStats path for DROPPED_MSGS. Refs #303
…r reportDroppedMsgs Refs #303
Create the droppedMsgs counter via StatsFactory.createDefaultCounter instead of injecting MeterRegistry directly, matching the convention used by all other metrics in the broker. Add a no-arg reportDroppedMsgs() alongside reportDroppedMsgs(int), mirroring the existing reportStats()/reportStats(key, count) pair, and migrate the single-drop call sites from reportDroppedMsgs(1) to reportDroppedMsgs(). Document on reportStats(...) that DROPPED_MSGS must be reported via reportDroppedMsgs to keep the Prometheus counter in sync. Update unit tests accordingly.
…respects stats.enabled The droppedMsgs Prometheus counter was created directly through StatsFactory, which is always active, so it stayed exposed even when metrics were turned off via stats.enabled=false (STATS_ENABLED) - inconsistent with every other broker metric. Move counter creation behind StatsManager#createDroppedMsgsCounter(): StatsManagerImpl registers the real counter, while StatsManagerStub (used when stats are disabled) returns a no-op counter that is never exposed on /actuator/prometheus. The historical PostgreSQL pipeline remains independently gated by historical-data-report.enabled.
…ction Extract a DroppedMsgStats stats object (interface + Default + Stub) owned by StatsManager, mirroring DeviceProcessorStats/FlowControlStats and the rest of the stats package, instead of returning a bare DefaultCounter. This removes the throwaway SimpleMeterRegistry no-op hack from StatsManagerStub (it now returns a real no-op StubDroppedMsgStats), lets the report client depend on the interface rather than a raw counter, and gives a clean extension point - including PE - for future dropped-message metrics without changing StatsManager's signature.
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.
Pull Request description
Resolves #303.
Exposes the cumulative dropped-message count as a Micrometer counter
droppedMsgson the existing/actuator/prometheusendpoint, so operators can alert on message drops directly with Prometheus.What changed
TbMessageStatsReportClient#reportDroppedMsgs(int count)method.TbMessageStatsReportClientImplnow injectsMeterRegistry, registers a singleCounternameddroppedMsgs(no tags), and increments it on every dropped message. The counter is registered in@PostConstruct init()before thehistorical-data-report.enabledearly-exit, so the metric is always present and scrapeable — even when historical persistence is disabled.reportStats(DROPPED_MSGS[, n])call sites (11 files) toreportDroppedMsgs(...). No call site uses the genericreportStatspath for dropped messages anymore.Backward compatibility
AtomicLong→ PostgreSQL historical pipeline is unchanged and still gated byhistorical-data-report.enabled, so existing historicaldroppedMsgsdashboards / time series are unaffected. No schema change, no new dependency.Sample scrape (
/actuator/prometheus):Documentation
droppedMsgs_totalcounter exposed on/actuator/prometheus.General checklist
Front-End feature checklist
N/A — back-end only change (no front-end / UI changes).
Back-End feature checklist
TbMessageStatsReportClientImplTest(basic increment, batched count, and counter-works-when-historical-reporting-disabled);BasicDownLinkProcessorImplTestverifications updated; fullmvn -T 1C clean installis green, including the Spring-contextRateLimitsIntegrationTestCase.micrometer-registry-prometheuswere already on the classpath.