@Test public void builderUsesTheProvidedCodexForKeyAndValue() { final KeyConvention keyConvention = new DefaultKeyConvention(); final TextMapCodex codex = new OneAppendingCodex(); final TextMapPropagator propagator = new TextMapPropagator.Builder() .withKeyConvention(keyConvention) .withCodex(codex) .build(); final MapBackedTextMap carrier = new MapBackedTextMap(); final SpanContext spanContext = new SpanContext(UUID.fromString("8557731e-cce9-45c2-9485-1fd86f5116ca"), UUID.fromString("30898bb0-f836-43fb-ad69-44969f15e52d"), UUID.fromString("3a0bc1c1-504f-4f5d-907b-9b4522453bcf")); propagator.inject(spanContext, carrier); Assert.assertEquals("trace-id was not injected correctly", "1-8557731e-cce9-45c2-9485-1fd86f5116ca", carrier.get("1-" + keyConvention.traceIdKey())); Assert.assertEquals("span-id was not injected correctly", "1-30898bb0-f836-43fb-ad69-44969f15e52d", carrier.get("1-" + keyConvention.spanIdKey())); Assert.assertEquals("parent-id was not injected correctly", "1-3a0bc1c1-504f-4f5d-907b-9b4522453bcf", carrier.get("1-" + keyConvention.parentIdKey())); }
@Override public void inject(SpanContext context, TextMap carrier) { put(carrier, convention.traceIdKey(), context.getTraceId().toString()); put(carrier, convention.spanIdKey(), context.getSpanId().toString()); if (context.getParentId() != null) { put(carrier, convention.parentIdKey(), context.getParentId().toString()); } for (Map.Entry<String, String> baggage : context.baggageItems()) { put(carrier, prefixKey(convention.baggagePrefix(), baggage.getKey()), baggage.getValue()); } }
TextMapPropagator implements Injector<TextMap>, Extractor<TextMap> { @Override public void inject(SpanContext context, TextMap carrier) { put(carrier, convention.traceIdKey(), context.getTraceId().toString()); put(carrier, convention.spanIdKey(), context.getSpanId().toString()); if (context.getParentId() != null) { put(carrier, convention.parentIdKey(), context.getParentId().toString()); } for (Map.Entry<String, String> baggage : context.baggageItems()) { put(carrier, prefixKey(convention.baggagePrefix(), baggage.getKey()), baggage.getValue()); } } }
TextMapPropagator implements Injector<TextMap>, Extractor<TextMap> { @Override public void inject(SpanContext context, TextMap carrier) { put(carrier, convention.traceIdKey(), context.getTraceId().toString()); put(carrier, convention.spanIdKey(), context.getSpanId().toString()); if (context.getParentId() != null) { put(carrier, convention.parentIdKey(), context.getParentId().toString()); } for (Map.Entry<String, String> baggage : context.baggageItems()) { put(carrier, prefixKey(convention.baggagePrefix(), baggage.getKey()), baggage.getValue()); } } protected  TextMapPropagator(KeyConvention convention, TextMapCodex keyCodex, TextMapCodex valueCodex); }
TextMapPropagator implements Injector<TextMap>, Extractor<TextMap> { @Override public void inject(SpanContext context, TextMap carrier) { put(carrier, convention.traceIdKey(), context.getTraceId().toString()); put(carrier, convention.spanIdKey(), context.getSpanId().toString()); if (context.getParentId() != null) { put(carrier, convention.parentIdKey(), context.getParentId().toString()); } for (Map.Entry<String, String> baggage : context.baggageItems()) { put(carrier, prefixKey(convention.baggagePrefix(), baggage.getKey()), baggage.getValue()); } } protected  TextMapPropagator(KeyConvention convention, TextMapCodex keyCodex, TextMapCodex valueCodex); @Override String toString(); @Override void inject(SpanContext context, TextMap carrier); @Override SpanContext extract(TextMap carrier); }
TextMapPropagator implements Injector<TextMap>, Extractor<TextMap> { @Override public void inject(SpanContext context, TextMap carrier) { put(carrier, convention.traceIdKey(), context.getTraceId().toString()); put(carrier, convention.spanIdKey(), context.getSpanId().toString()); if (context.getParentId() != null) { put(carrier, convention.parentIdKey(), context.getParentId().toString()); } for (Map.Entry<String, String> baggage : context.baggageItems()) { put(carrier, prefixKey(convention.baggagePrefix(), baggage.getKey()), baggage.getValue()); } } protected  TextMapPropagator(KeyConvention convention, TextMapCodex keyCodex, TextMapCodex valueCodex); @Override String toString(); @Override void inject(SpanContext context, TextMap carrier); @Override SpanContext extract(TextMap carrier);  }