metrics: add support for user-defined metrics#18218
Merged
yaauie merged 2 commits intoelastic:mainfrom Sep 29, 2025
Merged
Conversation
Contributor
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
Contributor
|
This pull request does not have a backport label. Could you fix it @yaauie? 🙏
|
1014806 to
b151f4c
Compare
andsel
approved these changes
Sep 29, 2025
Contributor
andsel
left a comment
There was a problem hiding this comment.
LGTM, left a suggestion to make more explicit the happy path when returning the metric in fromRubyBase.
logstash-core/src/main/java/org/logstash/instrument/metrics/UserMetric.java
Outdated
Show resolved
Hide resolved
…erMetric.java Co-authored-by: Andrea Selva <selva.andre@gmail.com>
|
💚 Build Succeeded
History
|
v1v
pushed a commit
that referenced
this pull request
Oct 21, 2025
* metrics: add support for user-defined metrics * Update logstash-core/src/main/java/org/logstash/instrument/metrics/UserMetric.java Co-authored-by: Andrea Selva <selva.andre@gmail.com> --------- Co-authored-by: Andrea Selva <selva.andre@gmail.com>
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.





Release notes
[rn: skip]
What does this PR do?
Provides a way for registering non-standard metrics, without needing to wire them through publicly.
It does so by introducing an API
UserMetric<VALUE_TYPE>marked as Logstash-internal, a companionUserMetric.Factory<USER_METRIC>to encapsulate the logic for its type and a null implementation, and introducingNamespacedMetric#register(String metric, UserMetric.Factory<USER_METRIC> userMetricFactory).Together, these methods and the wiring through to the metric collector allow anything with an
api.NamespacedMetricto provide its own metric implementation.Why is it important/What is the impact to the user?
This is necessary ground-work for #18107 which will add ratio and relative-spend metrics from within the Logstash code-base.
Checklist
[ ] I have made corresponding change to the default configuration files (and/or docker env variables)Author's Checklist
How to test this PR locally
Related issues
Use cases
Screenshots
Logs