Creating segment for async_django_q_task

0

Hello, I have added xray to my django app and it works correctly for every api call , Custom segment and subsegments I created except custom segments of functions that are called inside async_django_q_task. It looks like it does create traces for them but they are empty, example of such trace:

{
    "Id": "some_id",
    "Duration": null,
    "LimitExceeded": false,
    "Segments": []
}

Example of the way I try to trace the function in async_django_q_task:

def dummy_function():
    xray_recorder.begin_segment('segment')
    do_something()
    xray_recorder.end_segment()
async_django_q_task(dummy_function)

Thanks in advance for help.

asked 2 years ago252 views
1 Answer
0

Hi. Sorry that you are running into this weird issue. I would like to ask a few follow up questions to investigate further.

  1. Are you running your code in a Lambda function? if yes, does this issue happen consistently or intermittently?
  2. Since the code involves async execution, there is a possibility that the execution completes outside the scope of the function execution. Do you see the async method complete execution before Lambda function finishes?
  3. Does your Lambda function have enough permissions to send traces to X-Ray backend?
  4. If possible, can you enable Debug level logs on the X-Ray SDK and see if the segments are being emitted or if there are any errors?
  5. If possible, can you provide the incoming trace header to your code? Just want to make sure if the incoming trace header is sampled or not.
AWS
answered 2 years ago
  • Hi, thank you and sorry for late response.

    1. No, the code runs in a django server on an ec2 instace.
    2. We don't use lambda function
    3. Yes, the EC2 send traces of regular http requests just fine.
    4. Does x-ray sdk has it's own log file? because I'm not seeing any xray related logs in our app log file.
    5. I'm sorry, I don't quite understand what do you mean by "provide the incoming trace header to your code", can you please elaborate?(read the trace header section in the docs but I don't understand what you mean by "provide" it)

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions