-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathDurableExecutionPlugin.java
More file actions
79 lines (68 loc) · 3.68 KB
/
Copy pathDurableExecutionPlugin.java
File metadata and controls
79 lines (68 loc) · 3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package software.amazon.lambda.durable.plugin;
/**
* Plugin interface for instrumenting durable execution lifecycle events.
*
* <p>Implement this interface to integrate observability tools (OpenTelemetry, Datadog, etc.) with the durable
* execution SDK. The SDK calls these hooks at key lifecycle points without requiring modifications to core SDK code.
*
* <p>All methods have default no-op implementations, allowing plugins to override only the hooks they need.
*
* <p>Plugin errors are isolated — exceptions thrown by plugin methods are caught and logged but never disrupt SDK
* execution.
*
* @deprecated This is a preview API that is experimental and may be changed or removed in future releases.
*/
@Deprecated
public interface DurableExecutionPlugin {
// ─── Invocation-level hooks ──────────────────────────────────────────
/**
* Called at the start of each Lambda invocation. Use to set up per-invocation state (trace ID, invocation span).
*
* <p>Check {@link InvocationInfo#isFirstInvocation()} to detect the first invocation of an execution (useful for
* sampling decisions or execution-level span creation).
*/
default void onInvocationStart(InvocationInfo info) {}
/**
* Called at the end of each Lambda invocation. Use to flush spans/metrics before Lambda freezes.
*
* <p>This hook is awaited — the SDK blocks until it returns. This is the only safe flush point before Lambda
* freezes the execution environment.
*
* <p>Check {@link InvocationEndInfo#invocationStatus()} to detect if the execution reached a terminal state in this
* invocation (useful for writing summary records or flushing final data).
*/
default void onInvocationEnd(InvocationEndInfo info) {}
// ─── Operation-level hooks ───────────────────────────────────────────
/** Called when an operation starts (including replay). Use for logging/metrics that want replay visibility. */
default void onOperationStart(OperationInfo info) {}
/**
* Called when an operation reaches a terminal status for the first time (not on replay).
*
* <p>The OTel plugin creates operation spans here with backfilled start/end timestamps.
*/
default void onOperationEnd(OperationEndInfo info) {}
/**
* Called when a checkpoint response changes the status of one or more operations.
*
* <p>Receives the operations that changed and a snapshot of all operations.
*/
default void onOperationChange(OperationChangeInfo info) {}
// ─── User function hooks ─────────────────────────────────────────────
/**
* Called when a user-provided function starts executing. This fires for both step attempts (with {@code attempt}
* set) and child context functions (with {@code attempt} null).
*
* <p>This hook fires on the same thread as user code, so plugins can set OTel context via
* {@code Context.makeCurrent()} here.
*/
default void onUserFunctionStart(UserFunctionStartInfo info) {}
/**
* Called when a user-provided function finishes executing. This fires for both step attempts and child context
* functions.
*
* <p>This hook fires on the same thread as user code, so plugins can close OTel scopes here.
*/
default void onUserFunctionEnd(UserFunctionEndInfo info) {}
}