Skip to content

Commit f66c655

Browse files
authored
added context-free endSubsegment to AWSXRay class (#229)
1 parent 96ef948 commit f66c655

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

aws-xray-recorder-sdk-core/src/main/java/com/amazonaws/xray/AWSXRay.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public static Segment beginSegment(String name, TraceID traceId, String parentId
105105
}
106106

107107
/**
108-
* @deprecated Use {@code AWSXray.getGlobalRecorder().beginNoOpSegment() }.
108+
* @deprecated Use {@code AWSXRay.getGlobalRecorder().beginNoOpSegment() }.
109109
*/
110110
@Deprecated
111111
public static Segment beginDummySegment() {
@@ -124,6 +124,10 @@ public static void endSubsegment() {
124124
globalRecorder.endSubsegment();
125125
}
126126

127+
public static void endSubsegment(@Nullable Subsegment subsegment) {
128+
globalRecorder.endSubsegment(subsegment);
129+
}
130+
127131
@Nullable
128132
public String currentEntityId() {
129133
return globalRecorder.currentEntityId();

aws-xray-recorder-sdk-core/src/main/java/com/amazonaws/xray/AWSXRayRecorder.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,12 +562,13 @@ public void endSegment() {
562562
}
563563

564564
/**
565-
* Ends the provided subsegment. This method doesn't touch context storage.
565+
* Ends the provided subsegment. This method doesn't touch context storage and should be used when ending custom subsegments
566+
* in asynchronous methods or other threads.
566567
*
567568
* @param subsegment
568569
* the subsegment to close.
569570
*/
570-
public void endSubsegment(Subsegment subsegment) {
571+
public void endSubsegment(@Nullable Subsegment subsegment) {
571572
if (subsegment == null) {
572573
logger.debug("No input subsegment to end. No-op.");
573574
return;

0 commit comments

Comments
 (0)