How can I search `subsegment` by name in AWS xray console?

1.3k Views Asked by At

I am running lambda in AWS and enabled xray. Below is a code I use to create a subsegment inside lambda. I can see this subsegment when I click a trace. How can I search all traces with this subsegment by name in xray console?

await AWSXRay.captureAsyncFunc('create-connection', async () => {
...
1

There are 1 best solutions below

0
On BEST ANSWER

In the X-Ray console, you can only search for traces with segment names as each segment typically represents a service. Subsegment names searches are not supported.

What you can do instead is add an annotation to the created subsegment. Something like this should work:

await AWSXRay.captureAsyncFunc('create-connection', function(subsegment) => {
  subsegment.addAnnotation("mykey", "my value");
  ...

Since annotations are indexed, in the X-Ray console you can search traces with annotation like annotation.mykey = "my value"