File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
context/src/main/java/io/opentelemetry/context/propagation Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 55
66package io .opentelemetry .context .propagation ;
77
8+ import java .util .Collections ;
9+ import java .util .List ;
810import javax .annotation .Nullable ;
911
1012/**
@@ -33,4 +35,20 @@ public interface TextMapGetter<C> {
3335 */
3436 @ Nullable
3537 String get (@ Nullable C carrier , String key );
38+
39+ /**
40+ * If implemented, returns all values for a given {@code key}, in order.
41+ *
42+ * <p>The default method returns the first value of the given propagation {@code key} as a
43+ * singleton list, or returns an empty list.
44+ *
45+ * @param carrier carrier of propagation fields, such as an http request.
46+ * @param key the key of the field.
47+ * @return the first value of the given propagation {@code key} as a singleton list, or returns an
48+ * empty list.
49+ */
50+ default List <String > getList (@ Nullable C carrier , String key ) {
51+ String first = get (carrier , key );
52+ return first == null ? Collections .emptyList () : Collections .singletonList (first );
53+ }
3654}
You can’t perform that action at this time.
0 commit comments