A developer uses the AWS X-Ray SDK inside a Lambda function and wants to attach the customer tier to each trace so that traces can later be filtered and grouped by tier in the X-Ray console. The value must be indexed so it can be used in a filter expression. Which X-Ray feature should the developer add to the segment?
- AAdd the customer tier as segment metadata, because metadata fields are indexed by X-Ray and become available as keys in trace filter expressions.
- BAdd the customer tier to the structured log line, because X-Ray reads CloudWatch log fields and exposes them as indexed keys in filter expressions.
- CAdd the customer tier as a subsegment name, because X-Ray indexes subsegment names and lets you filter traces using the recorded name value.
- DAdd the customer tier as a segment annotation, because annotations are indexed by X-Ray and can be used directly in trace filter expressions. Correct
Why A is wrong: Metadata is stored with the trace for context but is not indexed, so it cannot be used in a filter expression to search or group traces by tier.
Why B is wrong: X-Ray does not index CloudWatch log fields into trace filter expressions, so writing the tier only to logs leaves traces unsearchable by that value.
Why C is wrong: Subsegment names describe units of work and are not a place for variable business keys, and renaming them per tier would break the timing view rather than enable filtering.
Why D is correct: Annotations are key value pairs that X-Ray indexes, so the tier becomes searchable and can group traces through a filter expression on that annotation key.