Skip to content
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

Fix NPE when label value is null #1265

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

max-melentyev
Copy link

Hi, we faced an NPE in metrics exporter in cassandra-management-api.

WARN  [epollEventLoopGroup-6-1] 2025-01-17 07:37:13,527 DefaultChannelPipeline.java:1152 - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in th
e pipeline did not handle the exception.
java.lang.NullPointerException: null
        at io.prometheus.client.exporter.common.TextFormat.writeEscapedLabelValue(TextFormat.java:156)
        at io.prometheus.client.exporter.common.TextFormat.write004(TextFormat.java:119)
        at io.prometheus.client.exporter.common.TextFormat.writeFormat(TextFormat.java:53)
at io.k8ssandra.metrics.http.NettyServerHandler.channelRead0(NettyServerHandler.java:76)
        at io.k8ssandra.metrics.http.NettyServerHandler.channelRead0(NettyServerHandler.java:31)

It exports a lot of metrics and prometheus client doesn't add information about the particular metric that causes the exception, so it's hard to identify and fix a particular metric definition. Adding information about metric and label for all possible exceptions will require much more effort, so I think rendering nulls as empty values should be a good option instead of not rendering anything at all.

@dhoard
Copy link
Collaborator

dhoard commented Jan 20, 2025

I feel this is the wrong approach. Treating null values as empty strings can mask real issues.

@max-melentyev
Copy link
Author

Sure, it would be great to wrap exceptions with the information about metric and label that have null values!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants