Skip to content

Conversation

@lukeina2z
Copy link
Contributor

@lukeina2z lukeina2z commented Sep 5, 2025

Description

Moto 5.0.9, released in May 2024, lacks support for certain AWS resources such as Step Functions APIs (describeActivity). This PR upgrades moto to the latest release (5.1.11) to add these capabilities.

After the upgrade, one DynamoDB unit test failed. This PR also addresses that failure.

The unit test failures after upgrading moto from 5.0.9 to 5.1.11 happened due to two key improvements in moto's DynamoDB implementation:

  1. Enhanced Parameter Validation Before (moto 5.0.9): Moto had lenient validation and allowed invalid parameter combinations like Segment=21 with TotalSegments=17, even though this violates AWS DynamoDB's actual behavior.

After (moto 5.1.11): Moto added stricter validation that matches AWS DynamoDB's real behavior:

Segment parameter must be zero-based (0 to TotalSegments-1)

Segment=21 with TotalSegments=17 now correctly throws ValidationException

  1. More Accurate Parallel Scan Simulation Before (moto 5.0.9): Moto's parallel scan implementation was simplified and might have returned items regardless of which segment was being scanned, leading to predictable but incorrect behavior.

After (moto 5.1.11): Moto improved its parallel scan simulation to more accurately reflect how AWS DynamoDB distributes items across segments:

Items are distributed based on hash values of partition keys

Different segments contain different subsets of data

Segment 16 (out of 17 total) might legitimately contain 0 items if the hash distribution doesn't place any items there

Why This Matters
These changes make moto behave more like the actual AWS DynamoDB service, which is beneficial for testing because:

Tests catch invalid parameter usage that would fail in production

Tests reflect realistic data distribution patterns

Code is validated against more accurate AWS behavior

The test failures weren't bugs in the OpenTelemetry instrumentation code - they were issues with the test setup that became visible when moto started enforcing AWS's actual constraints and behavior patterns.

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Test

Verified with:
tox -e py312-test-instrumentation-botocore
tox -e spellcheck
tox -e lint-instrumentation-botocore
tox -e ruff

Skip Changelog
as this PR only impacts unit tests.

Moto 5.0.9, released in May 2024, lacks support for certain AWS resources such as Step Functions APIs. This PR upgrades moto to the latest release (5.1.11) to add these capabilities.

After the upgrade, one DynamoDB unit test failed. This PR also addresses that failure.

The unit test failures after upgrading moto from 5.0.9 to 5.1.11 happened due to two key improvements in moto's DynamoDB implementation:

1. Enhanced Parameter Validation
Before (moto 5.0.9): Moto had lenient validation and allowed invalid parameter combinations like Segment=21 with TotalSegments=17, even though this violates AWS DynamoDB's actual behavior.

After (moto 5.1.11): Moto added stricter validation that matches AWS DynamoDB's real behavior:

Segment parameter must be zero-based (0 to TotalSegments-1)

Segment=21 with TotalSegments=17 now correctly throws ValidationException

2. More Accurate Parallel Scan Simulation
Before (moto 5.0.9): Moto's parallel scan implementation was simplified and might have returned items regardless of which segment was being scanned, leading to predictable but incorrect behavior.

After (moto 5.1.11): Moto improved its parallel scan simulation to more accurately reflect how AWS DynamoDB distributes items across segments:

Items are distributed based on hash values of partition keys

Different segments contain different subsets of data

Segment 16 (out of 17 total) might legitimately contain 0 items if the hash distribution doesn't place any items there

Why This Matters
These changes make moto behave more like the actual AWS DynamoDB service, which is beneficial for testing because:

Tests catch invalid parameter usage that would fail in production

Tests reflect realistic data distribution patterns

Code is validated against more accurate AWS behavior

The test failures weren't bugs in the OpenTelemetry instrumentation code - they were issues with the test setup that became visible when moto started enforcing AWS's actual constraints and behavior patterns.
@yiyuan-he
Copy link

LGTM, just needs a changelog

@lukeina2z lukeina2z requested a review from a team as a code owner September 5, 2025 23:39
@lukeina2z
Copy link
Contributor Author

LGTM, just needs a changelog

Added. I thought it's not required as this change is only about unit test.

lukeina2z added a commit to lukeina2z/opentelemetry-python-contrib that referenced this pull request Sep 6, 2025
…ibutes

