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

Add baggage to B3 codec #438

Merged
merged 3 commits into from
Jun 6, 2018
Merged

Conversation

pavolloffay
Copy link
Member

Related to jaegertracing/jaeger#755 (comment)

  • by default uses baggage- prefix
  • it's enabled by default

Signed-off-by: Pavol Loffay [email protected]

@codecov
Copy link

codecov bot commented Jun 5, 2018

Codecov Report

Merging #438 into master will increase coverage by 0.13%.
The diff coverage is 95.65%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #438      +/-   ##
============================================
+ Coverage     87.41%   87.55%   +0.13%     
- Complexity      511      517       +6     
============================================
  Files            65       65              
  Lines          1979     2000      +21     
  Branches        259      263       +4     
============================================
+ Hits           1730     1751      +21     
  Misses          160      160              
  Partials         89       89
Impacted Files Coverage Δ Complexity Δ
...a/io/jaegertracing/propagation/B3TextMapCodec.java 90.38% <95.65%> (+6.51%) 20 <3> (+6) ⬆️

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 9dca4ce...64de258. Read the comment docs.

@pavolloffay
Copy link
Member Author

we should decide whether baggage will be enabled by default or not. However our baggage management is different and separate from the codec. Which makes me think that we can remove enableBaggage from the codec and just use baggage manager. Note that baggage manager applies for all installed codecs. But doing this we are forced to by default enable baggage in B3. On the other hand it will be consistent with our codec.

Brave/Sleuth has to be configured explicitly which keys are whitelisted for propagation.

@yurishkuro
Copy link
Member

+1 to integrate with baggage manager.

@pavolloffay
Copy link
Member Author

Done in the last commit

@pavolloffay
Copy link
Member Author

@yurishkuro could you please review?

@pavolloffay pavolloffay mentioned this pull request Jun 6, 2018
* it's enabled by default
* prefix is configurable

Signed-off-by: Pavol Loffay <[email protected]>
Signed-off-by: Pavol Loffay <[email protected]>
*/
public class B3TextMapCodec implements Codec<TextMap> {
protected static final String TRACE_ID_NAME = "X-B3-TraceId";
protected static final String SPAN_ID_NAME = "X-B3-SpanId";
protected static final String PARENT_SPAN_ID_NAME = "X-B3-ParentSpanId";
protected static final String SAMPLED_NAME = "X-B3-Sampled";
protected static final String FLAGS_NAME = "X-B3-Flags";
protected static final String BAGGAGE_NAME = "baggage-";
Copy link
Contributor

Choose a reason for hiding this comment

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

s/NAME/PREFIX?

// NOTE: uber's flags aren't the same as B3/Finagle ones
protected static final byte SAMPLED_FLAG = 1;
protected static final byte DEBUG_FLAG = 2;

private static final PrefixedKeys keys = new PrefixedKeys();
private final String baggageName;
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto call it prefix instead?

@@ -80,12 +104,37 @@ public SpanContext extract(TextMap carrier) {
if (entry.getValue().equals("1")) {
flags |= DEBUG_FLAG;
}
} else if (entry.getKey().startsWith(BAGGAGE_NAME)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be this.baggageName?

if (baggage == null) {
baggage = new HashMap<String, String>();
}
baggage.put(keys.unprefixedKey(entry.getKey(), BAGGAGE_NAME), entry.getValue());
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Signed-off-by: Pavol Loffay <[email protected]>
@pavolloffay
Copy link
Member Author

@black-adder PR updated.

return new SpanContext(traceId, spanId, parentId, flags);
SpanContext spanContext = new SpanContext(traceId, spanId, parentId, flags);
if (baggage != null) {
spanContext = spanContext.withBaggage(baggage);
Copy link
Contributor

Choose a reason for hiding this comment

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

this is an interesting use case, what if only baggage is propagated without the rest of the trace context?

Copy link
Member Author

Choose a reason for hiding this comment

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

At the moment it's an invalid span context - null

@pavolloffay pavolloffay merged commit 1d57911 into jaegertracing:master Jun 6, 2018
@ghost ghost removed the review label Jun 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants