-
Notifications
You must be signed in to change notification settings - Fork 916
Promote getAll to TextMapGetter stable API #7267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,8 @@ | |
|
|
||
| package io.opentelemetry.context.propagation; | ||
|
|
||
| import java.util.Collections; | ||
| import java.util.Iterator; | ||
| import javax.annotation.Nullable; | ||
|
|
||
| /** | ||
|
|
@@ -33,4 +35,26 @@ public interface TextMapGetter<C> { | |
| */ | ||
| @Nullable | ||
| String get(@Nullable C carrier, String key); | ||
|
|
||
| /** | ||
| * 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) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm late to reviewing this, but it was brought to my attention due to micrometer-metrics/tracing#1032. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see there was previous discussion on this in #6852 (comment), with the motivation being to avoid copying from the Enumeration that Servlet spec returns for headers. I think that could be achieved even with the API using
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand the feedback here - but yeah unfortunately it's too late given this is now stable, it will be very difficult to change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the response.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please open a new issue to discuss. Hard to stay on top of comments of closed PRs
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could add something like default Iterator<String> getAll(@Nullable C carrier, String key) {
return getAllValues(carrier, key).iterator();
}
default Iterable<String> getAllValues(@Nullable C carrier, String key) {
String first = get(carrier, key);
if (first == null) {
return Collections.emptyList();
}
return Collections.singleton(first);
}and deprecate the old method if you so wish. |
||
| String first = get(carrier, key); | ||
| if (first == null) { | ||
| return Collections.emptyIterator(); | ||
| } | ||
| return Collections.singleton(first).iterator(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,5 @@ | ||
| Comparing source compatibility of opentelemetry-context-1.50.0-SNAPSHOT.jar against opentelemetry-context-1.49.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 | ||
| +++ NEW METHOD: PUBLIC(+) java.util.Iterator<java.lang.String> getAll(java.lang.Object, java.lang.String) |
Uh oh!
There was an error while loading. Please reload this page.