Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion newrelic/common/encoding_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,6 @@ class NrTraceState(dict):
# tx: transaction guid
# sa: sampled
# pr: priority
# tr: trace ID
# tk: trusted account key
# ti: time

Expand Down
4 changes: 1 addition & 3 deletions newrelic/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,10 +807,8 @@ def delete_setting(settings_object, name):
target = getattr(target, fields[0])
fields = fields[1].split(".", 1)

try:
if hasattr(target, fields[0]):
delattr(target, fields[0])
except AttributeError:
_logger.debug("Failed to delete setting: %r", name)


def translate_event_harvest_config_settings(settings, cached_settings):
Expand Down
28 changes: 17 additions & 11 deletions newrelic/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1666,9 +1666,25 @@ def apply_server_side_settings(server_side_config=None, settings=_settings):
apply_config_setting(settings_snapshot, name, value)

event_harvest_config = server_side_config.get("event_harvest_config", {})
harvest_limits = event_harvest_config.get("harvest_limits", ())
harvest_limits = event_harvest_config.get("harvest_limits", {})

# Override this setting here so that the allowlist that is pulled from the
# the harvest_limits includes the ml_event harvest limit.
# Since the server does not override this setting as it's an OTLP setting,
# we must override it here manually by converting it into a per harvest cycle
# value.
# override ml_events / (60s/5s) harvest
harvest_limits["ml_event_data"] = settings_snapshot.event_harvest_config.harvest_limits.ml_event_data / 12

apply_config_setting(settings_snapshot, "event_harvest_config.allowlist", frozenset(harvest_limits))

# Override ml event harvest config
ml_event_harvest_config = harvest_limits.get("ml_event_data", {})
if ml_event_harvest_config is not None:
apply_config_setting(
settings_snapshot, "event_harvest_config.harvest_limits.ml_event_data", harvest_limits["ml_event_data"]
)

# Override span event harvest config
span_event_harvest_config = server_side_config.get("span_event_harvest_config", {})
span_event_harvest_limit = span_event_harvest_config.get("harvest_limit", None)
Expand All @@ -1683,16 +1699,6 @@ def apply_server_side_settings(server_side_config=None, settings=_settings):
apply_config_setting(settings_snapshot, "ai_monitoring.enabled", collect_ai)
_logger.debug("Setting ai_monitoring.enabled to value of collect_ai=%s", collect_ai)

# Since the server does not override this setting as it's an OTLP setting,
# we must override it here manually by converting it into a per harvest cycle
# value.
apply_config_setting(
settings_snapshot,
"event_harvest_config.harvest_limits.ml_event_data",
# override ml_events / (60s/5s) harvest
settings_snapshot.event_harvest_config.harvest_limits.ml_event_data / 12,
)

# Since the server does not override this setting we must override it here manually
# by caping it at the max value of 4095.
apply_config_setting(
Expand Down
3 changes: 3 additions & 0 deletions tests/agent_features/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
translate_event_harvest_config_settings,
)
from newrelic.core.config import (
ML_EVENT_RESERVOIR_SIZE,
Settings,
_map_aws_account_id,
apply_config_setting,
Expand Down Expand Up @@ -476,6 +477,8 @@ def test_translate_event_harvest_setting_without_new_setting(external, internal)
assert result is settings
assert external.name not in flatten_settings(result)
assert fetch_config_setting(result, internal.name) == external.value
assert "ml_event_data" in settings.event_harvest_config.allowlist
assert settings.event_harvest_config.harvest_limits.ml_event_data == ML_EVENT_RESERVOIR_SIZE / 12


@pytest.mark.parametrize("external,internal", translate_event_harvest_settings_tests)
Expand Down
Loading