feat(metrics): Fix metrics naming and add log metrics backend#270
Merged
feat(metrics): Fix metrics naming and add log metrics backend#270
Conversation
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
🤖 This preview updates automatically when you update the PR. |
…icsBackend Add METRICS_PREFIX constant and LogMetricsBackend that periodically logs accumulated metrics at a configurable period (YAML type: log). Introduce MetricsFlusher protocol, DatadogFlusher, LogFlusher, and BufferedMetricsBackend to remove duplication between Datadog and Log backends. Wire type=log in runner and add config schema for log metrics (period_sec, optional tags). Tests mock the module-level logger and patch time where needed; merge increment/gauge/timing accumulation tests into one. Made-with: Cursor
e0523fb to
f5c94ea
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: LogFlusher "no metrics" branch is unreachable dead code
- Changed condition from 'if parts:' to 'if len(parts) > 1:' to properly detect when only the prefix is present without any metrics.
Or push these changes by commenting:
@cursor push e035a18b47
Preview (e035a18b47)
diff --git a/sentry_streams/sentry_streams/metrics/metrics.py b/sentry_streams/sentry_streams/metrics/metrics.py
--- a/sentry_streams/sentry_streams/metrics/metrics.py
+++ b/sentry_streams/sentry_streams/metrics/metrics.py
@@ -189,7 +189,7 @@
for name, value, tags in gauges:
tags_str = " ".join(tags) if tags else ""
parts.append(f"gauge {name.value}={value} {tags_str}".strip())
- if parts:
+ if len(parts) > 1:
logger.info(" | ".join(parts))
else:
logger.info("No metrics to flush")This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
evanh
approved these changes
Mar 17, 2026
Made-with: Cursor
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.


Adjust metrics naming and introduce a log based metric backend.
We have some issues with the metrics produced via datadog.
1a. These are the metrics we produce
sentry_streams..sentry_streams.streams.pipeline.input.message. WE are turning them intostreams.pipeline.input.messages.1b. For the rust ones we adding
streams.pipelinein front.Add a backend that prints metric values in logs periodically. This is meant to allow troubleshooting metrics production. At present we do not see any metric in prod.
Metrics naming
streams.prefix and suffix-only enum values (e.g.streams.input.messages) withpipelinetag.streams.soarroyo.consumer.run.countbecomesstreams.arroyo.consumer.run.count; pipeline tag unchanged.Log metrics backend
METRICS_PREFIXconstant andLogMetricsBackend(YAMLtype: log, configurableperiod_sec) that buffers and periodically logs accumulated metrics.MetricsFlusherprotocol,DatadogFlusher,LogFlusher, andBufferedMetricsBackendto remove duplication between Datadog and Log backends.type: log; tests mock module-level logger and consolidate buffer tests.Made with Cursor