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
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.
More Troubleshooting and Optimization questions
- A backend application uses Amazon ElastiCache for Redis in front of an Amazon RDS PostgreSQL database. Whenever the…
- Hundreds of short-lived AWS Lambda functions concurrently open and close new TCP database connections to an Amazon RDS…
- A developer wants their AWS Lambda function to emit custom business metrics (OrderValue, CheckoutLatencyMs) alongside…
- An AWS Lambda function processes CPU-intensive image resizing and takes 4,000 ms (4.0 seconds) when configured with…
- An Amazon SQS standard queue has its default VisibilityTimeout set to 30 seconds. A worker EC2 instance polls the…
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.