aws-xray-sdk-python: Manually created segments are not displayed on AWS service map

1.3k Views Asked by At

I'm running my applications in a Docker ECS container (and thus the XRAY daemon is also running in a Docker container). I see my traces resulting from automated patched libraries (requests, sqlite3, httplib, botocore) and instrumented middleware (Django). And the log shows my manually created segments and subsegments just fine, with the trace_id that I can see on the AWS service map. The problem is that the manually created segments and sub-segments, which I see in the log, are nowhere to be found on the service map.

Here, an example where in a pytest test I call my API and middleware:

from aws_xray_sdk.core import patch_all, xray_recorder

# configure X-RAY plugins for EC2 and ECS
xray_recorder.configure(
    sampling=False,
    context_missing="LOG_ERROR",
    plugins=("EC2Plugin", "ECSPlugin", "ElasticBeanstalkPlugin"),
    daemon_address="127.0.0.1:2000",
    dynamic_naming="*__init__silvakle*",
    service="__INIT__",
)
logging.basicConfig(level="WARNING")
logging.getLogger("aws_xray_sdk").setLevel(logging.DEBUG)
patch_all(double_patch=True)

def test_call_api:
    xray_recorder.begin_segment(name="systest_testX_rest_api")
    #call routine execute_command()
    xray_recorder.end_segment()

@xray_recorder.capture("## execute_command")
def execute_command(text, reply_all_messages=True):
    ...

In the terminal I see clearly the segment named "systest_testX_rest_api" and sub-segment "## execute_command", but on the AWS XRAY service map, while I see the trace_id just fine, the segments and sub-segments are nowhere to be found.

So, what am I missing here? What else are we supposed to do to have the manually created segments and sub-segments be displayed on the AWS service map?

1

There are 1 best solutions below

2
On

To answer to your question you don't need to do anything other than creating manual segments and subsegments to show up on the AWS X-Ray Console. I think for manual subsegments you have to mark it as remote in order to show up on AWS X-Ray Console. My question is do you see any downstream node of that manually created segment? Would you be able to share your trace timeline and service map image ?