@@ -528,11 +528,25 @@ def _import_opamp() -> Callable[[...], None]:
528528 # the resource and instantiate an OpAMP agent.
529529 # Since configuration is not specified every implementors may have its own.
530530 # Refer to opentelemetry-opamp-client package on how to setup the OpAMP agent.
531- _ , opamp_init_func = _import_config_components (
532- ["init_function" ], "_opentelemetry_opamp"
533- )[0 ]
531+ try :
532+ entry_point = next (
533+ iter (
534+ entry_points (
535+ group = "_opentelemetry_opamp" , name = "init_function"
536+ )
537+ )
538+ )
539+ return entry_point .load ()
540+ except StopIteration :
541+ _logger .debug ("No OpAMP init function found" )
542+ except AttributeError as exc :
543+ _logger .warning (
544+ "Failed to load OpAMP init function from entry point, %s: %s" ,
545+ entry_point ,
546+ exc ,
547+ )
534548
535- return opamp_init_func
549+ return None
536550
537551
538552def _initialize_components (
@@ -598,11 +612,9 @@ def _initialize_components(
598612 # provided code as it's not strictly specified. We call OpAMP init before other code
599613 # because people may want to have it blocking to get an updated config before setting
600614 # up the rest of the SDK.
601- try :
602- _init_opamp = _import_opamp ()
615+ _init_opamp = _import_opamp ()
616+ if _init_opamp is not None :
603617 _init_opamp (resource = resource )
604- except RuntimeError :
605- _logger .debug ("No OpAMP init function found" )
606618
607619 _init_tracing (
608620 exporters = span_exporters ,
0 commit comments