pkg icon indicating copy to clipboard operation
pkg copied to clipboard

metrics: deduplicate tags on insertion into registry

Open najork opened this issue 6 years ago • 0 comments

This library currently uses a slice to store tags [0]. However, Witchcraft converts the tags to a map when emitting them [1]. Even though the lossy behavior of converting the tag slice to a map is well-documented [2], it makes it difficult to debug issues involving multiple instances of the same tag key getting added to the metrics registry since the internal state diverges from what is logged. Since the Witchcraft spec defines a tag as a map<string, string> [3], let's move the deduplication of tags earlier in the pipeline such that it happens on insertion into the registry.

[0] https://github.com/palantir/pkg/blob/master/metrics/tag.go#L36 [1] https://github.com/palantir/witchcraft-go-server/blob/develop/witchcraft/server_metrics.go#L42 [2] https://github.com/palantir/pkg/blob/master/metrics/tag.go#L46-L49 [3] https://github.com/palantir/witchcraft-api/blob/master/witchcraft-logging-api/src/main/conjure/witchcraft-logging-api.yml#L369-L370

najork avatar Oct 25 '19 15:10 najork