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
Add thread state metrics #910
Conversation
I never got around looking into this, but would have thought of 'jvm.thread.states' with 'id' tag for the state. So you'd get all states (arguably the remaining are not that interesting) and this would differentiate this metric from the 'jvm.threads.*' ones. But just thinking loud. Thanks for looking into this! |
@mweirauch Thanks for the feedback! I just tried to translate the request from the referenced issue into code and didn't think much on this. I'd like to understand your suggestion but I couldn't get it fully. I might miss some context there. I guess you're suggesting metric per thread and the meter definition is as follows:
What I didn't get fully is how the state will be represented there. Translating it into numeric value or having another tag like |
What I meant was actually encoding the state as 'id' tag. I didn't consider the thread id. But what about 'id' and 'state' tags? Or does this generate too much cardinality given the fact that every thread id can be in every state? |
@mweirauch Ah, I'm just confused by the name,
Again, I'm just confused by the name, |
I'm in favor of one meter with
Thread ID seems high cardinality to me and limited value. If we tag any identity at all, perhaps thread name is a better thing to tag? Thread name would likely be the same or similar across applications/instances/restarts for the same logical threads. As for the meter name, it seems like this is actually an enhancement to the already existing |
I agree thread id or name might be too much, also regarding the retrieval. And yes regarding 'jvm.threads.live', would be the same just sliced up. So a distinct metric just with all states available expressed with a tag would do is my understanding from the discussion. |
@shakuzen @mweirauch Thanks for the feedback! Having |
I know nitpicking, but I think all 'Thread.State' should be part of the metric. So 'NEW' and 'TERMINATED'. Otherwise summing over all states doesn't give the whole set of threads. |
@mweirauch I just assumed
But I didn't check more than the Javadoc, so I might be wrong. And I thought I just added 8061ccb as suggested. |
This PR adds thread state metrics.
Note that this could be enhanced if there's a way to reuse a result across gauges but I couldn't find an easy way yet. #807 might be helpful here.
Closes gh-543