Skip to content
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

Bug: Tracing is not working when Event Source decorator is used #4303

Closed
SZubarev opened this issue May 8, 2024 · 3 comments
Closed

Bug: Tracing is not working when Event Source decorator is used #4303

SZubarev opened this issue May 8, 2024 · 3 comments
Labels
cant-reproduce Any issues that cannot be reproduced not-a-bug

Comments

@SZubarev
Copy link
Contributor

SZubarev commented May 8, 2024

Expected Behaviour

If I add @tracer decorator the X-Ray tracing should work

Current Behaviour

If @tracer decorator is used together with @event_source decorator X-Ray tracing is not working.
Also original X-Ray SDK decorator @xray_recorder.capture() not working if @event_source decorator is used.

Code snippet

@tracer.capture_lambda_handler
@event_source(data_class=ActiveMQEvent)
def lambda_handler(event: ActiveMQEvent, context: LambdaContext):

    for message in event.messages:
    ....


### Possible Solution

_No response_

### Steps to Reproduce

Add tracer decorator together with event_source decorator

### Powertools for AWS Lambda (Python) version

latest

### AWS Lambda function runtime

3.12

### Packaging format used

Lambda Layers

### Debugging logs

_No response_
@SZubarev SZubarev added bug Something isn't working triage Pending triage from maintainers labels May 8, 2024
@SZubarev SZubarev changed the title Tracing is not working when Event Source is used Bug: Tracing is not working when Event Source decorator is used May 9, 2024
@leandrodamascena
Copy link
Contributor

Hi @SZubarev, thanks for opening this issue and reporting what may be a bug.

I was trying to reproduce this error but I couldn't. Following the steps I did to reproduce. Can you please provide a minimal and reproducible code and payload?

code

from aws_lambda_powertools import Tracer
from aws_lambda_powertools.utilities.data_classes import event_source, EventBridgeEvent

tracer = Tracer() 

@tracer.capture_lambda_handler
@event_source(data_class=EventBridgeEvent)
def lambda_handler(event: EventBridgeEvent, context):
    print("time ---->", event.time)
    return "OK"

payload

{
  "version": "0",
  "id": "6a7e8feb-b491-4cf7-a9f1-bf3703467718",
  "detail-type": "EC2 Instance State-change Notification",
  "source": "aws.ec2",
  "account": "111122223333",
  "time": "2017-12-22T18:43:48Z",
  "region": "us-west-1",
  "resources": [
    "arn:aws:ec2:us-west-1:123456789012:instance/i-1234567890abcdef0"
  ],
  "detail": {
    "instance_id": "i-1234567890abcdef0",
    "state": "terminated"
  },
  "replay-name": "replay_archive"
}

execution result

Test Event Name
zsas

Response
"OK"

Function Logs
START RequestId: 25dd6166-850a-4a8f-8934-8fa73846a51f Version: $LATEST
time ----> 2017-12-22T18:43:48Z
END RequestId: 25dd6166-850a-4a8f-8934-8fa73846a51f
REPORT RequestId: 25dd6166-850a-4a8f-8934-8fa73846a51f	Duration: 4.09 ms	Billed Duration: 4 ms	Memory Size: 128 MB	Max Memory Used: 63 MB	Init Duration: 527.00 ms	
XRAY TraceId: 1-663d4990-18d87888009633dd6dae583a	SegmentId: f5914f9d61cd9bac	Sampled: true

Request ID
25dd6166-850a-4a8f-8934-8fa73846a51f

Trace

image

Thanks

@leandrodamascena leandrodamascena added cant-reproduce Any issues that cannot be reproduced not-a-bug and removed bug Something isn't working triage Pending triage from maintainers labels May 9, 2024
@SZubarev
Copy link
Contributor Author

Root cause was event sourcing from Amazon MQ which doesn't provide XRay headers to request when sending messages to lambda. Closing.

@github-project-automation github-project-automation bot moved this from Triage to Coming soon in Powertools for AWS Lambda (Python) May 10, 2024
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

@heitorlessa heitorlessa moved this from Coming soon to Shipped in Powertools for AWS Lambda (Python) Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cant-reproduce Any issues that cannot be reproduced not-a-bug
Projects
Status: Shipped
Development

No branches or pull requests

2 participants