aws / aws-xray-java-agent

The official AWS X-Ray Auto Instrumentation Agent for Java.
Apache License 2.0
42 stars 18 forks source link

Xray event emitting does not limit UDP packet size #51

Closed rferreira closed 4 years ago

rferreira commented 4 years ago

Hello folks, it looks like the UDP event emitter doesn't not limit the UDP packet size causing these annoying errors:

java.io.IOException: Message too long
at java.base/java.net.PlainDatagramSocketImpl.send(Native Method)
at java.base/java.net.DatagramSocket.send(DatagramSocket.java:695)
at com.amazonaws.xray.emitters.UDPEmitter.sendData(UDPEmitter.java:106)
at com.amazonaws.xray.emitters.UDPEmitter.sendSegment(UDPEmitter.java:84)
at com.amazonaws.xray.AWSXRayRecorder.sendSegment(AWSXRayRecorder.java:178)
at com.amazonaws.xray.contexts.ThreadLocalSegmentContext.endSubsegment(ThreadLocalSegmentContext.java:77)
at com.amazonaws.xray.AWSXRayRecorder.endSubsegment(AWSXRayRecorder.java:546)
at com.amazonaws.xray.AWSXRay.endSubsegment(AWSXRay.java:111)
at com.amazonaws.xray.sql.mysql.TracingInterceptor$TracingStatementProxy.invoke(TracingInterceptor.java:198)
at com.sun.proxy.$Proxy64.execute(Unknown Source)
at jdk.internal.reflect.GeneratedMethodAccessor25.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.apache.tomcat.jdbc.pool.StatementFacade$StatementProxy.invoke(StatementFacade.java:114)
at com.sun.proxy.$Proxy64.execute(Unknown Source)
at org.jdbi.v3.core.statement.SqlLoggerUtil.wrap(SqlLoggerUtil.java:31)
at org.jdbi.v3.core.statement.SqlStatement.internalExecute(SqlStatement.java:1666)
at org.jdbi.v3.core.result.ResultProducers.lambda$returningUpdateCount$0(ResultProducers.java:49)
at org.jdbi.v3.core.statement.Update.execute(Update.java:53)
at org.jdbi.v3.core.statement.Update.execute(Update.java:41)
at com.scanii.core.models.daos.DistributedLockDao.lambda$acquire$0(DistributedLockDao.java:55)
at org.jdbi.v3.core.transaction.LocalTransactionHandler.inTransaction(LocalTransactionHandler.java:134)
at org.jdbi.v3.core.transaction.LocalTransactionHandler.inTransaction(LocalTransactionHandler.java:158)
at org.jdbi.v3.core.Handle.inTransaction(Handle.java:467)
[...]

According to wikipedia (tm), the datagram packet size limit is 64kb (https://en.wikipedia.org/wiki/User_Datagram_Protocol) and yes, there's no good reason for the trace to be that large, but, in any case, it probably makes sense for xray to discard the trace instead of trying so send the packet and throw an exception.

rferreira commented 4 years ago

oops I should have opened this against the sdk, not the agent, please disregard.

Rafaellinos commented 2 years ago

@rferreira I'm facing the same issue, did you find any solution? I'm using the latest version of SDK and xray-agent