Repository navigation
feat(telemetry): add the telemetry-4 conformance handler #924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
67f89ff
feat(telemetry): add the telemetry-4 conformance handler
hln33 738180f
ci(telemetry): pin the conformance suite to the telemetry-4 branch head
hln33 076a632
ci(telemetry): re-pin the conformance suite to the rebased telemetry-…
hln33 8f70085
ci(telemetry): pin the conformance suite to the telemetry-4 merge commit
hln33 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
...durable-execution-sdk-python-conformance-tests-telemetry/src/telemetry_4_full_tree_map.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| # SPDX-FileCopyrightText: 2026-present Amazon.com, Inc. or its affiliates. | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| """Full-tree operation detail for requirement telemetry-4. | ||
|
|
||
| The handler maps over the event ``[1, 2]`` with ``maxConcurrency=1``. The item | ||
| namer names each iteration ``item-<item>``. Each iteration runs one step named | ||
| ``greet-<item>``. The plugin runs with ``operation_detail="full-tree"``. So the | ||
| record's ``operationsByName`` holds the map context ``process-items``, the two | ||
| iteration contexts ``item-1`` and ``item-2``, and the two steps ``greet-1`` and | ||
| ``greet-2``. Under ``top-level`` detail the record would hold only | ||
| ``process-items``. | ||
|
|
||
| The handler uses the real SDK API only. It builds no record and calls no | ||
| exporter method. A missing or wrong record is the plugin's defect, and that | ||
| defect is the signal the suite measures. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import os | ||
| from typing import Any | ||
|
|
||
| from aws_durable_execution_sdk_python import ( | ||
| DurableContext, | ||
| StepContext, | ||
| durable_execution, | ||
| durable_step, | ||
| ) | ||
| from aws_durable_execution_sdk_python.config import MapConfig | ||
| from aws_durable_execution_sdk_python_telemetry_exporter import ( | ||
| CloudWatchLogsExporter, | ||
| ContentConfig, | ||
| DurableExecutionTelemetryConfig, | ||
| durable_execution_telemetry, | ||
| ) | ||
|
|
||
|
|
||
| # The template sets this variable. Without it the exporter has no target. | ||
| # So the module fails at import instead of dropping records silently. | ||
| log_group_name = os.environ.get("TELEMETRY_LOG_GROUP_NAME") | ||
| if not log_group_name: | ||
| raise RuntimeError("TELEMETRY_LOG_GROUP_NAME must be set") | ||
|
|
||
|
|
||
| @durable_step | ||
| def greet(_step_context: StepContext, item: int) -> str: | ||
| return f"Hello, {item}!" | ||
|
|
||
|
|
||
| def map_fn(ctx: DurableContext, item: int, _index: int, _items: Any) -> str: | ||
| result: str = ctx.step(greet(item), name=f"greet-{item}") | ||
| return result | ||
|
|
||
|
|
||
| @durable_execution( | ||
| plugins=[ | ||
| durable_execution_telemetry( | ||
| DurableExecutionTelemetryConfig( | ||
| exporters=[CloudWatchLogsExporter(log_group_name=log_group_name)], | ||
| emit_mode="on-complete", | ||
| sampling_rate=1, | ||
| operation_detail="full-tree", | ||
| content=ContentConfig(input=True, output=True), | ||
| ) | ||
| ) | ||
| ] | ||
| ) | ||
| def handler(event: list[int], context: DurableContext) -> list[str]: | ||
| results: list[str] = context.map( | ||
| event, | ||
| map_fn, | ||
| name="process-items", | ||
| config=MapConfig( | ||
| max_concurrency=1, | ||
| item_namer=lambda item, index: f"item-{item}", | ||
| ), | ||
| ).get_results() | ||
| return results | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.