Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,23 @@
*
* @param <C> carrier of propagation fields, such as an http request.
*/
@FunctionalInterface
public interface TextMapGetter<C> {

/**
* Returns all the keys in the given carrier.
*
* <p>The default method returns an empty {@link Iterable}.
*
* @param carrier carrier of propagation fields, such as an http request.
* @since 0.10.0
* @deprecated Propagators should use {@link #get(Object, String)} or {@link #getAll(Object,
* String)} with known fields instead.
*/
Iterable<String> keys(C carrier);
@Deprecated
default Iterable<String> keys(C carrier) {
return Collections.emptyList();
}

/**
* Returns the first value of the given propagation {@code key} or returns {@code null}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ public String get(@Nullable Void carrier, String key) {
}
};

@Test
@SuppressWarnings("deprecation") // Verifies the default behavior of deprecated keys().
void canBeImplementedAsLambda() {
TextMapGetter<Void> getter = (carrier, key) -> "value";

assertThat(getter.get(null, "key")).isEqualTo("value");
assertThat(getter.keys(null)).isEqualTo(Collections.emptyList());
}

@Test
void extendedTextMapGetterdefaultMethod_returnsEmpty() {
Iterator<String> result = nullGet.getAll(null, "key");
Expand Down
7 changes: 6 additions & 1 deletion docs/apidiffs/current_vs_latest/opentelemetry-context.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
Comparing source compatibility of opentelemetry-context-1.64.0-SNAPSHOT.jar against opentelemetry-context-1.63.0.jar
No changes.
*** MODIFIED INTERFACE: PUBLIC ABSTRACT io.opentelemetry.context.propagation.TextMapGetter (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
GENERIC TEMPLATES: === C:java.lang.Object
*** MODIFIED METHOD: PUBLIC NON_ABSTRACT (<- ABSTRACT) java.lang.Iterable<java.lang.String><java.lang.String> keys(java.lang.Object)
+++ NEW ANNOTATION: java.lang.Deprecated
+++ NEW ANNOTATION: java.lang.FunctionalInterface
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ private static <C> SpanContext getSpanContextFromHeader(
}

@Nullable
@SuppressWarnings("deprecation") // Jaeger baggage extraction requires enumerating carrier keys.
private static <C> Baggage getBaggageFromHeader(@Nullable C carrier, TextMapGetter<C> getter) {
BaggageBuilder builder = null;
int entriesAdded = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public <C> void inject(Context context, @Nullable C carrier, TextMapSetter<C> se
}

@Override
@SuppressWarnings("deprecation") // OT trace baggage extraction requires enumerating carrier keys.
public <C> Context extract(Context context, @Nullable C carrier, TextMapGetter<C> getter) {
if (context == null) {
return Context.root();
Expand Down
Loading