mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat(lambda): give each durable execution an X-Ray trace header (#8161)
This commit is contained in:
1 parent
55b2fb7bd3
commit
f5e581a872
23 files changed
+510
-53
No files matched your search
@@ -0,0 +1,30 @@
|
||||
package io.floci.aws.core.common;
|
||||
|
||||
import java.util.HexFormat;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
/** Ids in the formats X-Ray uses in an {@code X-Amzn-Trace-Id} header. */
|
||||
public final class XRayTraceIds {
|
||||
|
||||
private static final int TRACE_RANDOM_BYTES = 12;
|
||||
|
||||
private XRayTraceIds() {
|
||||
}
|
||||
|
||||
/** {@code 1-<8 hex digits of epoch seconds>-<24 random hex digits>}. */
|
||||
public static String traceId(long epochSeconds) {
|
||||
byte[] id = new byte[TRACE_RANDOM_BYTES];
|
||||
ThreadLocalRandom.current().nextBytes(id);
|
||||
return "1-" + String.format("%08x", epochSeconds) + "-" + HexFormat.of().formatHex(id);
|
||||
}
|
||||
|
||||
/** 16 random lowercase hex digits, never all zeros. */
|
||||
public static String segmentId() {
|
||||
ThreadLocalRandom random = ThreadLocalRandom.current();
|
||||
long value;
|
||||
do {
|
||||
value = random.nextLong();
|
||||
} while (value == 0);
|
||||
return HexFormat.of().toHexDigits(value);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
package io.floci.aws.services.elbv2;
|
||||
|
||||
import io.floci.aws.core.common.XRayTraceIds;
|
||||
import io.vertx.core.MultiMap;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HexFormat;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
/**
|
||||
* The {@code X-Amzn-Trace-Id} header an Application Load Balancer adds or updates before it sends a
|
||||
@@ -59,8 +58,6 @@ final class ElbV2TraceHeader {
|
||||
}
|
||||
|
||||
private static String traceId() {
|
||||
byte[] id = new byte[12];
|
||||
ThreadLocalRandom.current().nextBytes(id);
|
||||
return "1-" + String.format("%08x", Instant.now().getEpochSecond()) + "-" + HexFormat.of().formatHex(id);
|
||||
return XRayTraceIds.traceId(Instant.now().getEpochSecond());
|
||||
}
|
||||
}
|
||||
@@ -270,7 +270,7 @@ public class LambdaController {
|
||||
String durableExecutionName = headers.getHeaderString("X-Amz-Durable-Execution-Name");
|
||||
|
||||
InvokeResult result = lambdaService.invoke(region, functionName, qualifier, payload, type, clientContext,
|
||||
durableExecutionName);
|
||||
durableExecutionName, headers.getHeaderString("X-Amzn-Trace-Id"));
|
||||
|
||||
if (type != InvocationType.Event
|
||||
&& result.getPayload() != null
|
||||
|
||||
@@ -168,7 +168,12 @@ public class LambdaExecutorService implements Resettable {
|
||||
}
|
||||
|
||||
public InvokeResult invoke(LambdaFunction fn, byte[] payload, InvocationType type, String requestId) {
|
||||
return invoke(fn, payload, type, 0, null, null, requestId, null);
|
||||
return invoke(fn, payload, type, 0, null, null, requestId, null, null);
|
||||
}
|
||||
|
||||
public InvokeResult invoke(LambdaFunction fn, byte[] payload, InvocationType type, String requestId,
|
||||
String traceId) {
|
||||
return invoke(fn, payload, type, 0, null, null, requestId, null, traceId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -193,7 +198,7 @@ public class LambdaExecutorService implements Resettable {
|
||||
InvokeResult invoke(LambdaFunction fn, byte[] payload, InvocationType type, int chainDepth,
|
||||
String invokedQualifier, String clientContext) {
|
||||
return invoke(fn, payload, type, chainDepth, invokedQualifier, clientContext, UUID.randomUUID().toString(),
|
||||
null);
|
||||
null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -203,12 +208,12 @@ public class LambdaExecutorService implements Resettable {
|
||||
public InvokeResult invokeStreaming(LambdaFunction fn, byte[] payload, int chainDepth, String invokedQualifier,
|
||||
ResponseStreamListener listener) {
|
||||
return invoke(fn, payload, InvocationType.RequestResponse, chainDepth, invokedQualifier, null,
|
||||
UUID.randomUUID().toString(), listener);
|
||||
UUID.randomUUID().toString(), listener, null);
|
||||
}
|
||||
|
||||
private InvokeResult invoke(LambdaFunction fn, byte[] payload, InvocationType type, int chainDepth,
|
||||
String invokedQualifier, String clientContext, String requestId,
|
||||
ResponseStreamListener listener) {
|
||||
ResponseStreamListener listener, String traceId) {
|
||||
if (type == InvocationType.DryRun) {
|
||||
return new InvokeResult(204, null, new byte[0], null, requestId);
|
||||
}
|
||||
@@ -260,7 +265,7 @@ public class LambdaExecutorService implements Resettable {
|
||||
}
|
||||
|
||||
try {
|
||||
return executeSync(fn, payload, requestId, clientContext, invokedQualifier, listener);
|
||||
return executeSync(fn, payload, requestId, clientContext, invokedQualifier, listener, traceId);
|
||||
} finally {
|
||||
permit.close();
|
||||
}
|
||||
@@ -316,7 +321,7 @@ public class LambdaExecutorService implements Resettable {
|
||||
}
|
||||
InvokeResult result;
|
||||
try (permit) {
|
||||
result = executeSync(event.fn(), event.payload(), event.requestId(), null, event.invokedQualifier(), null);
|
||||
result = executeSync(event.fn(), event.payload(), event.requestId(), null, event.invokedQualifier(), null, null);
|
||||
} catch (RuntimeException e) {
|
||||
LOG.warnv("Error in async Lambda execution for {0}: {1}", event.fn().getFunctionName(), e.getMessage());
|
||||
// Stops retrying, as upstream did: routes the previous attempt's result, or UnknownError when
|
||||
@@ -394,7 +399,7 @@ public class LambdaExecutorService implements Resettable {
|
||||
|
||||
private InvokeResult executeSync(LambdaFunction fn, byte[] payload, String requestId,
|
||||
String clientContext, String invokedQualifier,
|
||||
ResponseStreamListener listener) {
|
||||
ResponseStreamListener listener, String traceId) {
|
||||
ContainerHandle handle;
|
||||
try {
|
||||
handle = warmPool.acquireProvisioned(fn, invokedQualifier);
|
||||
@@ -412,6 +417,7 @@ public class LambdaExecutorService implements Resettable {
|
||||
requestId, payload, deadlineMs, fn.getFunctionArn(),
|
||||
new CompletableFuture<>());
|
||||
invocation.setClientContext(clientContext);
|
||||
invocation.setTraceId(traceId);
|
||||
invocation.setResponseStreamListener(listener);
|
||||
RuntimeApiServer runtimeApiServer = handle.getRuntimeApiServer();
|
||||
boolean initializing = !runtimeApiServer.hasRuntimePolled();
|
||||
|
||||
@@ -1444,6 +1444,12 @@ public class LambdaService implements ResourceProvider {
|
||||
*/
|
||||
public InvokeResult invoke(String region, String functionName, String queryQualifier, byte[] payload,
|
||||
InvocationType type, String clientContext, String durableExecutionName) {
|
||||
return invoke(region, functionName, queryQualifier, payload, type, clientContext, durableExecutionName, null);
|
||||
}
|
||||
|
||||
public InvokeResult invoke(String region, String functionName, String queryQualifier, byte[] payload,
|
||||
InvocationType type, String clientContext, String durableExecutionName,
|
||||
String traceHeader) {
|
||||
validateInvokeQualifier(queryQualifier);
|
||||
LambdaArnUtils.ResolvedFunctionRef ref = resolveWithRegion(region, functionName, queryQualifier);
|
||||
String name = ref.name();
|
||||
@@ -1457,7 +1463,8 @@ public class LambdaService implements ResourceProvider {
|
||||
fn = targetResolver.resolveInvokeTarget(region, name, qualifier);
|
||||
}
|
||||
reportCustomResourceLiveness(payload);
|
||||
InvokeResult durable = invokeIfDurable(fn, region, qualifier, durableExecutionName, payload, type);
|
||||
InvokeResult durable = invokeIfDurable(fn, region, qualifier, durableExecutionName, payload, type,
|
||||
traceHeader);
|
||||
if (durable != null) {
|
||||
return durable;
|
||||
}
|
||||
@@ -1469,7 +1476,8 @@ public class LambdaService implements ResourceProvider {
|
||||
|
||||
/** Null for a plain function, and for a DryRun, which only checks the qualifier. */
|
||||
private InvokeResult invokeIfDurable(LambdaFunction fn, String region, String qualifier,
|
||||
String durableExecutionName, byte[] payload, InvocationType type) {
|
||||
String durableExecutionName, byte[] payload, InvocationType type,
|
||||
String traceHeader) {
|
||||
if (!fn.isDurable()) {
|
||||
return null;
|
||||
}
|
||||
@@ -1480,7 +1488,7 @@ public class LambdaService implements ResourceProvider {
|
||||
if (type == InvocationType.DryRun) {
|
||||
return null;
|
||||
}
|
||||
InvokeResult result = invokeDurable(fn, region, durableExecutionName, payload, type);
|
||||
InvokeResult result = invokeDurable(fn, region, durableExecutionName, payload, type, traceHeader);
|
||||
result.setExecutedVersion(fn.getVersion());
|
||||
return result;
|
||||
}
|
||||
@@ -1490,7 +1498,7 @@ public class LambdaService implements ResourceProvider {
|
||||
* limit. Event answers 202 as soon as the execution exists.
|
||||
*/
|
||||
private InvokeResult invokeDurable(LambdaFunction fn, String region, String executionName, byte[] payload,
|
||||
InvocationType type) {
|
||||
InvocationType type, String traceHeader) {
|
||||
boolean synchronous = type == InvocationType.RequestResponse;
|
||||
if (synchronous && fn.getDurableExecutionTimeout() > MAX_FUNCTION_TIMEOUT_SECONDS) {
|
||||
throw new AwsException("InvalidParameterValueException",
|
||||
@@ -1504,7 +1512,8 @@ public class LambdaService implements ResourceProvider {
|
||||
}
|
||||
String input = payload == null || payload.length == 0 ? "{}" : new String(payload, StandardCharsets.UTF_8);
|
||||
DurableExecution execution = durableExecutionService.start(new DurableExecutionService.StartRequest(
|
||||
fn.getAccountId(), region, fn.getFunctionName(), fn.getVersion(), executionName, input, synchronous));
|
||||
fn.getAccountId(), region, fn.getFunctionName(), fn.getVersion(), executionName, input, synchronous,
|
||||
traceHeader));
|
||||
String requestId = UUID.randomUUID().toString();
|
||||
InvokeResult result;
|
||||
if (!synchronous) {
|
||||
@@ -1589,7 +1598,7 @@ public class LambdaService implements ResourceProvider {
|
||||
LambdaArnUtils.ResolvedFunctionRef ref = LambdaArnUtils.resolve(functionArn);
|
||||
LambdaFunction fn = targetResolver.resolveInvokeTargetForAccount(
|
||||
arn.accountId(), arn.region(), ref.name(), ref.qualifier());
|
||||
InvokeResult durable = invokeIfDurable(fn, arn.region(), ref.qualifier(), null, payload, type);
|
||||
InvokeResult durable = invokeIfDurable(fn, arn.region(), ref.qualifier(), null, payload, type, null);
|
||||
if (durable != null) {
|
||||
return durable;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,8 @@ public class DurableExecutionService implements Resettable {
|
||||
}
|
||||
|
||||
public record StartRequest(String accountId, String region, String functionName, String qualifier,
|
||||
String executionName, String inputPayload, boolean synchronous) {
|
||||
String executionName, String inputPayload, boolean synchronous,
|
||||
String traceHeader) {
|
||||
}
|
||||
|
||||
public record ListRequest(String accountId, String region, String functionName, String version,
|
||||
@@ -548,6 +549,7 @@ public class DurableExecutionService implements Resettable {
|
||||
private void runInvocation(String accountId, String key, String invocationId, long launchGeneration) {
|
||||
ResolvedDurableTarget target;
|
||||
byte[] payload;
|
||||
String traceId = null;
|
||||
long startedAt;
|
||||
synchronized (lockFor(accountId, key)) {
|
||||
DurableExecution execution = store.getForAccount(accountId, key).orElse(null);
|
||||
@@ -563,6 +565,7 @@ public class DurableExecutionService implements Resettable {
|
||||
try {
|
||||
target = invoker.resolve(accountId, execution.getRegion(), execution.getFunctionName(),
|
||||
execution.getVersion());
|
||||
traceId = DurableTraceHeader.forInvocation(execution.getTraceHeader(), target.activeTracing());
|
||||
payload = objectMapper.writeValueAsBytes(
|
||||
DurableWire.invocationEvent(execution, token, updatedOperationIds));
|
||||
} catch (AwsException | IOException e) {
|
||||
@@ -578,7 +581,7 @@ public class DurableExecutionService implements Resettable {
|
||||
result = new DurableInvocationResult(null, null, "ResourceNotFoundException");
|
||||
} else {
|
||||
try {
|
||||
result = invoker.invoke(target, payload, invocationId);
|
||||
result = invoker.invoke(target, payload, invocationId, traceId);
|
||||
} catch (AwsException e) {
|
||||
result = new DurableInvocationResult(null, DurableWire.functionErrorPayload(
|
||||
DurableErrorObject.of(e.getMessage(), e.getErrorCode())),
|
||||
@@ -703,6 +706,8 @@ public class DurableExecutionService implements Resettable {
|
||||
execution.setVersion(target.version());
|
||||
execution.setExecutionArn(target.functionArn() + "/durable-execution/" + name + "/" + executionId);
|
||||
execution.setStartTimestamp(now);
|
||||
execution.setTraceHeader(DurableTraceHeader.forExecution(request.traceHeader(), target.activeTracing(),
|
||||
now / 1000));
|
||||
execution.setInputPayload(request.inputPayload());
|
||||
execution.setExecutionTimeoutSeconds(target.executionTimeoutSeconds());
|
||||
execution.setRetentionPeriodInDays(target.retentionPeriodInDays());
|
||||
@@ -850,7 +855,7 @@ public class DurableExecutionService implements Resettable {
|
||||
ResolvedDurableTarget target, String name, String executionId, long now,
|
||||
List<Runnable> effects) {
|
||||
StartRequest request = new StartRequest(target.accountId(), target.region(), target.functionName(),
|
||||
target.version(), name, operation.getInputPayload(), false);
|
||||
target.version(), name, operation.getInputPayload(), false, null);
|
||||
DurableExecution child = newExecution(request, target, name, executionId, now);
|
||||
child.setParentExecutionArn(parent.getExecutionArn());
|
||||
child.setParentOperationId(operation.getId());
|
||||
@@ -878,7 +883,7 @@ public class DurableExecutionService implements Resettable {
|
||||
private ChainedOutcome invokePlainFunction(ResolvedDurableTarget target, byte[] payload) {
|
||||
DurableInvocationResult result;
|
||||
try {
|
||||
result = invoker.invoke(target, payload, UUID.randomUUID().toString());
|
||||
result = invoker.invoke(target, payload, UUID.randomUUID().toString(), null);
|
||||
} catch (AwsException e) {
|
||||
return ChainedOutcome.failed(e);
|
||||
} catch (RuntimeException e) {
|
||||
|
||||
@@ -10,7 +10,7 @@ public interface DurableFunctionInvoker {
|
||||
/** The function a durable execution runs on, or an AwsException when the name does not resolve. */
|
||||
ResolvedDurableTarget resolve(String accountId, String region, String functionName, String qualifier);
|
||||
|
||||
DurableInvocationResult invoke(ResolvedDurableTarget target, byte[] payload, String requestId);
|
||||
DurableInvocationResult invoke(ResolvedDurableTarget target, byte[] payload, String requestId, String traceId);
|
||||
|
||||
record ResolvedDurableTarget(String accountId,
|
||||
String region,
|
||||
@@ -19,7 +19,8 @@ public interface DurableFunctionInvoker {
|
||||
String version,
|
||||
boolean durable,
|
||||
int executionTimeoutSeconds,
|
||||
int retentionPeriodInDays) {
|
||||
int retentionPeriodInDays,
|
||||
boolean activeTracing) {
|
||||
}
|
||||
|
||||
record DurableInvocationResult(String requestId, byte[] payload, String functionError) {
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
package io.floci.aws.services.lambda.durable;
|
||||
|
||||
import io.floci.aws.core.common.XRayTraceIds;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** The X-Ray trace header of a durable execution and of each invocation of it. */
|
||||
final class DurableTraceHeader {
|
||||
|
||||
private static final Pattern ROOT = Pattern.compile("1-[0-9a-fA-F]{8}-[0-9a-fA-F]{24}");
|
||||
private static final Pattern PARENT = Pattern.compile("[0-9a-fA-F]{16}");
|
||||
|
||||
private DurableTraceHeader() {
|
||||
}
|
||||
|
||||
private record Fields(String root, String parent, String sampled) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Lambda records its own segment for an Active function that samples the request, so the Parent
|
||||
* it was sent is replaced.
|
||||
*/
|
||||
static String forExecution(String received, boolean activeTracing, long epochSeconds) {
|
||||
Fields fields = parse(received);
|
||||
String root = fields.root() != null ? fields.root() : XRayTraceIds.traceId(epochSeconds);
|
||||
String sampled = fields.sampled() != null ? fields.sampled() : activeTracing ? "1" : "0";
|
||||
String parent;
|
||||
if (activeTracing && "1".equals(sampled)) {
|
||||
parent = XRayTraceIds.segmentId();
|
||||
} else if (fields.parent() != null) {
|
||||
parent = fields.parent();
|
||||
} else if (fields.sampled() == null) {
|
||||
parent = XRayTraceIds.segmentId();
|
||||
} else {
|
||||
parent = null;
|
||||
}
|
||||
return format(root, parent, sampled);
|
||||
}
|
||||
|
||||
static String forInvocation(String executionHeader, boolean activeTracing) {
|
||||
if (executionHeader == null) {
|
||||
return null;
|
||||
}
|
||||
Fields fields = parse(executionHeader);
|
||||
if (activeTracing) {
|
||||
return format(fields.root(), XRayTraceIds.segmentId(), fields.sampled());
|
||||
}
|
||||
if (fields.parent() != null) {
|
||||
return executionHeader;
|
||||
}
|
||||
return "Root=" + fields.root();
|
||||
}
|
||||
|
||||
private static Fields parse(String header) {
|
||||
String root = null;
|
||||
String parent = null;
|
||||
String sampled = null;
|
||||
if (header != null) {
|
||||
for (String part : header.split(";")) {
|
||||
String field = part.trim();
|
||||
int equals = field.indexOf('=');
|
||||
if (equals < 0) {
|
||||
continue;
|
||||
}
|
||||
String key = field.substring(0, equals);
|
||||
String value = field.substring(equals + 1);
|
||||
if ("Root".equals(key) && root == null && ROOT.matcher(value).matches()) {
|
||||
root = value;
|
||||
} else if ("Parent".equals(key) && parent == null && PARENT.matcher(value).matches()) {
|
||||
parent = value;
|
||||
} else if ("Sampled".equals(key) && sampled == null
|
||||
&& ("0".equals(value) || "1".equals(value))) {
|
||||
sampled = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Fields(root, parent, sampled);
|
||||
}
|
||||
|
||||
private static String format(String root, String parent, String sampled) {
|
||||
StringBuilder header = new StringBuilder("Root=").append(root);
|
||||
if (parent != null) {
|
||||
header.append(";Parent=").append(parent);
|
||||
}
|
||||
return header.append(";Sampled=").append(sampled).toString();
|
||||
}
|
||||
}
|
||||
@@ -139,6 +139,9 @@ public final class DurableWire {
|
||||
node.put("DurableExecutionName", execution.getName());
|
||||
node.put("FunctionArn", execution.getFunctionArn());
|
||||
node.put("Version", execution.getVersion());
|
||||
if (execution.getTraceHeader() != null) {
|
||||
node.putObject("TraceHeader").put("XAmznTraceId", execution.getTraceHeader());
|
||||
}
|
||||
node.put("Status", execution.getStatus().name());
|
||||
putTimestamp(node, "StartTimestamp", execution.getStartTimestamp(), false);
|
||||
if (execution.getEndTimestamp() != null) {
|
||||
|
||||
+5
-3
@@ -30,7 +30,8 @@ public class LambdaDurableFunctionInvoker implements DurableFunctionInvoker {
|
||||
return new ResolvedDurableTarget(accountId, region, fn.getFunctionName(), qualifiedArn, version,
|
||||
fn.isDurable(),
|
||||
fn.getDurableExecutionTimeout() != null ? fn.getDurableExecutionTimeout() : 0,
|
||||
fn.getDurableRetentionPeriodInDays() != null ? fn.getDurableRetentionPeriodInDays() : 0);
|
||||
fn.getDurableRetentionPeriodInDays() != null ? fn.getDurableRetentionPeriodInDays() : 0,
|
||||
"Active".equals(fn.getTracingMode()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,11 +39,12 @@ public class LambdaDurableFunctionInvoker implements DurableFunctionInvoker {
|
||||
* {@code $LATEST} execution resumes on whatever code $LATEST holds now, as on AWS.
|
||||
*/
|
||||
@Override
|
||||
public DurableInvocationResult invoke(ResolvedDurableTarget target, byte[] payload, String requestId) {
|
||||
public DurableInvocationResult invoke(ResolvedDurableTarget target, byte[] payload, String requestId,
|
||||
String traceId) {
|
||||
LambdaFunction fn = targetResolver.resolveInvokeTargetForAccount(target.accountId(), target.region(),
|
||||
target.functionName(), target.version());
|
||||
InvokeResult result = RequestScopes.callAs(target.accountId(),
|
||||
() -> executorService.invoke(fn, payload, InvocationType.RequestResponse, requestId));
|
||||
() -> executorService.invoke(fn, payload, InvocationType.RequestResponse, requestId, traceId));
|
||||
return new DurableInvocationResult(result.getRequestId(), result.getPayload(), result.getFunctionError());
|
||||
}
|
||||
}
|
||||
@@ -56,6 +56,7 @@ public class DurableExecution {
|
||||
/** Set on an execution a chained invoke started. Its close completes that operation of the parent. */
|
||||
private String parentExecutionArn;
|
||||
private String parentOperationId;
|
||||
private String traceHeader;
|
||||
|
||||
public DurableExecution() {
|
||||
}
|
||||
@@ -136,6 +137,8 @@ public class DurableExecution {
|
||||
|
||||
public String getVersion() { return version; }
|
||||
public void setVersion(String version) { this.version = version; }
|
||||
public String getTraceHeader() { return traceHeader; }
|
||||
public void setTraceHeader(String traceHeader) { this.traceHeader = traceHeader; }
|
||||
|
||||
public DurableExecutionStatus getStatus() { return status; }
|
||||
public void setStatus(DurableExecutionStatus status) { this.status = status; }
|
||||
|
||||
@@ -13,6 +13,7 @@ public class PendingInvocation {
|
||||
private final CompletableFuture<InvokeResult> resultFuture;
|
||||
private final CompletableFuture<Void> dispatchedFuture = new CompletableFuture<>();
|
||||
private volatile String clientContext;
|
||||
private volatile String traceId;
|
||||
private volatile ResponseStreamListener responseStreamListener;
|
||||
|
||||
public PendingInvocation(String requestId, byte[] payload, long deadlineMs,
|
||||
@@ -40,6 +41,8 @@ public class PendingInvocation {
|
||||
public String getFunctionArn() { return functionArn; }
|
||||
public String getClientContext() { return clientContext; }
|
||||
public void setClientContext(String clientContext) { this.clientContext = clientContext; }
|
||||
public String getTraceId() { return traceId; }
|
||||
public void setTraceId(String traceId) { this.traceId = traceId; }
|
||||
public ResponseStreamListener getResponseStreamListener() { return responseStreamListener; }
|
||||
public void setResponseStreamListener(ResponseStreamListener listener) { this.responseStreamListener = listener; }
|
||||
public CompletableFuture<InvokeResult> getResultFuture() { return resultFuture; }
|
||||
|
||||
@@ -1072,6 +1072,9 @@ public class RuntimeApiServer {
|
||||
if (invocation.getClientContext() != null) {
|
||||
response.putHeader("Lambda-Runtime-Client-Context", invocation.getClientContext());
|
||||
}
|
||||
if (invocation.getTraceId() != null) {
|
||||
response.putHeader("Lambda-Runtime-Trace-Id", invocation.getTraceId());
|
||||
}
|
||||
write = response.end(body);
|
||||
} catch (IllegalStateException alreadyEnded) {
|
||||
write = Future.failedFuture(alreadyEnded);
|
||||
|
||||
Reference in new issue
Block a user