Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow customizing timer units in Datadog export #184

Merged
merged 3 commits into from
Jun 27, 2023

Conversation

bluekeyes
Copy link
Member

The metrics.Timer type natively reports in nanoseconds, which is usually too small to be useful. Applications can now set the TimerUnits global variable to a different unit to scale values before they are sent to Datadog. We set the default value to nanoseconds for compatibility.

This may change how we report request latency in #181.

The metrics.Timer type natively reports in nanoseconds, which is usually
too small to be useful. Applications can now set the TimerUnits global
variable to a different unit to scale values before they are sent to
Datadog. We set the default value to nanoseconds for compatibility.
baseapp/datadog/datadog.go Outdated Show resolved Hide resolved
@bluekeyes bluekeyes requested a review from a team June 26, 2023 23:43
@@ -145,13 +156,13 @@ func (e *Emitter) EmitOnce() {

case metrics.Timer:
ms := m.Snapshot()
_ = e.client.Gauge(name+".avg", ms.Mean(), tags, 1)
_ = e.client.Gauge(name+".avg", convertTime(ms.Mean()), tags, 1)
_ = e.client.Gauge(name+".count", float64(ms.Count()), tags, 1)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Count() returns a count of events, not a time, so it doesn't need conversion.

@bluekeyes bluekeyes merged commit 1c3eac8 into develop Jun 27, 2023
3 checks passed
@bluekeyes bluekeyes deleted the bkeyes/timer-units branch June 27, 2023 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants