diff --git a/instrumentation/opentelemetry-instrumentation-celery/tests/test_utils.py b/instrumentation/opentelemetry-instrumentation-celery/tests/test_utils.py index a2f6e4338c..b627332e79 100644 --- a/instrumentation/opentelemetry-instrumentation-celery/tests/test_utils.py +++ b/instrumentation/opentelemetry-instrumentation-celery/tests/test_utils.py @@ -282,3 +282,27 @@ def test_task_id_from_protocol_v2(self): task_id = utils.retrieve_task_id_from_message(context) self.assertEqual(task_id, "7e917b83-4018-431d-9832-73a28e1fb6c0") + + def test_origin_and_hostname_attributes(self): + """Test that 'origin' and 'hostname' are distinct attributes""" + # Create a mock span + span = mock.Mock() + span.is_recording.return_value = True + + # Create a context with both 'origin' and 'hostname' keys + context = { + "origin": "gen8@b98c7aca4628", + "hostname": "celery@7c2c2cd6a5b5", + } + + # Call the function + utils.set_attributes_from_context(span, context) + + # Verify that both attributes were set with their original keys + span.set_attribute.assert_has_calls( + [ + mock.call("celery.origin", "gen8@b98c7aca4628"), + mock.call("celery.hostname", "celery@7c2c2cd6a5b5"), + ], + any_order=True, + )