-
Notifications
You must be signed in to change notification settings - Fork 55
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
Prefer b3 to x-cloud-trace in extractor #97
Prefer b3 to x-cloud-trace in extractor #97
Conversation
Looks good to me. Note that this PR doesn't inject the |
@adriancole Friendly ping. |
private static final String XCLOUD_VALUE = "c108dc108dc108dc108dc108dc108d00"; | ||
private static final String B3_HEADER = "b3"; | ||
private static final String B3_TRACE_ID = "b3b3b3b3b3b34da6a3ce929d0e0e4736"; | ||
private static final String B3_VALUE = String.format("%s-00f067aa0ba902b7-1", B3_TRACE_ID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super-nit: normal string cat is probably less distracting here :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for adding the test and the docs. I have some suggestions for the test.
@Test | ||
public void b3TakesPrecedenceOverXCloud() { | ||
TraceContext.Extractor<String> extractor = | ||
propagation.extractor(new FakeGetter(XCLOUD_VALUE, B3_VALUE)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea in general, but I think the FakeGetter makes it less clear, what's going on, vs just using a normal map.
For example, you can initialize an empty mutable map as a field named headers (ps no need to mark fields in a test as private as the keyword is cluttery). You can also initialize a map extractor as a field (ex propagation.extractor(Map::get))
Then, in each test use the actual values you want by setting them in the map. It will look more
headers.put(TRACE_ID_NAME, XCLOUD_VALUE);
TraceContextOrSamplingFlags extracted = extractor.extract(headers);
Imho, it reads easier... less distractions, such as "what is the fake getter doing" and "what is this unused object?" It also is much more like normal usage.
@adriancole Thanks for the suggestion; the tests are now much cleaner! |
thanks! |
@adriancole Could you cut a release for this fix? Then we can pull it into spring-cloud-gcp and close spring-attic/spring-cloud-gcp#1019. |
can do tomorrow morning. waiting on a brave patch.
… |
Thanks! |
0.8.3 out and ready cc @anuraaga
…On Wed, Oct 17, 2018 at 9:32 PM elefeint ***@***.***> wrote:
Thanks!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#97 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAD615ZmEzR-7-QkdEnNbYYO4YwBTyAyks5ulzF8gaJpZM4XKREa>
.
|
Addresses mismatch between extractor (which used to prefer X-cloud headers) and injector (which propagates b3 headers) by preferring b3 headers, when available.
Fixes #96 .