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: handle null parent spans in asChildOf calls #2167

Merged
merged 2 commits into from
Mar 31, 2022

Conversation

eddie4941
Copy link
Contributor

Motivation:

The opentracing apis state that when calling the asChildOf methods with
null parameters they should behave as no-ops. The existing code was
throwing null pointers in these cases

ref: https://github.com/opentracing/opentracing-java/blob/master/opentracing-api/src/main/java/io/opentracing/Tracer.java#L150

Modifications:

  • treat null values in childOf calls as no-ops

Result:

Our tracer implementation adheres to the opentracing apis

Copy link
Member

@Scottmitch Scottmitch left a comment

Choose a reason for hiding this comment

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

our call sites guard against calling this method with null. Can you update these to avoid the double null check in TracingHttpServiceFilter and TracingHttpRequesterFilter?

@Scottmitch
Copy link
Member

Scottmitch commented Mar 30, 2022

there are some check style issues related to import ordering. You can also run ./gradlew checkstyle locally to validate.

Error: eckstyle] [ERROR] /home/runner/work/servicetalk/servicetalk/servicetalk-opentracing-inmemory/src/test/java/io/servicetalk/opentracing/inmemory/DefaultInMemoryTracerTest.java:19:1: Import statement for 'io.servicetalk.opentracing.inmemory.api.InMemoryReference' is in the wrong order. Should be in the 'SPECIAL_IMPORTS' group, expecting group 'STANDARD_JAVA_PACKAGE' on this line. [CustomImportOrder]
[1505](https://github.com/apple/servicetalk/runs/5761785777?check_suite_focus=true#step:6:1505)

[1506](https://github.com/apple/servicetalk/runs/5761785777?check_suite_focus=true#step:6:1506)
> Task :servicetalk-opentracing-inmemory:checkstyleTest FAILED
[1507](https://github.com/apple/servicetalk/runs/5761785777?check_suite_focus=true#step:6:1507)
Error: eckstyle] [ERROR] /home/runner/work/servicetalk/servicetalk/servicetalk-opentracing-inmemory/src/test/java/io/servicetalk/opentracing/inmemory/DefaultInMemoryTracerTest.java:20:1: Import statement for 'io.servicetalk.opentracing.inmemory.api.InMemoryScopeManager' is in the wrong order. Should be in the 'SPECIAL_IMPORTS' group, expecting group 'STANDARD_JAVA_PACKAGE' on this line. [CustomImportOrder]
[1508](https://github.com/apple/servicetalk/runs/5761785777?check_suite_focus=true#step:6:1508)
Error: eckstyle] [ERROR] /home/runner/work/servicetalk/servicetalk/servicetalk-opentracing-inmemory/src/test/java/io/servicetalk/opentracing/inmemory/DefaultInMemoryTracerTest.java:21:1: Import statement for 'io.servicetalk.opentracing.inmemory.api.InMemorySpan' is in the wrong order. Should be in the 'SPECIAL_IMPORTS' group, expecting group 'STANDARD_JAVA_PACKAGE' on this line. [CustomImportOrder]
[1509](https://github.com/apple/servicetalk/runs/5761785777?check_suite_focus=true#step:6:1509)
Error: eckstyle] [ERROR] /home/runner/work/servicetalk/servicetalk/servicetalk-opentracing-inmemory/src/test/java/io/servicetalk/opentracing/inmemory/DefaultInMemoryTracerTest.java:22:1: Import statement for 'io.servicetalk.opentracing.inmemory.api.InMemorySpanBuilder' is in the wrong order. Should be in the 'SPECIAL_IMPORTS' group, expecting group 'STANDARD_JAVA_PACKAGE' on this line. [CustomImportOrder]
[1510](https://github.com/apple/servicetalk/runs/5761785777?check_suite_focus=true#step:6:1510)
Error: eckstyle] [ERROR] /home/runner/work/servicetalk/servicetalk/servicetalk-opentracing-inmemory/src/test/java/io/servicetalk/opentracing/inmemory/DefaultInMemoryTracerTest.java:23:1: Import statement for 'io.servicetalk.opentracing.inmemory.api.InMemorySpanContext' is in the wrong order. Should be in the 'SPECIAL_IMPORTS' group, expecting group 'STANDARD_JAVA_PACKAGE' on this line. [CustomImportOrder]
[1511](https://github.com/apple/servicetalk/runs/5761785777?check_suite_focus=true#step:6:1511)
Error: eckstyle] [ERROR] /home/runner/work/servicetalk/servicetalk/servicetalk-opentracing-inmemory/src/test/java/io/servicetalk/opentracing/inmemory/DefaultInMemoryTracerTest.java:24:1: Import statement for 'io.servicetalk.opentracing.inmemory.api.InMemoryTracer' is in the wrong order. Should be in the 'SPECIAL_IMPORTS' group, expecting group 'STANDARD_JAVA_PACKAGE' on this line. [CustomImportOrder]

Motivation:

The opentracing apis state that when calling the asChildOf methods with
null parameters they should behave as no-ops. The existing code was
throwing null pointers in these cases

ref: https://github.com/opentracing/opentracing-java/blob/master/opentracing-api/src/main/java/io/opentracing/Tracer.java#L150

Modifications:

- treat null values in childOf calls as no-ops

Result:

Our tracer implementation adheres to the opentracing apis
@Scottmitch Scottmitch merged commit 3ae63a5 into apple:main Mar 31, 2022
@Scottmitch
Copy link
Member

thanks @eddie4941 !

@eddie4941 eddie4941 deleted the fix-tracing-null branch March 31, 2022 04:54
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