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

NullPointerException when no local ip in Span #224

Closed
rafal-dudek opened this issue Jul 31, 2024 · 10 comments · Fixed by #225
Closed

NullPointerException when no local ip in Span #224

rafal-dudek opened this issue Jul 31, 2024 · 10 comments · Fixed by #225
Labels

Comments

@rafal-dudek
Copy link

Describe the Bug

When localIP is missing in Server braveSpan, it causes exception:

java.lang.NullPointerException: Cannot invoke "String.length()" because "ipString" is null
	at com.google.common.net.InetAddresses.ipStringToBytes(InetAddresses.java:185)
	at com.google.common.net.InetAddresses.forString(InetAddresses.java:151)
	at zipkin2.reporter.stackdriver.brave.AttributesExtractor.extract(AttributesExtractor.java:76)
	at zipkin2.reporter.stackdriver.brave.SpanTranslator.translate(SpanTranslator.java:80)
	at zipkin2.reporter.stackdriver.brave.StackdriverV2Encoder.translate(StackdriverV2Encoder.java:59)
	at zipkin2.reporter.stackdriver.brave.StackdriverV2Encoder.sizeInBytes(StackdriverV2Encoder.java:31)
	at zipkin2.reporter.stackdriver.brave.StackdriverV2Encoder.sizeInBytes(StackdriverV2Encoder.java:15)
	at zipkin2.reporter.internal.CountBoundedQueue.doDrain(CountBoundedQueue.java:115)
	at zipkin2.reporter.internal.CountBoundedQueue.drainTo(CountBoundedQueue.java:83)
	at zipkin2.reporter.internal.AsyncReporter$BoundedAsyncReporter.flush(AsyncReporter.java:241)
	at zipkin2.reporter.internal.AsyncReporter$Flusher.run(AsyncReporter.java:352)
	at java.base/java.lang.Thread.run(Thread.java:1583)

Steps to Reproduce

Make sure that your Server Span is missing local IP address.
Not sure how to reproduce it exactly - the problem occurs in our Integration tests only in Jenkins Agent on Kubernetes, locally the IP address is present.
In our case it is for Spring Boot 3.3.2 MVC RestController span.

Expected Behaviour

There should be check if braveSpan.localIp()!=null before invoking InetAddresses.forString(String ipString) on it:
https://github.com/openzipkin/zipkin-gcp/blob/master/encoder-stackdriver-brave/src/main/java/zipkin2/reporter/stackdriver/brave/AttributesExtractor.java#L76

If localIP is null, do not set any attribute for it.

@sann3
Copy link

sann3 commented Aug 2, 2024

We are also facing this issue
Spring boot - 3.3.2
com.google.cloud:spring-cloud-gcp-dependencies - 5.5.0
org.springframework.cloud:spring-cloud-dependencies - 2023.0.3

@shakuzen
Copy link
Member

shakuzen commented Aug 5, 2024

Anyone up for making a pull request to fix this and add tests for it? Looks like the AttributesExtractor used by the other encoder has null checks for IP:

if (zipkinSpan.localEndpoint().ipv4() != null) {
attributes.putAttributeMap(
getLabelName("endpoint.ipv4"), toAttributeValue(zipkinSpan.localEndpoint().ipv4()));
}
if (zipkinSpan.localEndpoint().ipv6() != null) {
attributes.putAttributeMap(
getLabelName("endpoint.ipv6"), toAttributeValue(zipkinSpan.localEndpoint().ipv6()));
}

@hjed
Copy link

hjed commented Aug 13, 2024

We get this problem when running spring on cloud run

@shakuzen
Copy link
Member

Would folks affected by this be able to test with snapshots to confirm there aren't any remaining issues with the fix now merged?

@hjed
Copy link

hjed commented Aug 16, 2024

We've tested with Os's PR and it fixes the issue for us, thanks

@ccudennec-otto
Copy link

oh, that's great to hear! 🥳
how is your release schedule? when can we expect the fix to be released?

@shakuzen
Copy link
Member

Releases for this repo are ad hoc. I'll try to find time to do a release this week.

@shakuzen
Copy link
Member

With #226 merged, I think we have everything ready for the release. If anyone would like to try out snapshots before the release to make sure everything is good, that'd be appreciated.

@joaotab
Copy link

joaotab commented Sep 3, 2024

I tried the 2.2.5-SNAPSHOT and it worked for our deployment

@shakuzen
Copy link
Member

shakuzen commented Sep 4, 2024

2.2.5 is released now with this fix.

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

Successfully merging a pull request may close this issue.

6 participants