GH-987 feat: propagate aws x-ray tracing header

Resolves #987
Resolves #988
This commit is contained in:
amond
2023-01-17 03:01:45 +09:00
committed by Oleg Zhurakousky
parent 4dcf0be7b3
commit 17c22b4e87

View File

@@ -147,6 +147,21 @@ public final class CustomRuntimeEventLoop implements SmartLifecycle {
String invocationUrl = MessageFormat
.format(LAMBDA_INVOCATION_URL_TEMPLATE, runtimeApi, LAMBDA_VERSION_DATE, requestId);
String traceId = response.getHeaders().getFirst("Lambda-Runtime-Trace-Id");
if (traceId != null) {
if (logger.isDebugEnabled()) {
logger.debug("Lambda-Runtime-Trace-Id: " + traceId);
}
try {
// The X-Ray SDK uses this value to connect trace data between services.
System.setProperty("com.amazonaws.xray.traceHeader", traceId);
} catch (Exception e) {
if (logger.isDebugEnabled()) {
logger.debug("Failed to set amazon x-ray trace id", e);
}
}
}
try {
Message<byte[]> responseMessage = (Message<byte[]>) function.apply(eventMessage);