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

posta 4 anni fa750 visualizzazioni
2 Risposte
1
Risposta accettata

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!

con risposta 4 anni fa
1

You were correct - many thanks!!

con risposta 4 anni fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande