Skip to content

Commit

Permalink
added context-free endSubsegment to AWSXRay class (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
willarmiros authored Nov 13, 2020
1 parent 96ef948 commit f66c655
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public static Segment beginSegment(String name, TraceID traceId, String parentId
}

/**
* @deprecated Use {@code AWSXray.getGlobalRecorder().beginNoOpSegment() }.
* @deprecated Use {@code AWSXRay.getGlobalRecorder().beginNoOpSegment() }.
*/
@Deprecated
public static Segment beginDummySegment() {
Expand All @@ -124,6 +124,10 @@ public static void endSubsegment() {
globalRecorder.endSubsegment();
}

public static void endSubsegment(@Nullable Subsegment subsegment) {
globalRecorder.endSubsegment(subsegment);
}

@Nullable
public String currentEntityId() {
return globalRecorder.currentEntityId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,12 +562,13 @@ public void endSegment() {
}

/**
* Ends the provided subsegment. This method doesn't touch context storage.
* Ends the provided subsegment. This method doesn't touch context storage and should be used when ending custom subsegments
* in asynchronous methods or other threads.
*
* @param subsegment
* the subsegment to close.
*/
public void endSubsegment(Subsegment subsegment) {
public void endSubsegment(@Nullable Subsegment subsegment) {
if (subsegment == null) {
logger.debug("No input subsegment to end. No-op.");
return;
Expand Down

0 comments on commit f66c655

Please sign in to comment.