-
Notifications
You must be signed in to change notification settings - Fork 171
Description
Use case
✨ Feature Request: Support for manualSegment
in captureAWSv3Client()
Summary
Currently, the Tracer.captureAWSv3Client()
method in AWS Lambda Powertools for TypeScript only accepts a single argument — the AWS SDK v3 client instance. This restricts users from passing a manual X-Ray segment or subsegment, which is supported in the underlying aws-xray-sdk-core
via:
captureAWSv3Client<T>(client: T, segment?: SegmentLike): T
For use cases that require precise control over segment context — such as batch processing — this limitation makes trace hierarchy management difficult.
Use Case
When processing events using processPartialResponse()
or similar batch utilities, each item may require a dedicated subsegment. The ability to pass this subsegment to captureAWSv3Client()
ensures AWS SDK calls are correctly nested within the item’s trace. Without this, SDK calls may attach to incorrect segments or appear disconnected in X-Ray.
Contribution
I'm open to contributing a pull request if this enhancement aligns with the maintainers’ vision for the library.
Solution/User Experience
Proposed Solution
Update the Tracer.captureAWSv3Client()
method to accept an optional second parameter for a manual SegmentLike
. This would internally forward both arguments to the X-Ray SDK’s native method, preserving existing behavior while enhancing flexibility:
captureAWSv3Client<T>(client: T, segment?: SegmentLike): T
This change would remain backward compatible and enable more advanced tracing scenarios.
Alternative solutions
Using the X-Ray SDK directly. This bypasses Powertools but loses consistency and built-in annotations.
Subclassing the Tracer to reintroduce the missing parameter. Functional, but not ideal for long-term maintainability.
Acknowledgment
- This feature request meets Powertools for AWS Lambda (TypeScript) Tenets
- Should this be considered in other Powertools for AWS Lambda languages? i.e. Python, Java, and .NET
Future readers
Please react with 👍 and your use case to help us understand customer demand.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status