Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert subsegment synchronization changes #350

Merged
merged 10 commits into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,24 +83,21 @@ public boolean sendSegment(Segment segment) {
if (logger.isDebugEnabled()) {
logger.debug(segment.prettySerialize());
}
if (segment.compareAndSetEmitted(false, true)) {
byte[] bytes = (PROTOCOL_HEADER + PROTOCOL_DELIMITER + segment.serialize()).getBytes(StandardCharsets.UTF_8);

byte[] bytes = (PROTOCOL_HEADER + PROTOCOL_DELIMITER + segment.serialize()).getBytes(StandardCharsets.UTF_8);

if (bytes.length > UDP_PACKET_LIMIT) {
List<Subsegment> subsegments = segment.getSubsegmentsCopy();
logger.debug("Segment too large, sending subsegments to daemon first. bytes " + bytes.length + " subsegemnts "
+ subsegments.size());
for (Subsegment subsegment : subsegments) {
sendSubsegment(subsegment);
segment.removeSubsegment(subsegment);
}
bytes = (PROTOCOL_HEADER + PROTOCOL_DELIMITER + segment.serialize()).getBytes(StandardCharsets.UTF_8);
logger.debug("New segment size. bytes " + bytes.length);
if (bytes.length > UDP_PACKET_LIMIT) {
List<Subsegment> subsegments = segment.getSubsegmentsCopy();
logger.debug("Segment too large, sending subsegments to daemon first. bytes " + bytes.length + " subsegemnts "
+ subsegments.size());
for (Subsegment subsegment : subsegments) {
sendSubsegment(subsegment);
segment.removeSubsegment(subsegment);
}
return sendData(bytes, segment);
} else {
return false;
bytes = (PROTOCOL_HEADER + PROTOCOL_DELIMITER + segment.serialize()).getBytes(StandardCharsets.UTF_8);
logger.debug("New segment size. bytes " + bytes.length);
}
return sendData(bytes, segment);
}

/**
Expand All @@ -113,13 +110,8 @@ public boolean sendSubsegment(Subsegment subsegment) {
if (logger.isDebugEnabled()) {
logger.debug(subsegment.prettyStreamSerialize());
}
if (subsegment.compareAndSetEmitted(false, true)) {
return sendData((PROTOCOL_HEADER + PROTOCOL_DELIMITER +
subsegment.streamSerialize()).getBytes(StandardCharsets.UTF_8),
subsegment);
} else {
return false;
}
return sendData((PROTOCOL_HEADER + PROTOCOL_DELIMITER + subsegment.streamSerialize()).getBytes(StandardCharsets.UTF_8),
subsegment);
}

private boolean sendData(byte[] data, Entity entity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ default void run(Runnable runnable, AWSXRayRecorder recorder) {
void setNamespace(String namespace);

/**
* @return an unused {@link ReentrantLock}
* @return the subsegmentsLock
*
* @deprecated This is for internal use of the SDK and will be made private.
*/
Expand Down Expand Up @@ -601,15 +601,17 @@ default void run(Runnable runnable, AWSXRayRecorder recorder) {
boolean isEmitted();

/**
* @deprecated Use {@link #compareAndSetEmitted(boolean, boolean)}
* Sets emitted on the entity.
*/
@Deprecated
void setEmitted(boolean emitted);

/**
* Checks whether this {@link Entity} currently has emitted state of {@code current} and if so, set emitted state to
* {@code next}. Returns {@code true} if the state was updated, or {@code false} otherwise.
*
* @deprecated Use {@link #setEmitted(boolean)}
*/
@Deprecated
boolean compareAndSetEmitted(boolean current, boolean next);

String serialize();
Expand Down
Loading