Skip to content

Conversation

@leehinman
Copy link
Contributor

What does this PR do?

Adds a new type of ClearOnVisitHistogram to monitoring/adapter.

Why is it important?

This type is the same as a go-metrics StandardHistogram, but the Visit function for the new type will call Clear on the underlying sample. This means the sample is reset each time you visit it. This is useful for things like the beats "Non-zero metrics in the last 30s" log entries.

The other difference is that the Visit function only reports the following metrics:

  • count
  • min
  • max
  • median
  • p99

This is smaller than the fields produced for the StandardHistogram. This was done to limit the field expansion, and this list of fields was picked because it is the list actually used in the elastic-agent monitoring dashboards.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works

Author's Checklist

  • [ ]

Related issues

@leehinman leehinman added the enhancement New feature or request label Jul 24, 2025
@leehinman leehinman requested a review from a team as a code owner July 24, 2025 18:45
@leehinman leehinman added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Jul 24, 2025
@leehinman leehinman requested review from faec and mauri870 and removed request for a team July 24, 2025 18:45
@leehinman leehinman force-pushed the 5882_clearing_histogram branch from 7580a8f to 664a29a Compare July 24, 2025 19:08
Copy link
Member

@mauri870 mauri870 left a comment

Choose a reason for hiding this comment

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

I don't see any obvious issues, but I'm not very experienced with how this integrates with the agent dashboards. I'd give more weight to Fae's review.

@leehinman leehinman force-pushed the 5882_clearing_histogram branch from 664a29a to 3230078 Compare August 5, 2025 17:18
@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

@leehinman
Copy link
Contributor Author

@mauri870 & @faec I did a draft PR of how I think this could be used in the beats repo.

elastic/beats#45749

@leehinman leehinman merged commit d5a250f into elastic:main Aug 7, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants