-
Notifications
You must be signed in to change notification settings - Fork 846
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactors the PR so that we have a separate internal ExtendedTextMapG…
…etter, as per review. Also changes the return type of the method to Iterator<String> as per review, and renames the method to getAll(). Tests are also adjusted
- Loading branch information
1 parent
6f13bfb
commit 3cd5429
Showing
4 changed files
with
82 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...xt/src/main/java/io/opentelemetry/context/internal/propagation/ExtendedTextMapGetter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.context.internal.propagation; | ||
|
||
import io.opentelemetry.context.propagation.TextMapGetter; | ||
import java.util.Collections; | ||
import java.util.Iterator; | ||
import javax.annotation.Nullable; | ||
|
||
/** | ||
* Extends {@link TextMapGetter} to return possibly multiple values for a given key. | ||
* | ||
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change | ||
* at any time. | ||
* | ||
* @param <C> carrier of propagation fields, such as an http request. | ||
*/ | ||
public interface ExtendedTextMapGetter<C> extends TextMapGetter<C> { | ||
/** | ||
* If implemented, returns all values for a given {@code key} in order, or returns an empty list. | ||
* | ||
* <p>The default method returns the first value of the given propagation {@code key} as a | ||
* singleton list, or returns an empty list. | ||
* | ||
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change | ||
* at any time. | ||
* | ||
* @param carrier carrier of propagation fields, such as an http request. | ||
* @param key the key of the field. | ||
* @return all values for a given {@code key} in order, or returns an empty list. Default method | ||
* wraps {@code get()} as an {@link Iterator}. | ||
*/ | ||
default Iterator<String> getAll(@Nullable C carrier, String key) { | ||
String first = get(carrier, key); | ||
return Collections.singleton(first).iterator(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters