ExtraFieldPropagation implements Propagation<K> { @Deprecated public static FactoryBuilder newFactoryBuilder(Propagation.Factory delegate) { return new FactoryBuilder(delegate); } ExtraFieldPropagation(Propagation<K> delegate, List<K> extraKeys); @Deprecated static Factory newFactory(Propagation.Factory delegate, String... names); @Deprecated static Factory newFactory(Propagation.Factory delegate,
    Collection<String> names); @Deprecated static FactoryBuilder newFactoryBuilder(Propagation.Factory delegate); @Deprecated @Nullable static String current(String name); @Deprecated @Nullable static String get(String name); @Deprecated static void set(String name, String value); @Deprecated static Map<String, String> getAll(); @Deprecated static Map<String, String> getAll(TraceContextOrSamplingFlags extracted); @Deprecated static Map<String, String> getAll(TraceContext context); @Deprecated @Nullable static String get(TraceContext context, String name); @Deprecated static void set(TraceContext context, String name, String value); @Deprecated List<K> extraKeys(); @Override List<K> keys(); @Override Injector<R> injector(Setter<R, K> setter); @Override Extractor<R> extractor(Getter<R, K> getter);  }
@Test public void inject_prefixed() { factory = newFactoryBuilder(B3Propagation.FACTORY) .addField("x-vcap-request-id") .addPrefixedFields("baggage-", asList("country-code")) .build(); initialize(); BaggageField.getByName(context, "x-vcap-request-id").updateValue(context, uuid); BaggageField.getByName(context, "country-code").updateValue(context, "FO"); injector.inject(context, request); assertThat(request) .containsEntry("baggage-country-code", "FO") .containsEntry("x-vcap-request-id", uuid); }
@Test public void extract_prefixed() { factory = newFactoryBuilder(B3Propagation.FACTORY) .addField("x-vcap-request-id") .addPrefixedFields("baggage-", asList("country-code")) .build(); initialize(); injector.inject(context, request); request.put("baggage-country-code", "FO"); request.put("x-vcap-request-id", uuid); TraceContextOrSamplingFlags extracted = extractor.extract(request); assertThat(extracted.context().toBuilder().extra(Collections.emptyList()).build()) .isEqualTo(context); assertThat(extracted.context().extra()) .hasSize(2); assertThat(BaggageField.getByName(extracted, "country-code").getValue(extracted)) .isEqualTo("FO"); assertThat(BaggageField.getByName(extracted, "x-vcap-request-id").getValue(extracted)) .isEqualTo(uuid); }
@Test public void deduplicates() { assertThat(newFactoryBuilder(B3SinglePropagation.FACTORY) .addField("country-code") .addPrefixedFields("baggage-", asList("country-code")) .addPrefixedFields("baggage_", asList("country-code")) .build()) .usingRecursiveComparison().isEqualTo( newFactoryBuilder(B3SinglePropagation.FACTORY) .addField("country-code").addField("country-code") .addPrefixedFields("baggage-", asList("country-code", "country-code")) .addPrefixedFields("baggage_", asList("country-code", "country-code")) .build() ); }