Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions docs/sdk-reference/observability/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,15 @@ snapshot of all operations.

=== "Python"

This hook is a work in progress and is not yet available in the Python SDK.
```python
--8<-- "examples/python/sdk-reference/plugins/checkpoint-change-hook.py"
```

=== "Java"

This hook is a work in progress and is not yet available in the Java SDK.
```java
--8<-- "examples/java/sdk-reference/plugins/checkpoint-change-hook.java"
```

## Use a plugin

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@Override
public void onOperationChange(OperationChangeInfo info) {
System.out.println("operations changed, ids: " + info.updatedOperations().keySet());
}
6 changes: 6 additions & 0 deletions examples/java/sdk-reference/plugins/complete-plugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import software.amazon.lambda.durable.plugin.InvocationEndInfo;
import software.amazon.lambda.durable.plugin.OperationInfo;
import software.amazon.lambda.durable.plugin.OperationEndInfo;
import software.amazon.lambda.durable.plugin.OperationChangeInfo;
import software.amazon.lambda.durable.plugin.UserFunctionStartInfo;
import software.amazon.lambda.durable.plugin.UserFunctionEndInfo;

Expand All @@ -29,6 +30,11 @@ public void onOperationEnd(OperationEndInfo info) {
System.out.println("operation " + info.name() + " end, error: " + info.error());
}

@Override
public void onOperationChange(OperationChangeInfo info) {
System.out.println("operations changed, ids: " + info.updatedOperations().keySet());
}

@Override
public void onUserFunctionStart(UserFunctionStartInfo info) {
System.out.println("user function " + info.name() + " start, attempt: " + info.attempt());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def on_operation_change(self, info: OperationChangeInfo) -> None:
print("operations changed", "ids:", list(info.updated_operations.keys()))
4 changes: 4 additions & 0 deletions examples/python/sdk-reference/plugins/complete-plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
InvocationEndInfo,
OperationStartInfo,
OperationEndInfo,
OperationChangeInfo,
UserFunctionStartInfo,
UserFunctionEndInfo,
)
Expand All @@ -22,6 +23,9 @@ def on_operation_start(self, info: OperationStartInfo) -> None:
def on_operation_end(self, info: OperationEndInfo) -> None:
print(f"operation {info.name} end, status: {info.status}, error: {info.error}")

def on_operation_change(self, info: OperationChangeInfo) -> None:
print("operations changed", "ids:", list(info.updated_operations.keys()))

def on_user_function_start(self, info: UserFunctionStartInfo) -> None:
print(f"user function {info.name} start, attempt: {info.attempt}")

Expand Down
8 changes: 4 additions & 4 deletions examples/typescript/sdk-reference/plugins/complete-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export const examplePlugin: DurableInstrumentationPlugin = {
console.log(`operation ${info.name} end, status: ${info.status}, error: ${info.error}`);
},

async onOperationChange(info: OperationChangeInfo): Promise<void> {
console.log(`operations changed, ids: ${Object.keys(info.updatedOperations)}`);
},

async onOperationAttemptStart(info: AttemptInfo): Promise<void> {
console.log(`attempt ${info.name} start, attempt: ${info.attempt}`);
},
Expand All @@ -53,10 +57,6 @@ export const examplePlugin: DurableInstrumentationPlugin = {
return fn();
},

async onOperationChange(info: OperationChangeInfo): Promise<void> {
console.log(`operations changed, ids: ${Object.keys(info.updatedOperations)}`);
},

enrichLogContext(): Record<string, string | number | boolean> {
return { service: "orders" };
},
Expand Down