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년 전755회 조회
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년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