Skip to content

Commit 6ef9bce

Browse files
authored
Custom Event Limit Increase (#591)
* Update reservoir size for custom events. * [Mega-Linter] Apply linters fixes Co-authored-by: TimPansino <[email protected]>
1 parent d0896ae commit 6ef9bce

File tree

3 files changed

+30
-19
lines changed

3 files changed

+30
-19
lines changed

newrelic/api/transaction.py

+24-14
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,12 @@
2525
import weakref
2626
from collections import OrderedDict
2727

28-
from newrelic.api.application import application_instance
2928
import newrelic.core.database_node
3029
import newrelic.core.error_node
31-
from newrelic.core.log_event_node import LogEventNode
3230
import newrelic.core.root_node
3331
import newrelic.core.transaction_node
3432
import newrelic.packages.six as six
33+
from newrelic.api.application import application_instance
3534
from newrelic.api.time_trace import TimeTrace, get_linking_metadata
3635
from newrelic.common.encoding_utils import (
3736
DistributedTracePayload,
@@ -61,8 +60,9 @@
6160
DST_NONE,
6261
DST_TRANSACTION_TRACER,
6362
)
64-
from newrelic.core.config import DEFAULT_RESERVOIR_SIZE, LOG_EVENT_RESERVOIR_SIZE
63+
from newrelic.core.config import CUSTOM_EVENT_RESERVOIR_SIZE, LOG_EVENT_RESERVOIR_SIZE
6564
from newrelic.core.custom_event import create_custom_event
65+
from newrelic.core.log_event_node import LogEventNode
6666
from newrelic.core.stack_trace import exception_stack
6767
from newrelic.core.stats_engine import CustomMetrics, SampledDataSet
6868
from newrelic.core.thread_utilization import utilization_tracker
@@ -324,10 +324,14 @@ def __init__(self, application, enabled=None, source=None):
324324
self.enabled = True
325325

326326
if self._settings:
327-
self._custom_events = SampledDataSet(capacity=self._settings.event_harvest_config.harvest_limits.custom_event_data)
328-
self._log_events = SampledDataSet(capacity=self._settings.event_harvest_config.harvest_limits.log_event_data)
327+
self._custom_events = SampledDataSet(
328+
capacity=self._settings.event_harvest_config.harvest_limits.custom_event_data
329+
)
330+
self._log_events = SampledDataSet(
331+
capacity=self._settings.event_harvest_config.harvest_limits.log_event_data
332+
)
329333
else:
330-
self._custom_events = SampledDataSet(capacity=DEFAULT_RESERVOIR_SIZE)
334+
self._custom_events = SampledDataSet(capacity=CUSTOM_EVENT_RESERVOIR_SIZE)
331335
self._log_events = SampledDataSet(capacity=LOG_EVENT_RESERVOIR_SIZE)
332336

333337
def __del__(self):
@@ -1473,31 +1477,35 @@ def set_transaction_name(self, name, group=None, priority=None):
14731477
self._group = group
14741478
self._name = name
14751479

1476-
14771480
def record_log_event(self, message, level=None, timestamp=None, priority=None):
14781481
settings = self.settings
1479-
if not (settings and settings.application_logging and settings.application_logging.enabled and settings.application_logging.forwarding and settings.application_logging.forwarding.enabled):
1482+
if not (
1483+
settings
1484+
and settings.application_logging
1485+
and settings.application_logging.enabled
1486+
and settings.application_logging.forwarding
1487+
and settings.application_logging.forwarding.enabled
1488+
):
14801489
return
1481-
1490+
14821491
timestamp = timestamp if timestamp is not None else time.time()
14831492
level = str(level) if level is not None else "UNKNOWN"
1484-
1493+
14851494
if not message or message.isspace():
14861495
_logger.debug("record_log_event called where message was missing. No log event will be sent.")
14871496
return
1488-
1497+
14891498
message = truncate(message, MAX_LOG_MESSAGE_LENGTH)
14901499

14911500
event = LogEventNode(
14921501
timestamp=timestamp,
14931502
level=level,
14941503
message=message,
1495-
attributes=get_linking_metadata(),
1504+
attributes=get_linking_metadata(),
14961505
)
14971506

14981507
self._log_events.add(event, priority=priority)
14991508

1500-
15011509
def record_exception(self, exc=None, value=None, tb=None, params=None, ignore_errors=None):
15021510
# Deprecation Warning
15031511
warnings.warn(
@@ -1869,7 +1877,9 @@ def record_log_event(message, level=None, timestamp=None, application=None, prio
18691877
"record_log_event has been called but no transaction or application was running. As a result, "
18701878
"the following event has not been recorded. message: %r level: %r timestamp %r. To correct "
18711879
"this problem, supply an application object as a parameter to this record_log_event call.",
1872-
message, level, timestamp,
1880+
message,
1881+
level,
1882+
timestamp,
18731883
)
18741884
elif application.enabled:
18751885
application.record_log_event(message, level, timestamp, priority=priority)

newrelic/core/config.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
# reservoir. Error Events have a different default size.
5353

5454
DEFAULT_RESERVOIR_SIZE = 1200
55+
CUSTOM_EVENT_RESERVOIR_SIZE = 30000
5556
ERROR_EVENT_RESERVOIR_SIZE = 100
5657
SPAN_EVENT_RESERVOIR_SIZE = 2000
5758
LOG_EVENT_RESERVOIR_SIZE = 10000
@@ -738,7 +739,7 @@ def default_host(license_key):
738739
)
739740

740741
_settings.event_harvest_config.harvest_limits.custom_event_data = _environ_as_int(
741-
"NEW_RELIC_CUSTOM_INSIGHTS_EVENTS_MAX_SAMPLES_STORED", DEFAULT_RESERVOIR_SIZE
742+
"NEW_RELIC_CUSTOM_INSIGHTS_EVENTS_MAX_SAMPLES_STORED", CUSTOM_EVENT_RESERVOIR_SIZE
742743
)
743744

744745
_settings.event_harvest_config.harvest_limits.span_event_data = _environ_as_int(

tests/agent_features/test_configuration.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -438,12 +438,12 @@ def test_delete_setting_parent():
438438
TSetting("event_harvest_config.harvest_limits.error_event_data", 100, 100),
439439
),
440440
(
441-
TSetting("custom_insights_events.max_samples_stored", 1200, 1200),
442-
TSetting("event_harvest_config.harvest_limits.custom_event_data", 9999, 1200),
441+
TSetting("custom_insights_events.max_samples_stored", 30000, 30000),
442+
TSetting("event_harvest_config.harvest_limits.custom_event_data", 9999, 30000),
443443
),
444444
(
445-
TSetting("custom_insights_events.max_samples_stored", 9999, 1200),
446-
TSetting("event_harvest_config.harvest_limits.custom_event_data", 1200, 1200),
445+
TSetting("custom_insights_events.max_samples_stored", 9999, 30000),
446+
TSetting("event_harvest_config.harvest_limits.custom_event_data", 30000, 30000),
447447
),
448448
(
449449
TSetting("application_logging.forwarding.max_samples_stored", 10000, 10000),

0 commit comments

Comments
 (0)