Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Support Extra Propagation Fields with Trace #2290

Merged
merged 8 commits into from
May 19, 2020
Merged

Conversation

meltsufin
Copy link
Contributor

@meltsufin meltsufin commented Mar 27, 2020

Providing a Trace Propagation Factory Builder instead of just the Factory,
which allows us to rely on the TraceAutoConfiguration.sleuthPropagation()
rather than completely skipping it.

Fixes: #2268.

Providing a Trace Propagation Factory Builder instead of just the Factory,
while allows us to rely on the `TraceAutoConfiguration.sleuthPropagation()`
rather than completely skipping it.

Fixes: #2268.
@meltsufin
Copy link
Contributor Author

@adriancole This almost works except that when there are no extra propagation fields, we get this exception:

java.lang.NullPointerException: fieldNames is empty
	at brave.internal.PredefinedPropagationFields.<init>(PredefinedPropagationFields.java:28)
	at brave.propagation.ExtraFieldPropagation$Extra.<init>(ExtraFieldPropagation.java:464)
	at brave.propagation.ExtraFieldPropagation$ExtraFactory.create(ExtraFieldPropagation.java:450)
	at brave.propagation.ExtraFieldPropagation$ExtraFieldExtractor.extract(ExtraFieldPropagation.java:414)
	at brave.http.HttpServerHandler.handleReceive(HttpServerHandler.java:109)
	at brave.servlet.TracingFilter.doFilter(TracingFilter.java:74)
	at org.springframework.cloud.sleuth.instrument.web.LazyTracingFilter.doFilter(TraceWebServletAutoConfiguration.java:138)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:367)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1639)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.base/java.lang.Thread.run(Thread.java:834)

I think we should just be providing a general Propagation.FactoryBuilder if that existed, rather than the specific ExtraFieldPropagation.FactoryBuilder. What do you think?

@meltsufin
Copy link
Contributor Author

@adriancole Ultimately, what we're after is the ability to configure the delegate for TraceAutoConfiguration, which is currently hardcoded as B3Propagation.FACTORY. I'm open to whatever would be the best way to do it. It will probably require some tweaks to TraceAutoConfiguration in Sleuth though.

@codefromthecrypt
Copy link

the exception will go away with a new brave release which will immediately go into the next sleuth release.

openzipkin/brave#1128

@meltsufin
Copy link
Contributor Author

@adriancole Thanks for such a quick turnaround!

@meltsufin meltsufin requested a review from elefeint May 12, 2020 20:23
elefeint
elefeint previously approved these changes May 12, 2020
spring-cloud-gcp-dependencies/pom.xml Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented May 12, 2020

Codecov Report

Merging #2290 into master will decrease coverage by 7.19%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2290      +/-   ##
============================================
- Coverage     81.13%   73.94%   -7.20%     
+ Complexity     2319     2098     -221     
============================================
  Files           260      260              
  Lines          7575     7575              
  Branches        785      785              
============================================
- Hits           6146     5601     -545     
- Misses         1103     1614     +511     
- Partials        326      360      +34     
Flag Coverage Δ Complexity Δ
#integration ? ?
#unittests 73.94% <100.00%> (ø) 2098.00 <1.00> (ø)
Impacted Files Coverage Δ Complexity Δ
...igure/trace/StackdriverTraceAutoConfiguration.java 72.30% <100.00%> (ø) 12.00 <1.00> (ø)
...gcp/secretmanager/SecretManagerPropertySource.java 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (-4.00%)
...a/spanner/repository/query/SpannerQueryMethod.java 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (-6.00%)
...retmanager/SecretManagerPropertySourceLocator.java 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (-2.00%)
...figure/config/GcpConfigBootstrapConfiguration.java 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (-2.00%)
...e/spanner/GcpSpannerEmulatorAutoConfiguration.java 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (-2.00%)
...epository/config/SpannerRepositoriesRegistrar.java 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (-3.00%)
...ository/config/DatastoreRepositoriesRegistrar.java 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (-3.00%)
...restore/GcpFirestoreEmulatorAutoConfiguration.java 0.00% <0.00%> (-84.85%) 0.00% <0.00%> (-4.00%)
...ramework/cloud/gcp/vision/DocumentOcrTemplate.java 17.64% <0.00%> (-73.53%) 4.00% <0.00%> (-5.00%)
... and 54 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4fdb7e3...5ad71b8. Read the comment docs.

@sonarcloud
Copy link

sonarcloud bot commented May 12, 2020

SonarCloud Quality Gate failed.

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell D 4 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@meltsufin
Copy link
Contributor Author

Looks like TraceSampleApplicationTests fails as soon as we upgrade spring-cloud-sleuth to 2.2.3.BUILD-SNAPSHOT. 😞

@elefeint
Copy link
Contributor

I can look into it Thursday -- I've had a lot of tracing on my mind lately.

@meltsufin
Copy link
Contributor Author

We should rework this PR based on spring-cloud/spring-cloud-sleuth#1647 as well.

@elefeint
Copy link
Contributor

My first thought was that we needed a newer brave, but sleuth snapshot already pulls in the latest...

@meltsufin
Copy link
Contributor Author

See: openzipkin/zipkin-gcp#175

@codefromthecrypt
Copy link

zipkin-gcp 0.17.0 is on the way now. shading the internal HexCodec thing so it should be safe.

Notably, this fixes the propagation package also, though former is still there. brave.propagation instead of zipkin2.propagation

Finally, this allows you to control the underlying B3PropagationFactory, as mentioned
spring-cloud/spring-cloud-sleuth#1647

One subtle difference 2.2.x to 3.x is the change in the primary inject format.

2.2.x is

return BaggagePropagation.newFactoryBuilder(B3Propagation.newFactoryBuilder()
                         .injectFormat(B3Propagation.Format.MULTI).build());

3.0 is

return BaggagePropagation.newFactoryBuilder(B3Propagation.newFactoryBuilder()
                         .injectFormat(B3Propagation.Format.SINGLE_NO_PARENT).build());

@meltsufin
Copy link
Contributor Author

@adriancole Can you please do a final review of this PR to make sure I configured the propagation factory correctly. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging this pull request may close these issues.

Whitelisted MDC keys in Sleuth are not present when Trace is enabled
3 participants