Open xiaochuanyu opened 7 years ago
Is there a particular reason why we allow duplicate key/val for tags? I see this in the code: https://github.com/coursera/metrics-datadog/blob/c497e68662b29fb5f2706fe6676b074772979f01/metrics-datadog/src/main/java/org/coursera/metrics/datadog/TaggedName.java#L96-L100 This makes it not possible to overwrite tag values using the builder such as when you want to start with some default values for certain tags but overwrite them later conditionally. The simplest example:
TaggedName.TaggedNameBuilder taggedNameBuilder =new TaggedName.TaggedNameBuilder().metricName("request_rate"); taggedNameBuilder.addTag("host_type", "default"); if (isSpecialCondition()) { taggedNameBuilder.addTag("host_type", "special"); } // etc
To maintain 100% backward compatibility, we can add a setTag(key, value) method that will overwrite or create tag with key/value.
setTag(key, value)
key
value
Is there a particular reason why we allow duplicate key/val for tags? I see this in the code: https://github.com/coursera/metrics-datadog/blob/c497e68662b29fb5f2706fe6676b074772979f01/metrics-datadog/src/main/java/org/coursera/metrics/datadog/TaggedName.java#L96-L100 This makes it not possible to overwrite tag values using the builder such as when you want to start with some default values for certain tags but overwrite them later conditionally. The simplest example:
To maintain 100% backward compatibility, we can add a
setTag(key, value)
method that will overwrite or create tag withkey
/value
.