Implement dogstatsd, add timestamp support, fix flushing#648
Merged
Conversation
ac7357b to
e1a206b
Compare
9708108 to
48eb47d
Compare
duncanista
reviewed
May 7, 2025
| import { logDebug } from "../utils"; | ||
|
|
||
| export class LambdaDogStatsD { | ||
| private static readonly HOST = "localhost"; |
Contributor
There was a problem hiding this comment.
Maybe we set this to 127.0.0.1 instead of localhost, for safety
duncanista
reviewed
May 7, 2025
| return; | ||
| } | ||
| const serializedTags = tags && tags.length ? `|#${this.normalizeTags(tags).join(",")}` : ""; | ||
| const timeStampPart = timestamp != null ? `|T${timestamp}` : ""; |
Contributor
There was a problem hiding this comment.
Suggested change
| const timeStampPart = timestamp != null ? `|T${timestamp}` : ""; | |
| const timestampPart = timestamp != null ? `|T${timestamp}` : ""; |
duncanista
reviewed
May 7, 2025
duncanista
reviewed
May 7, 2025
| } | ||
|
|
||
| const secondsSinceEpoch = Math.floor(metricTime.getTime() / 1000); | ||
| this.statsDClient?.distribution(name, value, secondsSinceEpoch, tags); |
Contributor
There was a problem hiding this comment.
Suggested change
| this.statsDClient?.distribution(name, value, secondsSinceEpoch, tags); | |
| this.statsDClient.distribution(name, value, secondsSinceEpoch, tags); |
duncanista
reviewed
May 7, 2025
Contributor
duncanista
left a comment
There was a problem hiding this comment.
Left some comments – would like to see if we can do millisecond/nanosecond resolution in Extension/Forwarder, just a nit
Contributor
Author
We discussed in Slack but replying here for visibility:
|
duncanista
reviewed
May 8, 2025
| logDebug(`Socket send buffer increased to ${LambdaDogStatsD.MIN_SEND_BUFFER_SIZE / 1024}kb`); | ||
| } | ||
| } catch { | ||
| // ignore |
duncanista
approved these changes
May 8, 2025
nhulston
commented
May 8, 2025
| expect(mockedIncrementInvocations).toBeCalledTimes(1); | ||
| expect(mockedIncrementInvocations).toBeCalledWith(expect.anything(), mockContext); | ||
| expect(logger.debug).toHaveBeenCalledTimes(8); | ||
| expect(logger.debug).toHaveBeenCalledTimes(9); |
Contributor
Author
There was a problem hiding this comment.
we get another debug log for increasing buffer send size
537d86d to
b7967e6
Compare
11 tasks
11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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