diff --git a/aws-opentelemetry-distro/src/amazon/opentelemetry/distro/always_record_sampler.py b/aws-opentelemetry-distro/src/amazon/opentelemetry/distro/always_record_sampler.py index 962eb3bb8..afc4212b7 100644 --- a/aws-opentelemetry-distro/src/amazon/opentelemetry/distro/always_record_sampler.py +++ b/aws-opentelemetry-distro/src/amazon/opentelemetry/distro/always_record_sampler.py @@ -52,7 +52,7 @@ def should_sample( parent_context, trace_id, name, kind, attributes, links, trace_state ) if result.decision is Decision.DROP: - result = _wrap_result_with_record_only_result(result) + result = _wrap_result_with_record_only_result(result, attributes) return result @override @@ -60,9 +60,9 @@ def get_description(self) -> str: return "AlwaysRecordSampler{" + self._root_sampler.get_description() + "}" -def _wrap_result_with_record_only_result(result: SamplingResult) -> SamplingResult: +def _wrap_result_with_record_only_result(result: SamplingResult, attributes: Attributes) -> SamplingResult: return SamplingResult( Decision.RECORD_ONLY, - result.attributes, + attributes, result.trace_state, ) diff --git a/aws-opentelemetry-distro/tests/amazon/opentelemetry/distro/test_always_record_sampler.py b/aws-opentelemetry-distro/tests/amazon/opentelemetry/distro/test_always_record_sampler.py index 50da959d1..13557130f 100644 --- a/aws-opentelemetry-distro/tests/amazon/opentelemetry/distro/test_always_record_sampler.py +++ b/aws-opentelemetry-distro/tests/amazon/opentelemetry/distro/test_always_record_sampler.py @@ -38,7 +38,7 @@ def validate_should_sample(self, root_decision: Decision, expected_decision: Dec trace_id=0, name="name", kind=SpanKind.CLIENT, - attributes={}, + attributes={"key": root_decision.name}, trace_state=TraceState(), )