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

Subsegment missing in trace #319

Open
Ftwpker opened this issue Jan 28, 2022 · 2 comments
Open

Subsegment missing in trace #319

Ftwpker opened this issue Jan 28, 2022 · 2 comments
Assignees
Labels

Comments

@Ftwpker
Copy link

Ftwpker commented Jan 28, 2022

Hi all,

I'm currently trying to setup individual subsegments for a dynamoDB and SQS call to see their individual performance.

My project is in Java using Micronaut and GraalVM (I followed these steps to add the needed classes for reflection to work)

After doing so I was able to see subsegment traces for SQS but when I add in a subsegment for dynamoDB call, I no longer see the SQS subsegment info for that trace.

After debugging a bit I see the parent traceIDs are the same for both but at the end of the call, there is only one subsegment added to the current segment which is the dynamo one.

Here are the way my current subsegments are setup:

SQS
`

SendMessageRequest sendMessageRequest =
    SendMessageRequest.builder().messageBody(message).queueUrl(queueUrl).build();

Subsegment subsegment = AWSXRay.beginSubsegment("sqs");

return sqsAsyncClient
    .sendMessage(sendMessageRequest)
    .thenAccept(
        x -> {
          AWSXRay.endSubsegment(subsegment);
          log.info("Successfully queued request: {}", message);
        })
    .exceptionally(throwable -> handleExceptions(throwable, message));`

I know I need to also close the subsegment in case of exception but for testing purposes I haven't done so yet and all my request are successful so far.

DynamoDb

`

Subsegment dbSegment = AWSXRay.beginSubsegment("db call");

boolean result =
    dynamoDao
        .messageExists(message)
        .thenApply(
            x -> {
              AWSXRay.endSubsegment(dbSegment);
              log.info("Successfully checked message status");
              return x;
            })
        .exceptionally(
            exception -> {
              return false;
            })
        .join();

return result;`
@willarmiros
Copy link
Contributor

Hi @Ftwpker,

You can instrument individual clients made with the AWS SDK so that subsegments are created automatically for those downstream calls. This is documented here: https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-java-awssdkclients.html

You shouldn't need to manually create subsegments. Hope this helps!

@Ftwpker
Copy link
Author

Ftwpker commented Feb 3, 2022

Thanks @willarmiros, I may try that out again for this project but in the case where we want to also instrument a non AWS service we may leverage subsegments so definitely would be helpful if we are able to get it working.

I did eventually get the subsegments to show up by encapsulating both subsegments under another subsegment.

`

Subsegment subsegment = AWSXRay.beginSubsegment("processing start");

//would contain trace for dynamo from the inital post
checkMessageExists(...)

//would contain trace for sqs from the inital post
sendSQSMessage(...)

AWSXray.endSubsegment(subsegment)

`

However if I had the individual subsegments in each method without wrapping in another subsegment it seems whichever subsegment that began and ended first was added whereas the other subsegment did not get logged with xray.

So in this case I would usually see the DB subsegment but not the sqs subsegment.

Not sure why the wrapping would make it work and the individual subsegment seems to stop after the first one is finished

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants