Repository navigation
feat(telemetry): add telemetry-2 failure handler - #876
Conversation
Add the handler for conformance requirement telemetry-2. The step "charge" throws "card declined" with no retry. The handler catches the step error and throws "payment failed" with the step error as its cause. So the execution fails and the exported record is FAILED with an error on the execution and on the operation. Add the template function, the README row, and the pom description.
…orkflow to the #179 head The team decided that error names and cause depth differ per SDK by design. Conformance PR #179 at 121e832 now matches each telemetry-2 `error` with `{$object: {}}`: present and an object, keys unchecked. So this SDK's two- level execution error and one-level step error pass. The README row and the handler javadoc no longer describe a cause chain. The workflow pin moves from 0eaf734, which predates telemetry-2 and made the runner skip the new handler, to the #179 head 121e832 so this PR's run exercises telemetry-2. telemetry-suite.yml is identical between the two commits. TEMPORARY: bump to the #179 merge commit on main before merging.
ccdae02 to
3d4eba3
Compare
This comment has been minimized.
This comment has been minimized.
…uard Telemetry2Failure copied the TELEMETRY_LOG_GROUP_NAME guard and the full plugin configuration from Telemetry1Success. Two copies of the same setup would have to be changed together by hand. So both now live once in TelemetryConformanceConfig and each handler calls it. The guard used to run inside a static initializer that read the environment. A static initializer that reads the environment cannot be unit tested without a subprocess or a custom classloader. So the guard is now a pure function, requireLogGroupName(String), and the handler passes System.getenv to it. Six tests cover it: null and three blank values throw with the exact message, a set value is returned, and the shared config registers exactly one plugin factory. Removing the guard fails four of them. The module is outside the SDK reactor, so the root build never runs its tests. The telemetry conformance workflow now runs `mvn package` without -DskipTests, which runs them before the deploy artifact is built. JUnit and surefire versions are repeated in the standalone pom from the root pom for the same reason.
This comment has been minimized.
This comment has been minimized.
DurableConfig.build() fills in a default DurableExecutionClient when none is given. That constructor builds a LambdaClient from environment credentials and sends one getDurableExecutionState warm-up request. So the test that called TelemetryConformanceConfig.durableConfig sent a real request whenever AWS credentials were exported. The helper javadoc also said the method made no network call, which was false. The plugin settings now live in a pure function, telemetryConfig(String), and durableConfig(String) wraps it. The test checks telemetryConfig: one CloudWatchLogsExporter, emit ON_COMPLETE, sampling rate 1.0, TOP_LEVEL operation detail, input and output included. The exporter creates its client on first export, so the test builds no client. The deployed run exercises durableConfig, which has no branch of its own. Test declarations use var where the type is obvious, per AGENTS.md.
This comment has been minimized.
This comment has been minimized.
AGENTS.md requires static imports for enum constants. The two assertions used the qualified names EmitMode.ON_COMPLETE and OperationDetail.TOP_LEVEL.
This comment has been minimized.
This comment has been minimized.
ParidelPooya
left a comment
There was a problem hiding this comment.
The handler matches the telemetry-2 requirement, the Telemetry1Success refactor does not change its record, and CI passes. One item must change before merge.
Blocking
.github/workflows/telemetry-conformance-tests.yml:50pinstelemetry-suite.ymlto121e832. That commit is only on the branch of aws/aws-durable-execution-conformance-tests#179, which is still open. The conformance repository allows only squash and rebase merges, and it deletes the head branch on merge. So after #179 merges,121e832is on no branch. The comment on lines 45-46 says the pinned SHA must be reachable from a branch. Fix: after #179 merges, pin to its merge commit on conformancemainand replace the TEMPORARY comment. Marking this PR as draft until then would prevent an early merge.
Non-blocking
Telemetry2Failure.java:47catchesRuntimeException. The step failure isStepFailedException. Other SDK exceptions, such asNonDeterministicExecutionException, also extendRuntimeException. So the handler would rethrow them aspayment failed. Acatch (StepFailedException stepError)states the intent and avoids this. Suspension is not affected, becauseSuspendExecutionExceptionextendsError. The JS handler also catches every error, so keep the current code if parity with JS matters more.conformance-tests-telemetryis not a module in the rootpom.xml. So thespotless-checkjob does not check the new and changed Java files. The PR body lists this as a follow-up. An issue would keep it tracked.
This comment has been minimized.
This comment has been minimized.
StepOperation.get() rebuilds the step's original exception from the
checkpoint and rethrows it. StepFailedException is only the fallback
when that rebuild fails. So the step surfaces as
RuntimeException("card declined"), and catch (StepFailedException)
from 0bb88f5 let it escape. The telemetry run failed with
"expected 'payment failed', got 'card declined'". Catch
RuntimeException again and state the reason in a comment.
|
Pushed Item 2 rests on the premise that the step failure is
|
This comment has been minimized.
This comment has been minimized.
Codex AI reviewNo actionable findings after reviewing the changes against rules 1–11, SDK invariants, and module guidance. Residual test risk: this read-only review did not execute the unit or cloud conformance suites. Reviewed commit |
ParidelPooya
left a comment
There was a problem hiding this comment.
Thanks. I checked a862370.
- The workflow pins
telemetry-suite.ymltoca2cd02, which is the #179 merge commit on conformancemain. The telemetry job passes on this pin. - You are right about the catch, and my comment was wrong.
StepOperation.java:229-235rebuilds the original exception from the checkpoint and rethrows it. It throwsStepFailedExceptiononly when that rebuild fails. Socatch (StepFailedException ...)would letcard declinedescape.catch (RuntimeException ...)is correct, and the new comment explains why.
Approving.
Summary
Adds the Java handler for conformance requirement
telemetry-2(aws/aws-durable-execution-conformance-tests#179).
The JS handler is aws/aws-durable-execution-sdk-js#1168. The Python handler is
aws/aws-durable-execution-sdk-python#907.
The step
chargethrowsRuntimeException("card declined"). The retry strategy isRetryStrategies.Presets.NO_RETRY, so the step fails on its first attempt. The handlercatches the step error and throws
RuntimeException("payment failed")with the step erroras its cause. So the execution fails and the plugin exports one
FAILEDrecord.Design
Problem. The telemetry conformance suite gains requirement telemetry-2: a failed
single-step execution must produce one telemetry record with status
FAILED, an executionerror, and a
chargeSTEP operation withfailedCount 1andmaxAttempt 1. This modulehas no handler that produces that record.
Cause. The module has one handler,
Telemetry1Success, and it succeeds. The suitematches a deployed function to a requirement by function name, so each requirement needs a
function that produces its record.
Options considered.
Telemetry1Successselects success or failure. Rejected. The suitemaps one function to one requirement by name, so one class would still need two template
functions. The flag adds a branch to the existing handler that would itself need a test.
The JS (#1168) and Python (#907) packages use one handler per requirement.
operation record.
maxAttempt 1, and thedefault strategy retries the step.
message
payment failedinExpectedResult.Telemetry1Successinto thenew handler. Rejected after review. Two copies of the same setup would have to be changed
together by hand, and the guard sat in a static initializer that read the environment,
which cannot be unit tested without a subprocess or a custom classloader.
createConfiguration(). Rejected. It removesthe duplication, but the environment read would still sit in a static initializer, so the
guard would stay untested.
Telemetry2Failure, with one step underNO_RETRYthatthrows
card declined; the handler catches the step error and throwspayment failedwith it as the cause. The log-group guard and the plugin configuration move into a
package-private helper,
TelemetryConformanceConfig, with a purerequireLogGroupName(String), a puretelemetryConfig(String)that holds the pluginsettings, and a
durableConfig(String)wrap that both handlers call. Reason: it is thesmallest change that produces the required record, it holds the shared setup once, and
the guard and the settings become functions with explicit inputs that a unit test can
exercise.
Test isolation (second review round).
DurableConfig.build()fills in a defaultDurableExecutionClientwhen none is given (sdk/.../DurableConfig.java:110–111). Thatconstructor builds a
LambdaClientfrom environment credentials and sends onegetDurableExecutionStatewarm-up request (DurableConfig.java:280–296). So a unit testthat calls
durableConfig(...)sends a real request whenever AWS credentials are exported.Options:
durableConfig(String, DurableExecutionClient)overload and pass a no-op client inthe test, as the SDK's own tests do. Rejected. It is a test-only seam in production code,
and the test would still build a
DurableConfigit does not need.for the same reason plus a new dependency.
telemetryConfig(String), which returns aDurableExecutionTelemetryConfig.CloudWatchLogsExportercreates its client on firstexport, so this function constructs no client. The test asserts the settings the runner
depends on.
durableConfig(String)becomes a wrap with no branch of its own; the deployedrun exercises it.
Removed. Nothing.
Decisions not covered by #179
RuntimeException("card declined"). The handler catchesRuntimeException.StepOperation.get()rebuilds the step's original exception from the checkpoint and rethrowsit;
StepFailedExceptionis only the fallback when the rebuild fails. So the step surfacesas
RuntimeException("card declined"), and catchingStepFailedExceptionlets it escape(the telemetry run on
0bb88f5e3failed withexpected 'payment failed', got 'card declined').The handler throws
RuntimeException("payment failed", cause).ca2cd02on main. See "Workflow pin" below.conformance-tests-telemetryis a standalone pom outside the SDK reactor(
conformance-tests-telemetry/pom.xml:7–15), because SAM builds it in isolation againstan installed SDK. So the root build never runs its tests. The telemetry conformance
workflow now runs
mvn packagewithout-DskipTests, which runs the module's tests beforethe deploy artifact is built. This mirrors the JS workflow, which runs
npm teston itstelemetry conformance package before building. Python and JS also include the package in
the repo-wide unit-test run; bringing this module and
conformance-tests-otelinto thereactor is a follow-up, not part of this PR.
Changes
conformance-tests-telemetry/src/main/java/.../Telemetry2Failure.java: new handler.src/main/java/.../TelemetryConformanceConfig.java: new helper holding the log-groupguard (
requireLogGroupName), the plugin settings (telemetryConfig) and the handlerconfiguration (
durableConfig).Telemetry1SuccessandTelemetry2Failurecall it.src/test/java/.../TelemetryConformanceConfigTest.java: 7 cases. Null,""," "and"\t"each throwIllegalStateException("TELEMETRY_LOG_GROUP_NAME must be set"); a setvalue is returned unchanged;
telemetryConfig(...)has oneCloudWatchLogsExporter; itsemit mode is
ON_COMPLETE, sampling rate1.0, operation detailTOP_LEVEL, and inputand output are included. No test builds a
DurableConfig, so no test builds a client.pom.xml:junit-jupiter(test scope) andmaven-surefire-plugin, versions repeated fromthe root pom; description lists telemetry-2.
template.yaml:Telemetry2Failurefunction mapped totelemetry-2.README.md: coverage row, layout lines for the helper and the test, localmvn packagestep.
.github/workflows/telemetry-conformance-tests.ymlmvn packagefor the module no longer passes-DskipTests.ca2cd02.Error shape
This SDK writes a two-level execution
error(payment failed→card declined) and aone-level
operationsByName.charge.error(card declined). The JS SDK writes three and two,the Python SDK one and one. The team decided this difference is expected. telemetry-2 at
conformance commit
121e832matches eacherrorwith{$object: {}}: present and an object,keys unchecked. The messages are asserted by the core
ExpectedResultandExpectedExecutionHistorysections. So this SDK passes telemetry-2 as is.Workflow pin
telemetry-conformance-tests.ymlpins the shared workflow toca2cd02, the #179 merge commiton main. Earlier revisions of this PR pinned the #179 head
121e832so the run exercisedtelemetry-2 before #179 merged. The previous mainline pin
0eaf734predates telemetry-2, andthe runner skipped the handler.
telemetry-suite.ymlis identical between the commits.Verification
mvn -pl telemetry-exporter -am -DskipTests installfrom the branch, thenmvn -B package -Ddurable.sdk.version=3.0.2-SNAPSHOTinconformance-tests-telemetry,with fake
AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEYexported so a client build wouldattempt a request: BUILD SUCCESS; surefire
Tests run: 7, Failures: 0, Errors: 0, Skipped: 0in 0.045 s; the shaded jar containsTelemetry1Success,Telemetry2Failureand
TelemetryConformanceConfigand no test classes.ifblock inrequireLogGroupNameremoved, the same commandfails 4 of the tests. The block was restored before commit.
spotless:checkdoes not cover it. Thefour Java files were formatted with the root
spotlessconfiguration (palantir) byrunning it on a temporary copy inside
telemetry-exporter.sam validate --lintontemplate.yaml: valid (template unchanged since).LocalDurableTestRunnerwith a capturing exporter,rendered with
record.toByNameWireMap()(the same callCloudWatchLogsExportermakes):status
FAILED,input: 41, nooutput,error: {RuntimeException, payment failed, cause: {RuntimeException, card declined}},operationsByName.charge:STEP,Step, count 1, failedCount 1, maxAttempt 1,FAILED,error: {java.lang.RuntimeException, card declined}. Every path matches telemetry-2 exceptthe missing
causelevels described above. Duration keys are absent only because the localrunner sets no operation timestamps.
telemetry-2) on the pinned [Chore]: publish javadoc #179 head: PASSED onccdae02and on
ecb5e34; rerun on0ccc30fpending.