An unofficial shim which faciliates the creation of AWS Xray Segments in Lambda functions triggered by SQS.
Project description
It’s not currently possibly follow an AWS Xray trace through a Lambda Function triggered by an SQS Queue.
Unless you use aws-xray-sqs-lambda-segment-shim!
Installation
pip install aws-xray-lambda-segment-shim
Usage
from aws_xray_sqs_lambda_segment_shim import SQSTriggeredXrayRecorder
def lambda_handler(event, context):
print(json.dumps(event, default=str))
for i, record in enumerate(event["Records"]):
recorder = SQSTriggeredXrayRecorder(
record=record,
lambda_request_id=context.aws_request_id,
lambda_arn=context.invoked_function_arn,
)
with recorder.in_subsegment(f"SQS Record {i}") as subsegment:
print(
"I'm triggered by an SQS Record and using trace id ",
subsegment.trace_id,
)
recorder.end_segment()
SQSTriggeredXrayRecorder is a child class of aws_xray_sdk.AWSXRayRecorder so you can use all the methods you would expect from following the aws-xray-sdk documentation.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for aws_xray_sqs_lambda_segment_shim-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 848b99d3633549e55ad6ede65fb6ba510013656fce80d572f3e598fec35b9a05 |
|
MD5 | f17cab678052e479f36655689b46c290 |
|
BLAKE2b-256 | ae65ad55bd5aafe5657ec2c6306f37f7f685b59311a3438ebb82ba0c85c3836d |
Close
Hashes for aws_xray_sqs_lambda_segment_shim-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6855eda7e515a5997e6f57118a43c759c326625c2b6d4ca675f0e69b177c364 |
|
MD5 | ff8a231c71a00bf165687fd05503ef6a |
|
BLAKE2b-256 | 804d383ea21eaf2d404d59f394815c106fe569ed73064ea3ad153647582e1a46 |