@@ -638,6 +638,63 @@ def delete_setting(settings_object, name):
638638        _logger .debug ("Failed to delete setting: %r" , name )
639639
640640
641+ def  translate_event_harvest_config_settings (settings , cached_settings ):
642+     """Translate event_harvest_config settings to max_samples settings. 
643+ 
644+     Background: 
645+     The collector/server side agent configuration uses the 
646+     `event_harvest_config` naming convention for their harvest 
647+     limit settings.  The original intent was for the language 
648+     agents to switch to this convention.  However, this only 
649+     happened for the Python agent.  Eventually, to remain 
650+     consistent with the other language agents, the decision 
651+     was made to change this back.  However, because the server 
652+     side configuration settings override the client-side settings, 
653+     the agent will insist on employing the `max_samples` naming 
654+     convention from the user's end but translate the settings 
655+     to their deprecated `event_harvest_config` counterparts during 
656+     the configuration process. 
657+ 
658+     Here, the user will still get warnings about deprecated settings 
659+     being used.  However, the agent will also translate the settings 
660+     to their deprecated `event_harvest_config` counterparts during 
661+     the configuration process. 
662+     """ 
663+ 
664+     cached  =  dict (cached_settings )
665+ 
666+     event_harvest_to_max_samples_settings_map  =  [
667+         ("event_harvest_config.harvest_limits.analytic_event_data" , "transaction_events.max_samples_stored" ),
668+         ("event_harvest_config.harvest_limits.span_event_data" , "span_events.max_samples_stored" ),
669+         ("event_harvest_config.harvest_limits.error_event_data" , "error_collector.max_event_samples_stored" ),
670+         ("event_harvest_config.harvest_limits.custom_event_data" , "custom_insights_events.max_samples_stored" ),
671+         ("event_harvest_config.harvest_limits.log_event_data" , "application_logging.forwarding.max_samples_stored" ),
672+     ]
673+ 
674+     for  event_harvest_key , max_samples_key  in  event_harvest_to_max_samples_settings_map :
675+         if  event_harvest_key  in  cached :
676+             _logger .info (
677+                 "Deprecated setting found: %r. Please use new setting: %r." , event_harvest_key , max_samples_key 
678+             )
679+ 
680+             if  max_samples_key  in  cached :
681+                 # Since there is the max_samples key as well as the event_harvest key, 
682+                 # we need to apply the max_samples value to the event_harvest key. 
683+                 apply_config_setting (settings , event_harvest_key , cached [max_samples_key ])
684+                 _logger .info (
685+                     "Ignoring deprecated setting: %r. Using new setting: %r." , event_harvest_key , max_samples_key 
686+                 )
687+             else :
688+                 # Translation to event_harvest_config has already happened 
689+                 _logger .info ("Applying value of deprecated setting %r to %r." , event_harvest_key , max_samples_key )
690+         elif  max_samples_key  in  cached :
691+             apply_config_setting (settings , event_harvest_key , cached [max_samples_key ])
692+ 
693+         delete_setting (settings , max_samples_key )
694+ 
695+     return  settings 
696+ 
697+ 
641698def  translate_deprecated_settings (settings , cached_settings ):
642699    # If deprecated setting has been set by user, but the new 
643700    # setting has not, then translate the deprecated setting to the 
@@ -669,19 +726,7 @@ def translate_deprecated_settings(settings, cached_settings):
669726    cached  =  dict (cached_settings )
670727
671728    deprecated_settings_map  =  [
672-         ("transaction_tracer.capture_attributes" , "transaction_tracer.attributes.enabled" ),
673-         ("error_collector.capture_attributes" , "error_collector.attributes.enabled" ),
674-         ("browser_monitoring.capture_attributes" , "browser_monitoring.attributes.enabled" ),
675-         ("analytics_events.capture_attributes" , "transaction_events.attributes.enabled" ),
676-         ("analytics_events.enabled" , "transaction_events.enabled" ),
677-         ("analytics_events.max_samples_stored" , "transaction_events.max_samples_stored" ),
678-         ("event_harvest_config.harvest_limits.analytic_event_data" , "transaction_events.max_samples_stored" ),
679-         ("event_harvest_config.harvest_limits.span_event_data" , "span_events.max_samples_stored" ),
680-         ("event_harvest_config.harvest_limits.error_event_data" , "error_collector.max_event_samples_stored" ),
681-         ("event_harvest_config.harvest_limits.custom_event_data" , "custom_insights_events.max_samples_stored" ),
682-         ("event_harvest_config.harvest_limits.log_event_data" , "application_logging.forwarding.max_samples_stored" ),
683-         ("error_collector.ignore_errors" , "error_collector.ignore_classes" ),
684-         ("strip_exception_messages.whitelist" , "strip_exception_messages.allowlist" ),
729+         # Nothing in here right now! 
685730    ]
686731
687732    for  old_key , new_key  in  deprecated_settings_map :
@@ -979,6 +1024,10 @@ def _load_configuration(config_file=None, environment=None, ignore_errors=True,
9791024
9801025    translate_deprecated_settings (_settings , _cache_object )
9811026
1027+     # Translate event_harvest_config settings to max_samples settings (from user's side) 
1028+ 
1029+     translate_event_harvest_config_settings (_settings , _cache_object )
1030+ 
9821031    # Apply High Security Mode policy if enabled in local agent 
9831032    # configuration file. 
9841033
0 commit comments