-
Notifications
You must be signed in to change notification settings - Fork 39
Implement dogstatsd, add timestamp support, fix flushing #648
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
Conversation
ac7357b to
e1a206b
Compare
9708108 to
48eb47d
Compare
src/metrics/dogstatsd.ts
Outdated
| import { logDebug } from "../utils"; | ||
|
|
||
| export class LambdaDogStatsD { | ||
| private static readonly HOST = "localhost"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we set this to 127.0.0.1 instead of localhost, for safety
src/metrics/dogstatsd.ts
Outdated
| return; | ||
| } | ||
| const serializedTags = tags && tags.length ? `|#${this.normalizeTags(tags).join(",")}` : ""; | ||
| const timeStampPart = timestamp != null ? `|T${timestamp}` : ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const timeStampPart = timestamp != null ? `|T${timestamp}` : ""; | |
| const timestampPart = timestamp != null ? `|T${timestamp}` : ""; |
src/metrics/listener.ts
Outdated
| } | ||
|
|
||
| const secondsSinceEpoch = Math.floor(metricTime.getTime() / 1000); | ||
| this.statsDClient?.distribution(name, value, secondsSinceEpoch, tags); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| this.statsDClient?.distribution(name, value, secondsSinceEpoch, tags); | |
| this.statsDClient.distribution(name, value, secondsSinceEpoch, tags); |
duncanista
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments – would like to see if we can do millisecond/nanosecond resolution in Extension/Forwarder, just a nit
We discussed in Slack but replying here for visibility:
|
src/metrics/dogstatsd.ts
Outdated
| logDebug(`Socket send buffer increased to ${LambdaDogStatsD.MIN_SEND_BUFFER_SIZE / 1024}kb`); | ||
| } | ||
| } catch { | ||
| // ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a debug log
src/index.spec.ts
Outdated
| expect(mockedIncrementInvocations).toBeCalledTimes(1); | ||
| expect(mockedIncrementInvocations).toBeCalledWith(expect.anything(), mockContext); | ||
| expect(logger.debug).toHaveBeenCalledTimes(8); | ||
| expect(logger.debug).toHaveBeenCalledTimes(9); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we get another debug log for increasing buffer send size
537d86d to
b7967e6
Compare
What does this PR do?
hot-shotsflush. The previous implementation just closed the UDP socket on "flush" which actually just drops any unsent UDP packets, leading to lost metrics.Motivation
hot-shotsdid not support metrics with timestamps, so originally we just sent metrics directly using the Datadog APITesting Guidelines
sendDistributionMetricandsendDistributionMetricWithDate. Both work!Additional Notes
Types of Changes
Check all that apply
https://datadoghq.atlassian.net/browse/SVLS-6785