Skip to content

feature: expose a metric for blockbuilder owned partitions #5042

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

javiermolinar
Copy link
Contributor

@javiermolinar javiermolinar commented Apr 23, 2025

What this PR does:
It adds a new metric to track the partitions owned by a blockbuilder. This will allow us to identify problems with unassigned partitions.

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]
@@ -232,6 +238,10 @@ func (b *BlockBuilder) running(ctx context.Context) error {
func (b *BlockBuilder) consume(ctx context.Context) (time.Duration, error) {
partitions := b.getAssignedPartitions()

for _, p := range partitions {
metricOwnedPartitions.WithLabelValues(strconv.Itoa(int(p))).Set(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

If a partition becomes un-owned, do we have a place to set this back to 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I may be wrong, but I think't we can leverage on Prometheus staleness. If the metric has not been updated in the past 5 minutes then it won't show up

Copy link
Contributor

@mapno mapno left a comment

Choose a reason for hiding this comment

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

LGTM. We could measure it inside b.getAssignedPartitions() and add partition state too.

@javiermolinar javiermolinar merged commit a3a2b8e into grafana:main May 26, 2025
19 checks passed
knylander-grafana pushed a commit to knylander-grafana/tempo-doc-work that referenced this pull request Jun 2, 2025
)

* feature: expose a metric for blockbuilder owned partitions

* track the errors too

* rollback last change

* include partition state

* changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants