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
4 changes: 2 additions & 2 deletions .github/workflows/telemetry-conformance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ jobs:
id-token: write
# The pinned SHA also selects the runner and telemetry-extension revision the shared
# workflow installs, so it must be reachable from a branch. It is the merge commit of
# aws-durable-execution-conformance-tests PR #183 on that repository's main branch.
uses: aws/aws-durable-execution-conformance-tests/.github/workflows/telemetry-suite.yml@cf13ef27d6e13a4423f7e0a178f9a3d4bb1099f0
# aws-durable-execution-conformance-tests PR #185 on that repository's main branch.
uses: aws/aws-durable-execution-conformance-tests/.github/workflows/telemetry-suite.yml@b380cbf19bbc4f08a2d7c593d4bf24f585946415
with:
language: java
resource_prefix: java
Expand Down
7 changes: 5 additions & 2 deletions conformance-tests-telemetry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ template that maps it to the requirement ID.
| `telemetry` | `telemetry-1` | One successful single-step execution emits one `SUCCEEDED` record with `input`, `output`, ARN-derived identity fields, and `operationsByName`. |
| `telemetry` | `telemetry-2` | One failed execution emits one `FAILED` record with an `error` on the execution and on `operationsByName.charge`. |
| `telemetry` | `telemetry-3` | An `OperationOverride.withResult` transform exports exactly `{userId}` of a three-key step result; the record has no `input` or `output`. |
| `telemetry` | `telemetry-4` | `FULL_TREE` operation detail exports a map, its two `MapIteration` contexts, and the step inside each, five keys in `operationsByName`. |

## Layout

Expand All @@ -31,17 +32,19 @@ src/main/java/software/amazon/lambda/durable/conformance/telemetry/
Telemetry1Success.java # single step "increment"; plugin + CloudWatchLogsExporter
Telemetry2Failure.java # step "charge" fails; handler throws "payment failed" with the step error as cause
Telemetry3ResultSelect.java # step "fetch-user"; override transform keeps only userId in the record
Telemetry4FullTreeMap.java # map "process-items" over the event; iterations item-N; step greet-N; FULL_TREE detail
TelemetryConformanceConfig.java # shared log-group guard and plugin config; every handler calls it
src/test/java/software/amazon/lambda/durable/conformance/telemetry/
TelemetryConformanceConfigTest.java # guard rejects null/blank; telemetry settings match the runner; telemetry-3 transform and content section
TelemetryConformanceConfigTest.java # guard rejects null/blank; telemetry settings match the runner; telemetry-3 transform and content section; telemetry-4 full-tree settings
```

The handlers use the real SDK API only. They construct no record and call no exporter method. A missing or wrong
record is the plugin's defect. That defect is the signal the suite measures.

The handler configuration is: one `CloudWatchLogsExporter`, emit mode `ON_COMPLETE`, sampling rate 1, operation detail
`TOP_LEVEL`, and content input and output enabled. telemetry-3 differs in the content section only: input and output are
disabled, and one `OperationOverride.withResult("fetch-user", ...)` transform selects `userId` from the step result.
disabled, and one `OperationOverride.withResult("fetch-user", ...)` transform selects `userId` from the step result. telemetry-4 differs in the operation detail only: `FULL_TREE`, with input and output
enabled and no overrides.

## Template contract

Expand Down
2 changes: 1 addition & 1 deletion conformance-tests-telemetry/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<name>AWS Lambda Durable Execution SDK Telemetry Conformance Tests</name>
<description>
Java SDK handlers and SAM template for the Durable Execution Telemetry conformance
suite (telemetry-1, telemetry-2, telemetry-3).
suite (telemetry-1, telemetry-2, telemetry-3, telemetry-4).
</description>

<properties>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package software.amazon.lambda.durable.conformance.telemetry;

import java.util.List;
import software.amazon.lambda.durable.DurableConfig;
import software.amazon.lambda.durable.DurableContext;
import software.amazon.lambda.durable.DurableHandler;
import software.amazon.lambda.durable.config.MapConfig;

/**
* Full-tree operation detail for requirement telemetry-4.
*
* <p>The map {@code process-items} runs one iteration per item with max concurrency 1. The item namer names each
* iteration {@code item-<item>}. Each iteration runs one step {@code greet-<item>}. The plugin runs with full-tree
* operation detail. So the record keeps the map, both iteration contexts, and both steps, one key per name.
*
* <p>The handler uses the event as the item list. The runner sends {@code [1, 2]}. The handler constructs no record and
* calls no exporter method. The plugin builds and exports the record.
*/
public final class Telemetry4FullTreeMap extends DurableHandler<List<Integer>, List<String>> {

// Class initialization fails when the variable is unset. See TelemetryConformanceConfig.requireLogGroupName.
private static final String LOG_GROUP_NAME =
TelemetryConformanceConfig.requireLogGroupName(System.getenv(TelemetryConformanceConfig.LOG_GROUP_ENV));

@Override
protected DurableConfig createConfiguration() {
return TelemetryConformanceConfig.durableConfig(
TelemetryConformanceConfig.fullTreeMapTelemetryConfig(LOG_GROUP_NAME));
}

@Override
public List<String> handleRequest(List<Integer> input, DurableContext context) {
var config = MapConfig.builder()
.maxConcurrency(1)
.itemNamer((item, index) -> "item-" + item)
.build();
return context.map(
TelemetryConformanceConfig.FULL_TREE_MAP_NAME,
input,
String.class,
(item, index, ctx) ->
ctx.step("greet-" + item, String.class, stepCtx -> "Hello, " + item + "!"),
config)
.results();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ final class TelemetryConformanceConfig {
/** Name of the telemetry-3 step. The override and the step call must use the same string. */
static final String RESULT_SELECT_STEP_NAME = "fetch-user";

/** Name of the telemetry-4 map. The handler's map call uses this string. */
static final String FULL_TREE_MAP_NAME = "process-items";

private TelemetryConformanceConfig() {}

/**
Expand Down Expand Up @@ -74,17 +77,53 @@ static DurableExecutionTelemetryConfig telemetryConfig(String logGroupName) {
* @return the plugin settings with the shared fields fixed and the given content
*/
static DurableExecutionTelemetryConfig telemetryConfig(String logGroupName, ContentConfig content) {
return telemetryConfig(logGroupName, DurableExecutionTelemetryConfig.OperationDetail.TOP_LEVEL, content);
}

/**
* Builds the telemetry plugin settings with a caller-supplied operation detail and content section.
*
* <p>This overload holds the settings every handler shares: one CloudWatch Logs exporter, emit on completion, and a
* sampling rate of 1. The operation detail and content differ per requirement. telemetry-1 to telemetry-3 use
* top-level detail. telemetry-4 uses full-tree detail. So both are parameters.
*
* @param logGroupName the log group the exporter writes to
* @param operationDetail which operations the record keeps
* @param content the content section for the requirement the handler covers
* @return the plugin settings with the shared fields fixed
*/
static DurableExecutionTelemetryConfig telemetryConfig(
String logGroupName,
DurableExecutionTelemetryConfig.OperationDetail operationDetail,
ContentConfig content) {
Comment thread
hln33 marked this conversation as resolved.
Resolved
return DurableExecutionTelemetryConfig.builder()
.addExporter(CloudWatchLogsExporter.builder()
.logGroupName(logGroupName)
.build())
.emitMode(DurableExecutionTelemetryConfig.EmitMode.ON_COMPLETE)
.samplingRate(1.0)
.operationDetail(DurableExecutionTelemetryConfig.OperationDetail.TOP_LEVEL)
.operationDetail(operationDetail)
.content(content)
.build();
}

/**
* Builds the telemetry-4 settings: the shared exporter and modes, full-tree operation detail, input and output
* included, and no overrides.
*
* <p>Full-tree detail keeps the map iteration contexts and the steps inside them. telemetry-4 requires all five
* operations in {@code operationsByName}, so no filter and no override may remove one.
*
* @param logGroupName the log group the exporter writes to
* @return the plugin settings the telemetry-4 handler uses
*/
static DurableExecutionTelemetryConfig fullTreeMapTelemetryConfig(String logGroupName) {
return telemetryConfig(
logGroupName,
DurableExecutionTelemetryConfig.OperationDetail.FULL_TREE,
ContentConfig.builder().input(true).output(true).build());
}

/**
* Builds the telemetry-3 settings: the shared exporter and modes, no input, no output, and one result override on
* {@link #RESULT_SELECT_STEP_NAME} that applies {@link #selectUserId(Object)}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static software.amazon.lambda.durable.telemetry.DurableExecutionTelemetryConfig.EmitMode.ON_COMPLETE;
import static software.amazon.lambda.durable.telemetry.DurableExecutionTelemetryConfig.OperationDetail.FULL_TREE;
import static software.amazon.lambda.durable.telemetry.DurableExecutionTelemetryConfig.OperationDetail.TOP_LEVEL;

import java.util.Map;
Expand Down Expand Up @@ -103,4 +104,32 @@ void resultSelectTelemetryConfigOverridesTheStepResultWithTheSelectingTransform(
assertNotNull(override.result());
assertEquals(Map.of("userId", "u-123"), override.result().apply(PARSED_FETCH_USER_RESULT));
}

@Test
void fullTreeMapTelemetryConfigKeepsTheSharedSettings() {
var config = TelemetryConformanceConfig.fullTreeMapTelemetryConfig(LOG_GROUP);
assertEquals(1, config.exporters().size());
assertInstanceOf(CloudWatchLogsExporter.class, config.exporters().get(0));
assertEquals(ON_COMPLETE, config.emitMode());
assertEquals(1.0, config.samplingRate());
}

@Test
void fullTreeMapTelemetryConfigUsesFullTreeDetailWithInputOutputAndNoOverrides() {
var config = TelemetryConformanceConfig.fullTreeMapTelemetryConfig(LOG_GROUP);
assertEquals(FULL_TREE, config.operationDetail());
assertTrue(config.content().includeInput());
assertTrue(config.content().includeOutput());
assertTrue(config.content().overrides().isEmpty());
}

@Test
void otherConfigsStillUseTopLevelDetail() {
assertEquals(
TOP_LEVEL,
TelemetryConformanceConfig.telemetryConfig(LOG_GROUP).operationDetail());
assertEquals(
TOP_LEVEL,
TelemetryConformanceConfig.resultSelectTelemetryConfig(LOG_GROUP).operationDetail());
}
}
11 changes: 11 additions & 0 deletions conformance-tests-telemetry/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,14 @@ Resources:
CodeUri: .
Handler: software.amazon.lambda.durable.conformance.telemetry.Telemetry3ResultSelect
Role: !Ref LambdaExecutionRoleArn

Telemetry4FullTreeMap:
Type: AWS::Serverless::Function
DependsOn: TelemetryLogGroup
TestingMetadata:
TestDescription:
- telemetry-4
Properties:
CodeUri: .
Handler: software.amazon.lambda.durable.conformance.telemetry.Telemetry4FullTreeMap
Role: !Ref LambdaExecutionRoleArn
Loading