Skip to content

Commit 91cd056

Browse files
authored
Merge branch 'develop-11.0.0' into remove_CAT
2 parents a12b023 + 4b415e4 commit 91cd056

File tree

14 files changed

+128
-66
lines changed

14 files changed

+128
-66
lines changed

newrelic/api/transaction.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,9 @@ def __init__(self, application, enabled=None, source=None):
320320
self.enabled = True
321321

322322
if self._settings:
323-
self._custom_events = SampledDataSet(
324-
capacity=self._settings.event_harvest_config.harvest_limits.custom_event_data
325-
)
323+
self._custom_events = SampledDataSet(capacity=self._settings.custom_insights_events.max_samples_stored)
326324
self._ml_events = SampledDataSet(capacity=self._settings.event_harvest_config.harvest_limits.ml_event_data)
327-
self._log_events = SampledDataSet(
328-
capacity=self._settings.event_harvest_config.harvest_limits.log_event_data
329-
)
325+
self._log_events = SampledDataSet(capacity=self._settings.application_logging.forwarding.max_samples_stored)
330326
else:
331327
self._custom_events = SampledDataSet(capacity=CUSTOM_EVENT_RESERVOIR_SIZE)
332328
self._log_events = SampledDataSet(capacity=LOG_EVENT_RESERVOIR_SIZE)

newrelic/config.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -669,12 +669,19 @@ def translate_deprecated_settings(settings, cached_settings):
669669
cached = dict(cached_settings)
670670

671671
deprecated_settings_map = [
672-
("analytics_events.max_samples_stored", "event_harvest_config.harvest_limits.analytic_event_data"),
673-
("transaction_events.max_samples_stored", "event_harvest_config.harvest_limits.analytic_event_data"),
674-
("span_events.max_samples_stored", "event_harvest_config.harvest_limits.span_event_data"),
675-
("error_collector.max_event_samples_stored", "event_harvest_config.harvest_limits.error_event_data"),
676-
("custom_insights_events.max_samples_stored", "event_harvest_config.harvest_limits.custom_event_data"),
677-
("application_logging.forwarding.max_samples_stored", "event_harvest_config.harvest_limits.log_event_data"),
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"),
678685
]
679686

680687
for old_key, new_key in deprecated_settings_map:

newrelic/core/config.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -811,11 +811,17 @@ def default_otlp_host(host):
811811
)
812812

813813
_settings.transaction_events.enabled = True
814+
_settings.transaction_events.max_samples_stored = _environ_as_int(
815+
"NEW_RELIC_ANALYTICS_EVENTS_MAX_SAMPLES_STORED", default=DEFAULT_RESERVOIR_SIZE
816+
)
814817
_settings.transaction_events.attributes.enabled = True
815818
_settings.transaction_events.attributes.exclude = []
816819
_settings.transaction_events.attributes.include = []
817820

818821
_settings.custom_insights_events.enabled = True
822+
_settings.custom_insights_events.max_samples_stored = _environ_as_int(
823+
"NEW_RELIC_CUSTOM_INSIGHTS_EVENTS_MAX_SAMPLES_STORED", default=CUSTOM_EVENT_RESERVOIR_SIZE
824+
)
819825
_settings.custom_insights_events.max_attribute_value = _environ_as_int(
820826
"NEW_RELIC_CUSTOM_INSIGHTS_EVENTS_MAX_ATTRIBUTE_VALUE", default=MAX_ATTRIBUTE_LENGTH
821827
)
@@ -831,6 +837,9 @@ def default_otlp_host(host):
831837
)
832838
_settings.distributed_tracing.exclude_newrelic_header = False
833839
_settings.span_events.enabled = _environ_as_bool("NEW_RELIC_SPAN_EVENTS_ENABLED", default=True)
840+
_settings.span_events.max_samples_stored = _environ_as_int(
841+
"NEW_RELIC_SPAN_EVENTS_MAX_SAMPLES_STORED", default=SPAN_EVENT_RESERVOIR_SIZE
842+
)
834843
_settings.span_events.attributes.enabled = True
835844
_settings.span_events.attributes.exclude = []
836845
_settings.span_events.attributes.include = []
@@ -858,6 +867,9 @@ def default_otlp_host(host):
858867
_settings.error_collector.ignore_classes = []
859868
_settings.error_collector.ignore_status_codes = _parse_status_codes("100-102 200-208 226 300-308 404", set())
860869
_settings.error_collector.expected_classes = []
870+
_settings.error_collector.max_event_samples_stored = _environ_as_int(
871+
"NEW_RELIC_ERROR_COLLECTOR_MAX_EVENT_SAMPLES_STORED", default=ERROR_EVENT_RESERVOIR_SIZE
872+
)
861873
_settings.error_collector.expected_status_codes = set()
862874
_settings.error_collector._error_group_callback = None
863875
_settings.error_collector.attributes.enabled = True
@@ -1014,6 +1026,9 @@ def default_otlp_host(host):
10141026
_settings.application_logging.forwarding.custom_attributes = _environ_as_mapping(
10151027
"NEW_RELIC_APPLICATION_LOGGING_FORWARDING_CUSTOM_ATTRIBUTES", default=""
10161028
)
1029+
_settings.application_logging.forwarding.max_samples_stored = _environ_as_int(
1030+
"NEW_RELIC_APPLICATION_LOGGING_FORWARDING_MAX_SAMPLES_STORED", default=LOG_EVENT_RESERVOIR_SIZE
1031+
)
10171032

