Skip to content

Commit

Permalink
Fix checkstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
majanjua-amzn committed May 6, 2024
1 parent ed061be commit 8ba9ff8
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.amazonaws.xray.entities.Subsegment;
import com.amazonaws.xray.entities.SubsegmentImpl;
import com.amazonaws.xray.entities.TraceHeader;
import com.amazonaws.xray.entities.TraceHeader.SampleDecision;
import com.amazonaws.xray.entities.TraceID;
import com.amazonaws.xray.exceptions.SubsegmentNotFoundException;
import com.amazonaws.xray.listeners.SegmentListener;
Expand All @@ -36,14 +35,14 @@ public class LambdaSegmentContext implements SegmentContext {
private static final Log logger = LogFactory.getLog(LambdaSegmentContext.class);

private static final String LAMBDA_TRACE_HEADER_KEY = "_X_AMZN_TRACE_ID";

// See: https://github.com/aws/aws-xray-sdk-java/issues/251
private static final String LAMBDA_TRACE_HEADER_PROP = "com.amazonaws.xray.traceHeader";

private static TraceHeader getTraceHeaderFromEnvironment() {
String lambdaTraceHeaderKey = System.getenv(LAMBDA_TRACE_HEADER_KEY);
return TraceHeader.fromString(lambdaTraceHeaderKey != null && lambdaTraceHeaderKey.length() > 0
? lambdaTraceHeaderKey
return TraceHeader.fromString(lambdaTraceHeaderKey != null && lambdaTraceHeaderKey.length() > 0
? lambdaTraceHeaderKey
: System.getProperty(LAMBDA_TRACE_HEADER_PROP));
}

Expand All @@ -67,7 +66,12 @@ public Subsegment beginSubsegment(AWSXRayRecorder recorder, String name) {
}
parentSegment = Segment.noOp(TraceID.create(recorder), recorder);
} else {
parentSegment = new FacadeSegment(recorder, traceHeader.getRootTraceId(), traceHeader.getParentId(), traceHeader.getSampled());
parentSegment = new FacadeSegment(
recorder,
traceHeader.getRootTraceId(),
traceHeader.getParentId(),
traceHeader.getSampled()
);
}

boolean isRecording = parentSegment.isRecording();
Expand Down Expand Up @@ -145,8 +149,7 @@ public void endSubsegment(AWSXRayRecorder recorder) {
current.getCreator().getEmitter().sendSubsegment((Subsegment) current);
}
clearTraceEntity();
}
else if (parentEntity instanceof NoOpSegment) {
} else if (parentEntity instanceof NoOpSegment) {
clearTraceEntity();
} else {
setTraceEntity(current.getParent());
Expand Down

0 comments on commit 8ba9ff8

Please sign in to comment.