Improve clarity on non-acceptable metric name formats
solodynamo-dhero opened this issue · 1 comments
datadog-agent image version: datadog/cluster-agent:1.9.0
datadog-go version: v4.4.0
Issue:
metric name: "db.cache.status:hit"
usage: s.datadogClient.Count("db.cache.status:hit", 1, nil, 1)
Above will fail on runtime with error:
2021-07-28 09:22:25 UTC | CORE | ERROR | (pkg/dogstatsd/server.go:422 in errLog) | Dogstatsd: error parsing metric message '"db.cache.status:hit:1|c|#env:production,service:some-service version:production--27a9a01"': could not parse dogstatsd metric value: strconv.ParseFloat: parsing "hit:1": invalid syntax
Reason:
forwarder logic calls this function
It separates the name from a value using ":" as a separator.
In my case, it will set the value = hit:1 which is wrong and while parsing to float64 it will fail.
Possible Solution:
We should have validation check on metric functions to reject such names or at least document them so other devs don't face such an issue.
Let me know if any other info is needed ✌️
Also, I came across this doc: https://docs.datadoghq.com/metrics/custom_metrics/#naming-custom-metrics
:
is a non-alphanumeric character.
It does state that we should use only ASCII alphanumeric character
By document, we can have Godoc like ones so IntelliSense can expose such details.