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

demandé il y a 4 ans747 vues
2 réponses
1
Réponse acceptée

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!

répondu il y a 4 ans
1

You were correct - many thanks!!

répondu il y a 4 ans

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions