aws / aws/aws-xray-sdk-java

"Segment has already been emitted" when streaming

Open
#69 14 comments 0 reactions 1 assignee Claimed by @willarmiros View on GitHub
bug
Dominant language
Java
Stars
100
Forks
100
PR merge metrics
No merged PRs in 30d

Description

SDK version: 2.2.1
Java version: 1.8.0_202

We've run into the known issue of [large traces not sending correctly over UDP](https://github.com/aws/aws-xray-sdk-java/issues/4) so had enabled streaming with the `DefaultStreamingStrategy`, and configured it to stream in chunks of 10. However, we see a large number of errors in the logs like this:

```
com.amazonaws.xray.exceptions.AlreadyEmittedException: Segment foo has already been emitted.
```

It looks like `DefaultStreamingStrategy` is careful to [lock and unlock](https://github.com/aws/aws-xray-sdk-java/blob/master/aws-xray-recorder-sdk-core/src/main/java/com/amazonaws/xray/strategy/DefaultStreamingStrategy.java#L73) access to the list of subsegments in a trace, to avoid synchronization issues. However, this lock is *not* checked (as far as I can see) when the whole trace is finished - meaning it's possible that X-Ray attempts to stream the same segments twice.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.