Skip to content

Commit 13bd582

Browse files
committed
refactor(plugin): Rename executionArn to durableExecutionArn
1 parent ae27b2e commit 13bd582

8 files changed

Lines changed: 32 additions & 32 deletions

File tree

examples/src/main/java/software/amazon/lambda/durable/examples/general/PluginExample.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* <p>Expected output for a successful run:
1818
*
1919
* <pre>
20-
* [PLUGIN] onInvocationStart: requestId=..., executionArn=..., firstInvocation=true
20+
* [PLUGIN] onInvocationStart: requestId=..., durableExecutionArn=..., firstInvocation=true
2121
* [PLUGIN] onOperationStart: name=create-greeting, type=STEP
2222
* [PLUGIN] onUserFunctionStart: name=create-greeting, attempt=1
2323
* [PLUGIN] onUserFunctionEnd: name=create-greeting, succeeded=true
@@ -54,8 +54,8 @@ static class LoggingPlugin implements DurableExecutionPlugin {
5454
@Override
5555
public void onInvocationStart(InvocationInfo info) {
5656
System.out.printf(
57-
"[PLUGIN] onInvocationStart: requestId=%s, executionArn=%s, firstInvocation=%s%n",
58-
info.requestId(), info.executionArn(), info.isFirstInvocation());
57+
"[PLUGIN] onInvocationStart: requestId=%s, durableExecutionArn=%s, firstInvocation=%s%n",
58+
info.requestId(), info.durableExecutionArn(), info.isFirstInvocation());
5959
}
6060

6161
@Override

