opentracing-contrib / java-web-servlet-filter

OpenTracing Java Web Servlet Filter Instrumentation
Apache License 2.0
24 stars 31 forks source link

Check for null extracted context before creating a child span #61

Open kcirone opened 5 years ago

kcirone commented 5 years ago

There are some implementations (I've observed) of OpenTracing that do not accept null arguments to SpanBuilder.asChildOf(). If tracer.extract() returns null (ie. no span context was passed to the servlet) and it is used to create a child span, .asChildOf() will cause a NullPointerException.

The equivalent operation would be to avoid calling .asChildOf() if extractedContext is null, which should work for any implementation.