10181033
_settings.application_logging.forwarding.labels.enabled = _environ_as_bool(
10191034
"NEW_RELIC_APPLICATION_LOGGING_FORWARDING_LABELS_ENABLED", default=False
@@ -1299,9 +1314,7 @@ def apply_server_side_settings(server_side_config=None, settings=_settings):
12991314
span_event_harvest_config = server_side_config.get("span_event_harvest_config", {})
13001315
span_event_harvest_limit = span_event_harvest_config.get("harvest_limit", None)
13011316
if span_event_harvest_limit is not None:
1302-
apply_config_setting(
1303-
settings_snapshot, "event_harvest_config.harvest_limits.span_event_data", span_event_harvest_limit
1304-
)
1317+
apply_config_setting(settings_snapshot, "span_events.max_samples_stored", span_event_harvest_limit)
13051318

13061319
# Check to see if collect_ai appears in the connect response to handle account-level AIM toggling
13071320
collect_ai = server_side_config.get("collect_ai", None)

newrelic/core/stats_engine.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,21 +1704,19 @@ def reset_transaction_events(self):
17041704
"""
17051705

17061706
if self.__settings is not None:
1707-
self._transaction_events = SampledDataSet(
1708-
self.__settings.event_harvest_config.harvest_limits.analytic_event_data
1709-
)
1707+
self._transaction_events = SampledDataSet(self.__settings.transaction_events.max_samples_stored)
17101708
else:
17111709
self._transaction_events = SampledDataSet()
17121710

17131711
def reset_error_events(self):
17141712
if self.__settings is not None:
1715-
self._error_events = SampledDataSet(self.__settings.event_harvest_config.harvest_limits.error_event_data)
1713+
self._error_events = SampledDataSet(self.__settings.error_collector.max_event_samples_stored)
17161714
else:
17171715
self._error_events = SampledDataSet()
17181716

17191717
def reset_custom_events(self):
17201718
if self.__settings is not None:
1721-
self._custom_events = SampledDataSet(self.__settings.event_harvest_config.harvest_limits.custom_event_data)
1719+
self._custom_events = SampledDataSet(self.__settings.custom_insights_events.max_samples_stored)
17221720
else:
17231721
self._custom_events = SampledDataSet()
17241722

@@ -1730,13 +1728,13 @@ def reset_ml_events(self):
17301728

17311729
def reset_span_events(self):
17321730
if self.__settings is not None:
1733-
self._span_events = SampledDataSet(self.__settings.event_harvest_config.harvest_limits.span_event_data)
1731+
self._span_events = SampledDataSet(self.__settings.span_events.max_samples_stored)
17341732
else:
17351733
self._span_events = SampledDataSet()
17361734

17371735
def reset_log_events(self):
17381736
if self.__settings is not None:
1739-
self._log_events = SampledDataSet(self.__settings.event_harvest_config.harvest_limits.log_event_data)
1737+
self._log_events = SampledDataSet(self.__settings.application_logging.forwarding.max_samples_stored)
17401738
else:
17411739
self._log_events = SampledDataSet()
17421740

tests/agent_features/test_configuration.py

Lines changed: 60 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -406,52 +406,94 @@ def test_delete_setting_parent():
406406

407407
translate_settings_tests = [
408408
(
409-
TSetting("analytics_events.max_samples_stored", 1200, 1200),
410-
TSetting("event_harvest_config.harvest_limits.analytic_event_data", 9999, 1200),
409+
TSetting("strip_exception_messages.whitelist", [], []),
410+
TSetting("strip_exception_messages.allowlist", ["non-default-value"], []),
411411
),
412412
(
413-
TSetting("analytics_events.max_samples_stored", 9999, 1200),
414-
TSetting("event_harvest_config.harvest_limits.analytic_event_data", 1200, 1200),
413+
TSetting("strip_exception_messages.whitelist", ["non-default-value"], []),
414+
TSetting("strip_exception_messages.allowlist", [], []),
415415
),
416416
(
417-
TSetting("transaction_events.max_samples_stored", 1200, 1200),
418-
TSetting("event_harvest_config.harvest_limits.analytic_event_data", 9999, 1200),
417+
TSetting("transaction_tracer.capture_attributes", True, True),
418+
TSetting("transaction_tracer.attributes.enabled", False, True),
419+
),
420+
(
421+
TSetting("transaction_tracer.capture_attributes", False, True),
422+
TSetting("transaction_tracer.attributes.enabled", True, True),
423+
),
424+
(
425+
TSetting("error_collector.capture_attributes", True, True),
426+
TSetting("error_collector.attributes.enabled", False, True),
427+
),
428+
(
429+
TSetting("error_collector.capture_attributes", False, True),
430+
TSetting("error_collector.attributes.enabled", True, True),
431+
),
432+
(
433+
TSetting("browser_monitoring.capture_attributes", False, False),
434+
TSetting("browser_monitoring.attributes.enabled", True, False),
419435
),
420436
(
437+
TSetting("browser_monitoring.capture_attributes", True, False),
438+
TSetting("browser_monitoring.attributes.enabled", False, False),
439+
),
440+
(
441+
TSetting("analytics_events.capture_attributes", True, True),
442+
TSetting("transaction_events.attributes.enabled", False, True),
443+
),
444+
(
445+
TSetting("analytics_events.capture_attributes", False, True),
446+
TSetting("transaction_events.attributes.enabled", True, True),
447+
),
448+
(TSetting("analytics_events.enabled", True, True), TSetting("transaction_events.enabled", False, True)),
449+
(TSetting("analytics_events.enabled", False, True), TSetting("transaction_events.enabled", True, True)),
450+
(
451+
TSetting("analytics_events.max_samples_stored", 1200, 1200),
421452
TSetting("transaction_events.max_samples_stored", 9999, 1200),
453+
),
454+
(
455+
TSetting("analytics_events.max_samples_stored", 9999, 1200),
456+
TSetting("transaction_events.max_samples_stored", 1200, 1200),
457+
),
458+
(
422459
TSetting("event_harvest_config.harvest_limits.analytic_event_data", 1200, 1200),
460+
TSetting("transaction_events.max_samples_stored", 9999, 1200),
423461
),
424462
(
425-
TSetting("span_events.max_samples_stored", 1000, 2000),
426-
TSetting("event_harvest_config.harvest_limits.span_event_data", 9999, 2000),
463+
TSetting("event_harvest_config.harvest_limits.analytic_event_data", 9999, 1200),
464+
TSetting("transaction_events.max_samples_stored", 1200, 1200),
427465
),
428466
(
429-
TSetting("span_events.max_samples_stored", 9999, 2000),
430467
TSetting("event_harvest_config.harvest_limits.span_event_data", 1000, 2000),
468+
TSetting("span_events.max_samples_stored", 9999, 2000),
431469
),
432470
(
433-
TSetting("error_collector.max_event_samples_stored", 100, 100),
434-
TSetting("event_harvest_config.harvest_limits.error_event_data", 9999, 100),
471+
TSetting("event_harvest_config.harvest_limits.span_event_data", 9999, 2000),
472+
TSetting("span_events.max_samples_stored", 1000, 2000),
435473
),
436474
(
437-
TSetting("error_collector.max_event_samples_stored", 9999, 100),
438475
TSetting("event_harvest_config.harvest_limits.error_event_data", 100, 100),
476+
TSetting("error_collector.max_event_samples_stored", 9999, 100),
439477
),
440478
(
441-
TSetting("custom_insights_events.max_samples_stored", 3600, 3600),
442-
TSetting("event_harvest_config.harvest_limits.custom_event_data", 9999, 3600),
479+
TSetting("event_harvest_config.harvest_limits.error_event_data", 9999, 100),
480+
TSetting("error_collector.max_event_samples_stored", 100, 100),
443481
),
444482
(
445-
TSetting("custom_insights_events.max_samples_stored", 9999, 3600),
446483
TSetting("event_harvest_config.harvest_limits.custom_event_data", 3600, 3600),
484+
TSetting("custom_insights_events.max_samples_stored", 9999, 3600),
447485
),
448486
(
449-
TSetting("application_logging.forwarding.max_samples_stored", 10000, 10000),
450-
TSetting("event_harvest_config.harvest_limits.log_event_data", 99999, 10000),
487+
TSetting("event_harvest_config.harvest_limits.custom_event_data", 9999, 3600),
488+
TSetting("custom_insights_events.max_samples_stored", 3600, 3600),
451489
),
452490
(
453-
TSetting("application_logging.forwarding.max_samples_stored", 99999, 10000),
454491
TSetting("event_harvest_config.harvest_limits.log_event_data", 10000, 10000),
492+
TSetting("application_logging.forwarding.max_samples_stored", 99999, 10000),
493+
),
494+
(
495+
TSetting("event_harvest_config.harvest_limits.log_event_data", 99999, 10000),
496+
TSetting("application_logging.forwarding.max_samples_stored", 10000, 10000),
455497
),
456498
]
457499

tests/agent_features/test_notice_error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ def test_transaction_error_event_limit():
411411
@override_application_settings(
412412
{
413413
"agent_limits.errors_per_harvest": _errors_per_harvest_limit,
414-
"event_harvest_config.harvest_limits.error_event_data": _error_event_limit,
414+
"error_collector.max_event_samples_stored": _error_event_limit,
415415
}
416416
)
417417
@reset_core_stats_engine()

tests/agent_features/test_priority_sampling.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from newrelic.api.background_task import BackgroundTask
2525

2626

27-
@override_application_settings({"event_harvest_config.harvest_limits.analytic_event_data": 1})
27+
@override_application_settings({"transaction_events.max_samples_stored": 1})
2828
@pytest.mark.parametrize("first_transaction_saved", [True, False])
2929
def test_priority_used_in_transaction_events(first_transaction_saved):
3030
first_priority = 1 if first_transaction_saved else 0
@@ -57,7 +57,7 @@ def _test():
5757
_test()
5858

5959

60-
@override_application_settings({"event_harvest_config.harvest_limits.error_event_data": 1})
60+
@override_application_settings({"error_collector.max_event_samples_stored": 1})
6161
@pytest.mark.parametrize("first_transaction_saved", [True, False])
6262
def test_priority_used_in_transaction_error_events(first_transaction_saved):
6363
first_priority = 1 if first_transaction_saved else 0
@@ -97,7 +97,7 @@ def _test():
9797
_test()
9898

9999

100-
@override_application_settings({"event_harvest_config.harvest_limits.custom_event_data": 1})
100+
@override_application_settings({"custom_insights_events.max_samples_stored": 1})
101101
@pytest.mark.parametrize("first_transaction_saved", [True, False])
102102
def test_priority_used_in_transaction_custom_events(first_transaction_saved):
103103
first_priority = 1 if first_transaction_saved else 0

tests/agent_unittests/test_connect_response_fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def test_span_event_harvest_config(connect_response_fields):
140140
from newrelic.core.config import SPAN_EVENT_RESERVOIR_SIZE
141141

142142
expected = SPAN_EVENT_RESERVOIR_SIZE
143-
assert protocol.configuration.event_harvest_config.harvest_limits.span_event_data == expected
143+
assert protocol.configuration.span_events.max_samples_stored == expected
144144

145145

146146
@override_generic_settings(global_settings(), {"developer_mode": True})

tests/agent_unittests/test_harvest_loop.py

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def test_application_harvest_with_spans(distributed_tracing_enabled, span_events
342342
"license_key": "**NOT A LICENSE KEY**",
343343
"distributed_tracing.enabled": distributed_tracing_enabled,
344344
"span_events.enabled": span_events_enabled,
345-
"event_harvest_config.harvest_limits.span_event_data": max_samples_stored,
345+
"span_events.max_samples_stored": max_samples_stored,
346346
},
347347
)
348348
def _test():
@@ -507,10 +507,10 @@ def test_adaptive_sampling(transaction_node, monkeypatch):
507507
"feature_flag": set(),
508508
"distributed_tracing.enabled": True,
509509
"application_logging.forwarding.enabled": True,
510-
"event_harvest_config.harvest_limits.error_event_data": 1000,
511-
"event_harvest_config.harvest_limits.span_event_data": 1000,
512-
"event_harvest_config.harvest_limits.custom_event_data": 1000,
513-
"event_harvest_config.harvest_limits.log_event_data": 1000,
510+
"error_collector.max_event_samples_stored": 1000,
511+
"span_events.max_samples_stored": 1000,
512+
"custom_insights_events.max_samples_stored": 1000,
513+
"application_logging.forwarding.max_samples_stored": 1000,
514514
},
515515
)
516516
def test_reservoir_sizes(transaction_node):
@@ -530,13 +530,13 @@ def test_reservoir_sizes(transaction_node):
530530

531531

532532
@pytest.mark.parametrize(
533-
"harvest_name, event_name",
533+
"harvest_setting,event_name",
534534
[
535-
("analytic_event_data", "transaction_events"),
536-
("error_event_data", "error_events"),
537-
("custom_event_data", "custom_events"),
538-
("log_event_data", "log_events"),
539-
("span_event_data", "span_events"),
535+
("transaction_events.max_samples_stored", "transaction_events"),
536+
("error_collector.max_event_samples_stored", "error_events"),
537+
("custom_insights_events.max_samples_stored", "custom_events"),
538+
("application_logging.forwarding.max_samples_stored", "log_events"),
539+
("span_events.max_samples_stored", "span_events"),
540540
],
541541
)
542542
@override_generic_settings(
@@ -548,11 +548,18 @@ def test_reservoir_sizes(transaction_node):
548548
"distributed_tracing.enabled": True,
549549
},
550550
)
551-
def test_reservoir_size_zeros(harvest_name, event_name):
551+
def test_reservoir_size_zeros(harvest_setting, event_name):
552552
app = Application("Python Agent Test (Harvest Loop)")
553553
app.connect_to_data_collector(None)
554554

555-
setattr(settings.event_harvest_config.harvest_limits, harvest_name, 0)
555+
# Walk down the settings tree until the 2nd to last setting name is reached to get the
556+
# settings container, then set the final setting on that container to 0
557+
harvest_setting = list(harvest_setting.split("."))
558+
_settings = settings
559+
for setting_attr in harvest_setting[:-1]:
560+
_settings = getattr(_settings, setting_attr)
561+
setattr(_settings, harvest_setting[-1], 0)
562+
556563
settings.event_harvest_config.allowlist = frozenset(())
557564
app._stats_engine.reset_stats(settings)
558565

@@ -600,7 +607,7 @@ def test_error_event_sampling_info(events_seen):
600607
{
601608
"developer_mode": True,
602609
"license_key": "**NOT A LICENSE KEY**",
603-
"event_harvest_config.harvest_limits.error_event_data": reservoir_size,
610+
"error_collector.max_event_samples_stored": reservoir_size,
604611
},
605612
)
606613
def _test():
@@ -669,7 +676,7 @@ def transactions_validator(payload):
669676
settings,
670677
{
671678
"developer_mode": True,
672-
"event_harvest_config.harvest_limits.analytic_event_data": transactions_limit,
679+
"transaction_events.max_samples_stored": transactions_limit,
673680
"agent_limits.synthetics_events": synthetics_limit,
674681
},
675682
)

tests/logger_logging/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"application_logging.forwarding.context_data.enabled": True,
3232
"application_logging.metrics.enabled": True,
3333
"application_logging.local_decorating.enabled": True,
34-
"event_harvest_config.harvest_limits.log_event_data": 100000,
34+
"application_logging.forwarding.max_samples_stored": 100000,
3535
}
3636

3737
collector_agent_registration = collector_agent_registration_fixture(

0 commit comments

Comments
 (0)