@@ -645,6 +645,63 @@ def delete_setting(settings_object, name):
645645 _logger .debug ("Failed to delete setting: %r" , name )
646646
647647
648+ def translate_event_harvest_config_settings (settings , cached_settings ):
649+ """Translate event_harvest_config settings to max_samples settings.
650+
651+ Background:
652+ The collector/server side agent configuration uses the
653+ `event_harvest_config` naming convention for their harvest
654+ limit settings. The original intent was for the language
655+ agents to switch to this convention. However, this only
656+ happened for the Python agent. Eventually, to remain
657+ consistent with the other language agents, the decision
658+ was made to change this back. However, because the server
659+ side configuration settings override the client-side settings,
660+ the agent will insist on employing the `max_samples` naming
661+ convention from the user's end but translate the settings
662+ to their deprecated `event_harvest_config` counterparts during
663+ the configuration process.
664+
665+ Here, the user will still get warnings about deprecated settings
666+ being used. However, the agent will also translate the settings
667+ to their deprecated `event_harvest_config` counterparts during
668+ the configuration process.
669+ """
670+
671+ cached = dict (cached_settings )
672+
673+ event_harvest_to_max_samples_settings_map = [
674+ ("event_harvest_config.harvest_limits.analytic_event_data" , "transaction_events.max_samples_stored" ),
675+ ("event_harvest_config.harvest_limits.span_event_data" , "span_events.max_samples_stored" ),
676+ ("event_harvest_config.harvest_limits.error_event_data" , "error_collector.max_event_samples_stored" ),
677+ ("event_harvest_config.harvest_limits.custom_event_data" , "custom_insights_events.max_samples_stored" ),
678+ ("event_harvest_config.harvest_limits.log_event_data" , "application_logging.forwarding.max_samples_stored" ),
679+ ]
680+
681+ for event_harvest_key , max_samples_key in event_harvest_to_max_samples_settings_map :
682+ if event_harvest_key in cached :
683+ _logger .info (
684+ "Deprecated setting found: %r. Please use new setting: %r." , event_harvest_key , max_samples_key
685+ )
686+
687+ if max_samples_key in cached :
688+ # Since there is the max_samples key as well as the event_harvest key,
689+ # we need to apply the max_samples value to the event_harvest key.
690+ apply_config_setting (settings , event_harvest_key , cached [max_samples_key ])
691+ _logger .info (
692+ "Ignoring deprecated setting: %r. Using new setting: %r." , event_harvest_key , max_samples_key
693+ )
694+ else :
695+ # Translation to event_harvest_config has already happened
696+ _logger .info ("Applying value of deprecated setting %r to %r." , event_harvest_key , max_samples_key )
697+ elif max_samples_key in cached :
698+ apply_config_setting (settings , event_harvest_key , cached [max_samples_key ])
699+
700+ delete_setting (settings , max_samples_key )
701+
702+ return settings
703+
704+
648705def translate_deprecated_settings (settings , cached_settings ):
649706 # If deprecated setting has been set by user, but the new
650707 # setting has not, then translate the deprecated setting to the
@@ -676,19 +733,7 @@ def translate_deprecated_settings(settings, cached_settings):
676733 cached = dict (cached_settings )
677734
678735 deprecated_settings_map = [
679- ("transaction_tracer.capture_attributes" , "transaction_tracer.attributes.enabled" ),
680- ("error_collector.capture_attributes" , "error_collector.attributes.enabled" ),
681- ("browser_monitoring.capture_attributes" , "browser_monitoring.attributes.enabled" ),
682- ("analytics_events.capture_attributes" , "transaction_events.attributes.enabled" ),
683- ("analytics_events.enabled" , "transaction_events.enabled" ),
684- ("analytics_events.max_samples_stored" , "transaction_events.max_samples_stored" ),
685- ("event_harvest_config.harvest_limits.analytic_event_data" , "transaction_events.max_samples_stored" ),
686- ("event_harvest_config.harvest_limits.span_event_data" , "span_events.max_samples_stored" ),
687- ("event_harvest_config.harvest_limits.error_event_data" , "error_collector.max_event_samples_stored" ),
688- ("event_harvest_config.harvest_limits.custom_event_data" , "custom_insights_events.max_samples_stored" ),
689- ("event_harvest_config.harvest_limits.log_event_data" , "application_logging.forwarding.max_samples_stored" ),
690- ("error_collector.ignore_errors" , "error_collector.ignore_classes" ),
691- ("strip_exception_messages.whitelist" , "strip_exception_messages.allowlist" ),
736+ # Nothing in here right now!
692737 ]
693738
694739 for old_key , new_key in deprecated_settings_map :
@@ -986,6 +1031,10 @@ def _load_configuration(config_file=None, environment=None, ignore_errors=True,
9861031
9871032 translate_deprecated_settings (_settings , _cache_object )
9881033
1034+ # Translate event_harvest_config settings to max_samples settings (from user's side)
1035+
1036+ translate_event_harvest_config_settings (_settings , _cache_object )
1037+
9891038 # Apply High Security Mode policy if enabled in local agent
9901039 # configuration file.
9911040
0 commit comments