Skip to content

Commit 1dbaad3

Browse files
authored
Bump the statsd default packet size (#8967)
## Summary of changes Increases the default packet size used by vendored dogstatsd ## Reason for change Customers can hit the package size limits and payloads are dropped without sending. These were increased upstream in DataDog/dogstatsd-csharp-client#170, but as we're using an older vendored version with older limits. ## Implementation details - Update the limits - Update the vendored code (just for documentation really, we're never going to re-run this vendoring) ## Test coverage Meh ## Other details I considered making this setting actually configurable, but given the upstream code _still_ doesn't have this as configurable, and the Go reference implementation recommends these limits, I think this is probably the best approach
1 parent 9239376 commit 1dbaad3

3 files changed

Lines changed: 18 additions & 3 deletions

File tree

tracer/build/_build/UpdateVendors/VendoredDependency.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,20 @@ private static string ApplyStatsdClientTweaks(string filePath, string content)
549549
"Task.Factory.StartNew(() => Dequeue(), CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default)");
550550
}
551551

552+
if (normalizedPath.EndsWith("StatsdConfig.cs", StringComparison.OrdinalIgnoreCase))
553+
{
554+
// Upstream raised these defaults (512/2048) after 6.0.0 in dogstatsd-csharp-client#170,
555+
// so bump to match them. 1432 keeps a UDP datagram inside a standard 1500-byte MTU, and
556+
// 8192 matches the agent's dogstatsd_buffer_size default (its max packet size).
557+
content = content.Replace(
558+
"public const int DefaultStatsdMaxUDPPacketSize = 512;",
559+
"public const int DefaultStatsdMaxUDPPacketSize = 1432;");
560+
561+
content = content.Replace(
562+
"public int StatsdMaxUnixDomainSocketPacketSize { get; set; } = 2048;",
563+
"public int StatsdMaxUnixDomainSocketPacketSize { get; set; } = 8192;");
564+
}
565+
552566
return content;
553567
}
554568

tracer/src/Datadog.Trace/Vendors/StatsdClient/StatsdConfig.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ internal class StatsdConfig
1717
/// <summary>
1818
/// The default UDP maximum packet size.
1919
/// </summary>
20-
public const int DefaultStatsdMaxUDPPacketSize = 512;
20+
public const int DefaultStatsdMaxUDPPacketSize = 1432;
2121

2222
/// <summary>
2323
/// The name of the environment variable defining the global tags to be applied to every metric, event, and service check.
@@ -97,7 +97,7 @@ public StatsdConfig()
9797
/// Gets or sets the maximum Unix domain socket packet size.
9898
/// </summary>
9999
/// <value>The maximum Unix domain socket packet size.</value>
100-
public int StatsdMaxUnixDomainSocketPacketSize { get; set; } = 2048;
100+
public int StatsdMaxUnixDomainSocketPacketSize { get; set; } = 8192;
101101

102102
/// <summary>
103103
/// Gets or sets a value indicating whether we truncate the metric if it is too long.

tracer/test/Datadog.Trace.TestHelpers/MockTracerAgent.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1623,7 +1623,8 @@ private void HandleUdsStats()
16231623
{
16241624
try
16251625
{
1626-
var bytesReceived = new byte[0x1000];
1626+
// Must be at least StatsdMaxUnixDomainSocketPacketSize
1627+
var bytesReceived = new byte[0x2000];
16271628
// Connectionless protocol doesn't need Accept, Receive will block until we get something
16281629
var byteCount = _udsStatsSocket.Receive(bytesReceived);
16291630
var stats = Encoding.UTF8.GetString(bytesReceived, 0, byteCount);

0 commit comments

Comments
 (0)