Add get to TextMap
See original GitHub issueI complained about this a couple years ago, but re-complaining as it seems possible some things can change now.
TextMap is accidentally constrained to an awkward pattern where you can add keys by name, but not retrieve by name. This is awkward because getting by name involves creating an iterator then scanning it. It also encourages people to cast to vendor types like this for routine functionality.
I got bored looking to find a single implementation of TextMap that doesn’t support get by name natively or that doesn’t instantiate an intermediate java Map due to the awkwardness! The net result is guaranteed less efficient operations for the most common propagation use cases.
Can we please fix this as it will remove a lot of spaghetti. The fix is to add @Nullable String get(String key)
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (6 by maintainers)
Top GitHub Comments
The current method
Iterator<Map.Entry<String, String>> iterator();
also suggests that multi-values are not expected (although technically, there could be multiple entries with the same key). I’m not sure if those would be needed for the tracing use-case. I’d say, the adapter should get the first header. If you think there is a use case to get the list of headers, I’d add two methods, so that no objects have to be allocated for the common case:@Nullable String getFirst(String key)
List<String> get(String key)
Otherwise, big +1. Seems like a no-brainer to me.
Yeah, sgtm.