Skip to content

Commit

Permalink
Revert subsegment synchronization changes (#350)
Browse files Browse the repository at this point in the history
* Revert "Don't lock segment from subsegment (#306)"

This reverts commit d5ccae2.

* Revert "Keep track of emitted in emitter. (#279)"

This reverts commit d66d69a.

* Revert "Remove subsegments lock (#278)"

This reverts commit adfb395.

* Revert "Lock all accesses to entities. (#250)"

This reverts commit f0a3b3a.

* add back errorprone annotations

* fixed shouldPropagate

* added back getSubsegmentsCopy

* added back compareAndSetEmitted

* whitespace fix
  • Loading branch information
willarmiros authored Aug 22, 2022
1 parent d097192 commit 39ab1cc
Show file tree
Hide file tree
Showing 10 changed files with 285 additions and 474 deletions.
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

0 comments on commit 39ab1cc

Please sign in to comment.