DD_SERVICE; DD_ENV; DD_VERSION env vars support#1341
Conversation
44bbae6 to
a547030
Compare
devinsba
left a comment
There was a problem hiding this comment.
I'm not ready to approve yet. I need this to read a couple more times. Unfortunately the changes that aren't needed for these 3 environment variables make reviewing this more difficult
randomanderson
left a comment
There was a problem hiding this comment.
A few small issues I commented on
| private static <V extends Enum<V>> Set<V> convertStringSetToEnumSet( | ||
| final Set<String> input, final Class<V> clazz) { | ||
| @NonNull | ||
| private static Set<PropagationStyle> convertStringSetToEnumSet(final Set<String> input) { |
There was a problem hiding this comment.
While I don't necessarily agree with removing the generic enum handling, I can't argue against it because we haven't needed another enum setting 🤷♂
However, with the change, the current method names of:
convertStringSetToEnumSetgetEnumSetSettingFromEnvironmentOrDefaultgetPropertySetValue
are confusing/inaccurate
There was a problem hiding this comment.
My point is we don't need generalisation(generic) if we don't use it for any other type argument more than a year (or some other significant timeline).
All these 3 method names were confusing even before this change, because they were using LinkedHashSet (iterates over elements in the same order they were added to Map) inside and never used actual EnumSet ( https://docs.oracle.com/javase/7/docs/api/java/util/EnumSet.html ) class where iteration order of entries is always the same according to declaration values in Enum. Anyway, it's a good point and I've renamed these 3 methods.
There was a problem hiding this comment.
Given the generic nature of Config, I'd probably vote to leave it, but I don't feel strongly.
On the whole, I find Config both too specific and too generic at the same time.
I really like Config to handle String to primitive conversions better -- especially for List, Maps, but long term, I'd like the details of the precise variables moved elsewhere.
I also find adding a new variable tedious but more importantly error prone. I think a new design could fix that, but I think we should talk through the design first.
tylerbenson
left a comment
There was a problem hiding this comment.
Can this be split up into separate commits/PRs? It seems there are some extra changes that may not make sense.
926365b to
097dc6f
Compare
|
FWIW I think that this needs to be split into two PRs: one with new vars and another one with refactoring changes. And preferably latter having some explanation of what the goal and/or new design is. Otherwise it is really hard to track and understand. |
097dc6f to
6e88ed3
Compare
221ebca to
81777f3
Compare
There was a problem hiding this comment.
ASIDE: I actually feel that the better opportunity to clean-up Config lies in these various static helpers.
Right now, we sprinkle propertyNameToSystemPropertyName, etc around the code, but I think that could be encapsulated. If we made a Config.Lookup helper class, then we could have a few variations...
PropertiesLookup, EnvLookup -- those could handle applying the appropriate name transformation.
Additionally, we could have a CompositeLookup that handles look first at Env then Properties then Parent.
That said, I don't want to do that as part of this PR for a couple reasons.
1 - I'd like to separate bigger refactorings / non-functional changes from functional changes.
It looks like we separated the commits (which is good), but at certain size, I think we should separate the PRs as well. Admittedly, we need to all be better about doing such a separation -- and this PR isn't quite so big that I find it problematic, but I think Config needs a more serious overall and that should be done by itself.
2 - Kind of the same point as above, but I'd like to get the functional change released sooner rather than later. And right now, we're debating largely non-functional pieces, I don't want to add to that the problem by changing Config enen more.
There was a problem hiding this comment.
Isn't this more or less functionally equivalent to enumSet support that came before? Just not public?
There was a problem hiding this comment.
I appreciate the use of MethodHandles. I think we've actually been using reflection in places where we should really be using MethodHandles; however, I'm not sure this is one of those places.
I think just looping over the enum values and checking name is probably a little more intuitive and probably faster, too. (Although, this code shouldn't be performance critical.)
Also, I don't really like exposing a name in the code directly out to the config.
I think this can lead to subtle & surprising breaking changes, but that's a problem that already existed.
There was a problem hiding this comment.
Isn't this more or less functionally equivalent to enumSet support that came before? Just not public?
No. It's not related to "enumSet support that came before". We never used the java.util.EnumSet class here. We only used "enumSet" string in function names, which created confusion and was potentially dangerous before. And it's discussed here: #1341 (comment)
This valueOf method is used for parsing Integer/Boolean/Float/Double:
https://github.com/DataDog/dd-trace-java/pull/1341/files#diff-43038f0f76f33bbf93ca377b0f77ff7aR954
https://github.com/DataDog/dd-trace-java/pull/1341/files#diff-43038f0f76f33bbf93ca377b0f77ff7aR963
https://github.com/DataDog/dd-trace-java/pull/1341/files#diff-43038f0f76f33bbf93ca377b0f77ff7aR974
https://github.com/DataDog/dd-trace-java/pull/1341/files#diff-43038f0f76f33bbf93ca377b0f77ff7aR982
https://github.com/DataDog/dd-trace-java/pull/1341/files#diff-43038f0f76f33bbf93ca377b0f77ff7aR988
https://github.com/DataDog/dd-trace-java/pull/1341/files#diff-43038f0f76f33bbf93ca377b0f77ff7aR1095
https://github.com/DataDog/dd-trace-java/pull/1341/files#diff-43038f0f76f33bbf93ca377b0f77ff7aR1100
https://github.com/DataDog/dd-trace-java/pull/1341/files#diff-43038f0f76f33bbf93ca377b0f77ff7aR1105
81777f3 to
12b5b0a
Compare
dougqh
left a comment
There was a problem hiding this comment.
As I've said in my comments, I think we all agree that we've reached the point where we really need to clean-up Config. I think we need to tackle that in another PR with some discussion first.
That said, I think we're mostly in a good place now. The one part that I'd really like to see reverted is the change to the Config constructor.
done |
tylerbenson
left a comment
There was a problem hiding this comment.
This looks much better. Thanks for the cleanup.
| serviceName = | ||
| getSettingFromEnvironment( | ||
| SERVICE_NAME, getSettingFromEnvironment(SERVICE, DEFAULT_SERVICE_NAME)); |
There was a problem hiding this comment.
from here it looks like the old SERVICE_NAME will take precedence over the new SERVICE, is that the intention?
Introducing support of 3 new java system.properies / environment variables:
tagsand overwrite corresponding keys indd.tags(DD_TAGS) which later become part ofmergedSpanTags.Config::tagsbecome not empty and java system propertydd.trace.global.tagsis totally ignored