Skip to content
New issue

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

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

Already on GitHub? # to your account

Batch Mutable State Metrics #6655

Merged
merged 4 commits into from
Oct 16, 2024
Merged

Batch Mutable State Metrics #6655

merged 4 commits into from
Oct 16, 2024

Conversation

njo
Copy link
Contributor

@njo njo commented Oct 11, 2024

What changed?

Extend metrics.Handler interface to include a batching feature which enables implementations to send "wide events". Batch the mutable state metrics.

Why?

Send a single metrics "event" where possible rather than several.

How did you test it?

Unit tests.

Potential risks

None expected.

Documentation

Nothing in docs/ to update. Release notes to come.

Is hotfix candidate?

No

@njo njo requested a review from a team as a code owner October 11, 2024 22:25
@CLAassistant
Copy link

CLAassistant commented Oct 11, 2024

CLA assistant check
All committers have signed the CLA.

common/metrics/metrics.go Outdated Show resolved Hide resolved
@njo njo force-pushed the extend_metrics_handler branch from 2eb04bf to 22d7056 Compare October 15, 2024 17:49
Copy link
Member

@bergundy bergundy left a comment

Choose a reason for hiding this comment

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

LGTM, had one concern but you can merge and we'll continue discussing later.

}

for category, taskCount := range stats.TaskCountByCategory {
// We use the metricsHandler rather than the batchHandler here because the same metric is repeatedly sent
Copy link
Member

Choose a reason for hiding this comment

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

Can't we support this in the batch handler? This limits the approach a bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could add it to the batch and leave it up to the handler implementation to decide what to do with duplicate metrics/labels. The main issue with this particular line is it also adds extra labels. We can't add those labels to a batch as is because they couldn't be correlated with the specific task count and would apply to the batch as a whole. We could change the metric name/label to be [categoryname]-task_count but that would break existing task_count metrics (unless the concatenation happened in the handler but that seems like a bit of a hack).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thinking about this some more I'm going to add it to the batch and we can decide what to do about it in the underlying implementation. I think I can make some kind of nested structure to handle it.

@njo njo force-pushed the extend_metrics_handler branch from 22d7056 to 7b74056 Compare October 16, 2024 19:27
@njo njo enabled auto-merge (squash) October 16, 2024 19:30
@njo njo merged commit f5c6ca1 into main Oct 16, 2024
47 checks passed
@njo njo deleted the extend_metrics_handler branch October 16, 2024 19:52
xwduan pushed a commit that referenced this pull request Oct 18, 2024
## What changed?
Extend metrics.Handler interface to include a batching feature which
enables implementations to send "wide events". Batch the mutable state metrics.

## Why?
Send a single metrics "event" where possible rather than several.

## How did you test it?
Unit tests.

## Potential risks
None expected.

## Documentation
Nothing in `docs/` to update. Release notes to come.

## Is hotfix candidate?
No
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants