diff --git a/src/Communication/Jaeger.Communication.Thrift/Senders/ThriftSenderBase.cs b/src/Communication/Jaeger.Communication.Thrift/Senders/ThriftSenderBase.cs
index 79fbf30c4..fa7bbd8e0 100644
--- a/src/Communication/Jaeger.Communication.Thrift/Senders/ThriftSenderBase.cs
+++ b/src/Communication/Jaeger.Communication.Thrift/Senders/ThriftSenderBase.cs
@@ -21,8 +21,8 @@ public enum ProtocolType
protected int MaxSpanBytes { get; }
- /// Protocol type (compact or binary)If 0 it will use default value .
+ /// Protocol type (compact or binary)
+ /// If 0 it will use default value .
public ThriftSenderBase(ProtocolType protocolType, int maxPacketSize)
{
switch (protocolType)
diff --git a/src/Senders/Jaeger.Senders.Thrift/UdpSender.cs b/src/Senders/Jaeger.Senders.Thrift/UdpSender.cs
index 3ca96fa90..1f72a931a 100644
--- a/src/Senders/Jaeger.Senders.Thrift/UdpSender.cs
+++ b/src/Senders/Jaeger.Senders.Thrift/UdpSender.cs
@@ -36,11 +36,10 @@ public UdpSender()
/// If empty it will use .
/// If 0 it will use .
- /// If 0 it will use .
+ /// If 0 it will use . Must not exceed .
public UdpSender(string host, int port, int maxPacketSize)
: base(ProtocolType.Compact, maxPacketSize)
{
-
if (string.IsNullOrEmpty(host))
{
host = DefaultAgentUdpHost;
@@ -51,6 +50,12 @@ public UdpSender(string host, int port, int maxPacketSize)
port = DefaultAgentUdpCompactPort;
}
+ if (maxPacketSize > ThriftUdpClientTransport.MaxPacketSize)
+ {
+ throw new NotSupportedException($"Using a packet size bigger than {ThriftUdpClientTransport.MaxPacketSize} "
+ + "can lead to lost traces and is therefore not supported.");
+ }
+
_udpTransport = new ThriftUdpClientTransport(host, port);
_agentClient = new Agent.Client(ProtocolFactory.GetProtocol(_udpTransport));
}
diff --git a/test/Senders/Jaeger.Senders.Thrift.Tests/UdpSenderTests.cs b/test/Senders/Jaeger.Senders.Thrift.Tests/UdpSenderTests.cs
new file mode 100644
index 000000000..3c9dec4ff
--- /dev/null
+++ b/test/Senders/Jaeger.Senders.Thrift.Tests/UdpSenderTests.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Net.Sockets;
+using System.Reflection;
+using Jaeger.Reporters;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Logging.Abstractions;
+using OpenTracing.Noop;
+using OpenTracing.Util;
+using Xunit;
+
+namespace Jaeger.Senders.Thrift.Tests
+{
+ public class UdpSenderTests
+ {
+ [Fact]
+ public void TestSenderWithAgentDataFromEnv()
+ {
+ Assert.Throws(() => new UdpSender("jaeger-agent", 6832, 65535));
+ }
+ }
+}