AWS Step Functions defines two semantic convention attributes:

aws.step_functions.activity.arn
aws.step_functions.state_machine.arn

https://github.com/open-telemetry/semantic-conventions/blob/main/docs/registry/attributes/aws.md#amazon-step-functions-attributes

Currently, these attributes are not set in the botocore instrumentation library. This PR adds support for them by extracting values from both Request and Response objects.

Tests
Added new unit tests (passing).

Verified with:
tox -e py312-test-instrumentation-botocore
tox -e spellcheck
tox -e lint-instrumentation-botocore
tox -e ruff

Backward Compatibility
This change is backward compatible. It only adds instrumentation for additional AWS resources and does not modify existing behavior in the auto-instrumentation library.

Note
This PR depends on open-telemetry#3736. Since open-telemetry#3736 has not yet been merged, its changes are included here as well.
@xrmx xrmx moved this to Easy to review / merge / close in @xrmx's Python PR digest Sep 9, 2025
@xrmx xrmx enabled auto-merge (squash) September 9, 2025 16:46
@xrmx xrmx merged commit edb34e6 into open-telemetry:main Sep 9, 2025
632 checks passed
@github-project-automation github-project-automation bot moved this from Easy to review / merge / close to Done in @xrmx's Python PR digest Sep 9, 2025
chloe-zh97 pushed a commit to chloe-zh97/opentelemetry-python-contrib that referenced this pull request Sep 10, 2025
)

* botocore: upgrade moto package from 5.0.9 to 5.1.11

Moto 5.0.9, released in May 2024, lacks support for certain AWS resources such as Step Functions APIs. This PR upgrades moto to the latest release (5.1.11) to add these capabilities.

After the upgrade, one DynamoDB unit test failed. This PR also addresses that failure.

The unit test failures after upgrading moto from 5.0.9 to 5.1.11 happened due to two key improvements in moto's DynamoDB implementation:

1. Enhanced Parameter Validation
Before (moto 5.0.9): Moto had lenient validation and allowed invalid parameter combinations like Segment=21 with TotalSegments=17, even though this violates AWS DynamoDB's actual behavior.

After (moto 5.1.11): Moto added stricter validation that matches AWS DynamoDB's real behavior:

Segment parameter must be zero-based (0 to TotalSegments-1)

Segment=21 with TotalSegments=17 now correctly throws ValidationException

2. More Accurate Parallel Scan Simulation
Before (moto 5.0.9): Moto's parallel scan implementation was simplified and might have returned items regardless of which segment was being scanned, leading to predictable but incorrect behavior.

After (moto 5.1.11): Moto improved its parallel scan simulation to more accurately reflect how AWS DynamoDB distributes items across segments:

Items are distributed based on hash values of partition keys

Different segments contain different subsets of data

Segment 16 (out of 17 total) might legitimately contain 0 items if the hash distribution doesn't place any items there

Why This Matters
These changes make moto behave more like the actual AWS DynamoDB service, which is beneficial for testing because:

Tests catch invalid parameter usage that would fail in production

Tests reflect realistic data distribution patterns

Code is validated against more accurate AWS behavior

The test failures weren't bugs in the OpenTelemetry instrumentation code - they were issues with the test setup that became visible when moto started enforcing AWS's actual constraints and behavior patterns.

* add changelog.
xrmx added a commit that referenced this pull request Sep 10, 2025
…ibutes (#3737)

* botocore: Add support for AWS Step Functions semantic convention attributes

AWS Step Functions defines two semantic convention attributes:

aws.step_functions.activity.arn
aws.step_functions.state_machine.arn

https://github.com/open-telemetry/semantic-conventions/blob/main/docs/registry/attributes/aws.md#amazon-step-functions-attributes

Currently, these attributes are not set in the botocore instrumentation library. This PR adds support for them by extracting values from both Request and Response objects.

Tests
Added new unit tests (passing).

Verified with:
tox -e py312-test-instrumentation-botocore
tox -e spellcheck
tox -e lint-instrumentation-botocore
tox -e ruff

Backward Compatibility
This change is backward compatible. It only adds instrumentation for additional AWS resources and does not modify existing behavior in the auto-instrumentation library.

Note
This PR depends on #3736. Since #3736 has not yet been merged, its changes are included here as well.

* add changelog.

---------

Co-authored-by: Riccardo Magliocchetti <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants