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

preguntada hace 4 años747 visualizaciones
2 Respuestas
1
Respuesta aceptada

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!

respondido hace 4 años
1

You were correct - many thanks!!

respondido hace 4 años

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas