segment.addAnnotation() does nothing?

1

Hi folks,

In my node.js Lambda function, I have a simple handler that does this:

const AWSXRay = require("aws-xray-sdk");

exports.handler = async (event, context) => {
const seg = AWSXRay.getSegment();
seg.addAnnotation("theme", "MeTheme");
seg.addMetadata("meta1", "meta2");
};

This is pretty much what's in the AWS docs. But when I view the trace in the XRay console, I can't find the annotation or metadata anywhere. I don't seem them in the raw document, or in any of the UI tabs marked Annotations or Metadata.

I could use some guidance here please - am I looking in the wrong place, or is my code incorrect?

Thanks,

ws

Edited by: Warren-at-work on May 11, 2020 12:59 PM

已提问 4 年前754 查看次数
2 回答
1
已接受的回答

I think by looking at the code you might be trying to modify segment in Lambda environment. You can not modify lambda created segment using your function code. This document confirms this behavior (https://docs.aws.amazon.com/xray/latest/devguide/xray-services-lambda.html). I believe you can create subsegments, add annotation inside the subsegment and you should be able to see that in your raw trace data as well as annotations tab on your trace. Hope this helps!

已回答 4 年前
1

You were correct - many thanks!!

已回答 4 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则

相关内容