@@ -931,6 +931,38 @@ def test_sets_deactivate_instrumentations_with_same_rules(
931931 self .assertEqual (len (rule_based_tracer_configurator .rules ), 1 )
932932 _updatable_tracer_configurator .cache_clear ()
933933
934+ @mock .patch ("elasticotel.distro.config._get_config" )
935+ @mock .patch ("elasticotel.sdk.trace.tracer_configurator._get_tracer_configurator" )
936+ @mock .patch ("opentelemetry.trace.get_tracer_provider" )
937+ def test_sets_deactivate_instrumentations_handles_unexpected_tracer_provider (
938+ self , get_tracer_provider_mock , get_tracer_configurator_mock , get_config_mock
939+ ):
940+ config = Config ()
941+ get_config_mock .return_value = config
942+ get_tracer_provider_mock .return_value = None
943+
944+ agent = mock .Mock ()
945+ client = mock .Mock ()
946+ config = opamp_pb2 .AgentConfigMap ()
947+ config .config_map ["elastic" ].body = json .dumps ({"deactivate_instrumentations" : "" }).encode ()
948+ config .config_map ["elastic" ].content_type = "application/json"
949+ remote_config = opamp_pb2 .AgentRemoteConfig (config = config , config_hash = b"1234" )
950+ message = opamp_pb2 .ServerToAgent (remote_config = remote_config )
951+ opamp_handler (agent , client , message )
952+
953+ client ._update_remote_config_status .assert_called_once_with (
954+ remote_config_hash = b"1234" , status = opamp_pb2 .RemoteConfigStatuses_APPLIED , error_message = ""
955+ )
956+ client ._update_effective_config .assert_called_once_with (
957+ {"elastic" : {"logging_level" : "warn" , "sampling_rate" : "1.0" , "deactivate_instrumentations" : "" }}
958+ )
959+ client ._build_remote_config_status_response_message .assert_called_once_with (
960+ client ._update_remote_config_status ()
961+ )
962+ agent .send .assert_called_once_with (payload = mock .ANY )
963+ client ._build_full_state_message .assert_not_called ()
964+ get_tracer_configurator_mock .assert_not_called ()
965+
934966 @mock .patch ("elasticotel.distro.config._get_config" )
935967 @mock .patch ("opentelemetry.trace.get_tracer_provider" )
936968 def test_calls_build_full_state_message_when_report_full_state_flag_is_set (
0 commit comments