otel-plugin/src/main/java/software/amazon/lambda/durable/otel/DeterministicIdGenerator.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ public class DeterministicIdGenerator implements IdGenerator {
2626

2727
private final AtomicReference<String> executionTraceId = new AtomicReference<>(null);
2828
private final ThreadLocal<String> pendingSpanOperationId = new ThreadLocal<>();
29-
private final AtomicReference<String> executionArn = new AtomicReference<>(null);
29+
private final AtomicReference<String> durableExecutionArn = new AtomicReference<>(null);
3030

3131
/**
3232
* Sets the execution ARN used for generating deterministic IDs.
3333
*
3434
* @param arn the durable execution ARN
3535
*/
36-
public void setExecutionArn(String arn) {
37-
this.executionArn.set(arn);
36+
public void setDurableExecutionArn(String arn) {
37+
this.durableExecutionArn.set(arn);
3838
this.executionTraceId.set(generateTraceIdFromArn(arn));
3939
}
4040

@@ -96,7 +96,7 @@ private String generateTraceIdFromArn(String arn) {
9696
* <p>Uses SHA-256 hash truncated to 16 hex chars (64 bits) for the span ID.
9797
*/
9898
private String generateSpanIdFromOperation(String operationId) {
99-
var arn = executionArn.get();
99+
var arn = durableExecutionArn.get();
100100
var input = arn != null ? arn + ":" + operationId : operationId;
101101
var hash = sha256(input);
102102
// Span ID is 16 hex chars (8 bytes)

otel-plugin/src/main/java/software/amazon/lambda/durable/otel/MdcSpanEnricher.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ private MdcSpanEnricher() {}
3737
/**
3838
* Injects the current span's trace ID and span ID into MDC.
3939
*
40-
* @param executionArn the durable execution ARN (may be null)
40+
* @param durableExecutionArn the durable execution ARN (may be null)
4141
*/
42-
public static void inject(String executionArn) {
42+
public static void inject(String durableExecutionArn) {
4343
var span = Span.current();
4444
if (span.getSpanContext().isValid()) {
4545
MDC.put(MDC_TRACE_ID, span.getSpanContext().getTraceId());
4646
MDC.put(MDC_SPAN_ID, span.getSpanContext().getSpanId());
4747
}
48-
if (executionArn != null) {
49-
MDC.put(MDC_EXECUTION_ARN, executionArn);
48+
if (durableExecutionArn != null) {
49+
MDC.put(MDC_EXECUTION_ARN, durableExecutionArn);
5050
}
5151
}
5252

otel-plugin/src/main/java/software/amazon/lambda/durable/otel/OpenTelemetryDurablePlugin.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class OpenTelemetryDurablePlugin implements DurableExecutionPlugin {
6060

6161
// Per-invocation state
6262
private volatile Span invocationSpan;
63-
private volatile String executionArn;
63+
private volatile String durableExecutionArn;
6464

6565
// Thread-safe storage for operation spans (keyed by operationId) — open spans that need ending
6666
private final ConcurrentHashMap<String, Span> operationSpans = new ConcurrentHashMap<>();
@@ -116,16 +116,16 @@ public OpenTelemetryDurablePlugin(
116116

117117
@Override
118118
public void onInvocationStart(InvocationInfo info) {
119-
this.executionArn = info.executionArn();
120-
idGenerator.setExecutionArn(info.executionArn());
119+
this.durableExecutionArn = info.durableExecutionArn();
120+
idGenerator.setDurableExecutionArn(info.durableExecutionArn());
121121

122122
// Extract parent context from Lambda environment (X-Ray, W3C, etc.)
123123
var extractedParentContext = contextExtractor.extract();
124124

125125
// Create invocation span as child of extracted context
126126
var spanBuilder = tracer.spanBuilder("durable.invocation")
127127
.setParent(extractedParentContext)
128-
.setAttribute(DURABLE_EXECUTION_ARN, info.executionArn())
128+
.setAttribute(DURABLE_EXECUTION_ARN, info.durableExecutionArn())
129129
.setAttribute(DURABLE_FIRST_INVOCATION, info.isFirstInvocation());
130130

131131
if (info.requestId() != null) {
@@ -189,7 +189,7 @@ public void onOperationStart(OperationInfo info) {
189189

190190
var spanBuilder = tracer.spanBuilder(spanName(info.type(), info.subType(), info.name()))
191191
.setParent(parentContext)
192-
.setAttribute(DURABLE_EXECUTION_ARN, executionArn)
192+
.setAttribute(DURABLE_EXECUTION_ARN, durableExecutionArn)
193193
.setAttribute(DURABLE_OPERATION_ID, info.id())
194194
.setAttribute(DURABLE_OPERATION_TYPE, info.type());
195195

@@ -239,7 +239,7 @@ public void onUserFunctionStart(UserFunctionStartInfo info) {
239239
.setParent(parentContext)
240240
.setStartTimestamp(info.startTimestamp() != null ? info.startTimestamp() : Instant.now());
241241

242-
spanBuilder.setAttribute(DURABLE_EXECUTION_ARN, executionArn);
242+
spanBuilder.setAttribute(DURABLE_EXECUTION_ARN, durableExecutionArn);
243243
spanBuilder.setAttribute(DURABLE_OPERATION_ID, info.id());
244244

245245
if (info.type() != null) {
@@ -261,7 +261,7 @@ public void onUserFunctionStart(UserFunctionStartInfo info) {
261261

262262
// Inject trace context into MDC for log-trace correlation
263263
if (enableMdc) {
264-
MdcSpanEnricher.inject(executionArn);
264+
MdcSpanEnricher.inject(durableExecutionArn);
265265
}
266266
}
267267

otel-plugin/src/test/java/software/amazon/lambda/durable/otel/DeterministicIdGeneratorTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void generateTraceId_withoutArn_returnsRandom() {
2929

3030
@Test
3131
void generateTraceId_withArn_returnsDeterministic() {
32-
generator.setExecutionArn("arn:aws:lambda:us-east-1:123:function:test:$LATEST/durable/exec1");
32+
generator.setDurableExecutionArn("arn:aws:lambda:us-east-1:123:function:test:$LATEST/durable/exec1");
3333

3434
var id1 = generator.generateTraceId();
3535
var id2 = generator.generateTraceId();
@@ -40,10 +40,10 @@ void generateTraceId_withArn_returnsDeterministic() {
4040

4141
@Test
4242
void generateTraceId_differentArns_produceDifferentIds() {
43-
generator.setExecutionArn("arn:exec1");
43+
generator.setDurableExecutionArn("arn:exec1");
4444
var id1 = generator.generateTraceId();
4545

46-
generator.setExecutionArn("arn:exec2");
46+
generator.setDurableExecutionArn("arn:exec2");
4747
var id2 = generator.generateTraceId();
4848

4949
assertNotEquals(id1, id2);
@@ -60,7 +60,7 @@ void generateSpanId_withoutOperationId_returnsRandom() {
6060

6161
@Test
6262
void generateSpanId_withOperationId_returnsDeterministic() {
63-
generator.setExecutionArn("arn:exec1");
63+
generator.setDurableExecutionArn("arn:exec1");
6464
generator.setNextSpanOperationId("op-hash-1");
6565
var id1 = generator.generateSpanId();
6666

@@ -73,7 +73,7 @@ void generateSpanId_withOperationId_returnsDeterministic() {
7373

7474
@Test
7575
void generateSpanId_differentOperationIds_produceDifferentIds() {
76-
generator.setExecutionArn("arn:exec1");
76+
generator.setDurableExecutionArn("arn:exec1");
7777

7878
generator.setNextSpanOperationId("op-1");
7979
var id1 = generator.generateSpanId();
@@ -96,7 +96,7 @@ void generateSpanId_consumesPendingId() {
9696

9797
@Test
9898
void generateSpanIdForOperation_doesNotConsumePending() {
99-
generator.setExecutionArn("arn:exec1");
99+
generator.setDurableExecutionArn("arn:exec1");
100100
generator.setNextSpanOperationId("op-1");
101101

102102
// This should NOT consume the pending
@@ -112,7 +112,7 @@ void generateSpanIdForOperation_doesNotConsumePending() {
112112

113113
@Test
114114
void generateSpanIdForOperation_isDeterministic() {
115-
generator.setExecutionArn("arn:exec1");
115+
generator.setDurableExecutionArn("arn:exec1");
116116

117117
var id1 = generator.generateSpanIdForOperation("op-1");
118118
var id2 = generator.generateSpanIdForOperation("op-1");
@@ -122,15 +122,15 @@ void generateSpanIdForOperation_isDeterministic() {
122122

123123
@Test
124124
void traceId_isValidHex() {
125-
generator.setExecutionArn("arn:exec1");
125+
generator.setDurableExecutionArn("arn:exec1");
126126
var traceId = generator.generateTraceId();
127127

128128
assertTrue(traceId.matches("[0-9a-f]{32}"), "Trace ID should be 32 hex chars: " + traceId);
129129
}
130130

131131
@Test
132132
void spanId_isValidHex() {
133-
generator.setExecutionArn("arn:exec1");
133+
generator.setDurableExecutionArn("arn:exec1");
134134
generator.setNextSpanOperationId("op-1");
135135
var spanId = generator.generateSpanId();
136136

sdk-integration-tests/src/test/java/software/amazon/lambda/durable/PluginIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void plugin_receivesInvocationStartAndEnd_onSuccessfulExecution() {
3939
// Verify invocation hooks fired
4040
assertEquals(1, plugin.invocationStarts.size());
4141
assertTrue(plugin.invocationStarts.get(0).isFirstInvocation());
42-
assertNotNull(plugin.invocationStarts.get(0).executionArn());
42+
assertNotNull(plugin.invocationStarts.get(0).durableExecutionArn());
4343

4444
assertEquals(1, plugin.invocationEnds.size());
4545
assertEquals(InvocationStatus.SUCCEEDED, plugin.invocationEnds.get(0).invocationStatus());

sdk/src/main/java/software/amazon/lambda/durable/plugin/InvocationEndInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Information provided at the end of a Lambda invocation.
77
*
88
* @param requestId the Lambda request ID for this invocation
9-
* @param executionArn the durable execution ARN
9+
* @param durableExecutionArn the durable execution ARN
1010
* @param isFirstInvocation true if this is the first invocation of the execution
1111
* @param invocationStatus the invocation outcome (SUCCEEDED, FAILED, or PENDING)
1212
* @param executionError non-null if the execution failed
@@ -15,7 +15,7 @@
1515
@Deprecated
1616
public record InvocationEndInfo(
1717
String requestId,
18-
String executionArn,
18+
String durableExecutionArn,
1919
boolean isFirstInvocation,
2020
InvocationStatus invocationStatus,
2121
Throwable executionError) {}

sdk/src/main/java/software/amazon/lambda/durable/plugin/InvocationInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
* Invocation-level information available to plugin hooks.
77
*
88
* @param requestId the Lambda request ID for this invocation
9-
* @param executionArn the durable execution ARN
9+
* @param durableExecutionArn the durable execution ARN
1010
* @param isFirstInvocation true if this is the first invocation of the execution (not a replay invocation)
1111
* @deprecated This is a preview API that is experimental and may be changed or removed in future releases.
1212
*/
1313
@Deprecated
14-
public record InvocationInfo(String requestId, String executionArn, boolean isFirstInvocation) {}
14+
public record InvocationInfo(String requestId, String durableExecutionArn, boolean isFirstInvocation) {}

0 commit comments

Comments
 (0)