AWS Developer DVA-C02 · Troubleshooting and Optimization · medium

A developer instruments a microservices payment API with the AWS X-Ray SDK. They want to attach custom key-value data (customerTier = "PLATINUM" and orderId = "ORD-99281") to X-Ray segments so engineers can filter traces in the X-Ray console using filter expressions like annotation.customerTier = "PLATINUM". They also want to attach a 12 KB raw debug JSON response object that does not need to be indexed for search. How should the developer record these two pieces of data in the X-Ray SDK?

Published · Last updated · checked before publication — how we verify questions

Options

  • ARecord customerTier as X-Ray Metadata and the 12 KB JSON object as an Annotation
  • BRecord customerTier and orderId as Annotations and the 12 KB JSON as MetadataCorrect answer
  • CStore both inside the X-Ray Sampling Rule reservoir JSON configuration file
  • DWrite both values into the EC2 instance's /etc/hosts file for the X-Ray daemon

Answer: B. Record customerTier and orderId as Annotations and the 12 KB JSON as Metadata

In AWS X-Ray, Annotations (putAnnotation) are indexed by X-Ray (up to 50 per trace) so you can query them in Filter Expressions (annotation.<key> = <value>). Metadata (putMetadata) is not indexed for search and is used to store larger structured objects/arrays for inspection inside individual traces.

Why the other options are wrong

  • A. Record customerTier as X-Ray Metadata and the 12 KB JSON object as an Annotation — This is backwards: Metadata is not indexed for filter expressions, and Annotations only accept scalar string/number/boolean values.
  • C. Store both inside the X-Ray Sampling Rule reservoir JSON configuration file — Sampling Rules control what percentage of requests are traced, not per-request key-value trace attributes.
  • D. Write both values into the EC2 instance's /etc/hosts file for the X-Ray daemon — /etc/hosts is for local OS hostname resolution and is not read as X-Ray trace segment attributes.

All Troubleshooting and Optimization questions and the topic overview →

AWS and Amazon Web Services are trademarks of Amazon.com, Inc. PrepIQ Hub is not affiliated with, endorsed by, or sponsored by Amazon Web Services.