Skip to content

Commit

Permalink
Revert "Custom Event Limit Increase (#591)" (#622)
Browse files Browse the repository at this point in the history
This reverts commit 6ef9bce.
  • Loading branch information
TimPansino authored Sep 12, 2022
1 parent 6ef9bce commit aa23eaa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 30 deletions.
38 changes: 14 additions & 24 deletions newrelic/api/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@
import weakref
from collections import OrderedDict

from newrelic.api.application import application_instance
import newrelic.core.database_node
import newrelic.core.error_node
from newrelic.core.log_event_node import LogEventNode
import newrelic.core.root_node
import newrelic.core.transaction_node
import newrelic.packages.six as six
from newrelic.api.application import application_instance
from newrelic.api.time_trace import TimeTrace, get_linking_metadata
from newrelic.common.encoding_utils import (
DistributedTracePayload,
Expand Down Expand Up @@ -60,9 +61,8 @@
DST_NONE,
DST_TRANSACTION_TRACER,
)
from newrelic.core.config import CUSTOM_EVENT_RESERVOIR_SIZE, LOG_EVENT_RESERVOIR_SIZE
from newrelic.core.config import DEFAULT_RESERVOIR_SIZE, LOG_EVENT_RESERVOIR_SIZE
from newrelic.core.custom_event import create_custom_event
from newrelic.core.log_event_node import LogEventNode
from newrelic.core.stack_trace import exception_stack
from newrelic.core.stats_engine import CustomMetrics, SampledDataSet
from newrelic.core.thread_utilization import utilization_tracker
Expand Down Expand Up @@ -324,14 +324,10 @@ def __init__(self, application, enabled=None, source=None):
self.enabled = True

if self._settings:
self._custom_events = SampledDataSet(
capacity=self._settings.event_harvest_config.harvest_limits.custom_event_data
)
self._log_events = SampledDataSet(
capacity=self._settings.event_harvest_config.harvest_limits.log_event_data
)
self._custom_events = SampledDataSet(capacity=self._settings.event_harvest_config.harvest_limits.custom_event_data)
self._log_events = SampledDataSet(capacity=self._settings.event_harvest_config.harvest_limits.log_event_data)
else:
self._custom_events = SampledDataSet(capacity=CUSTOM_EVENT_RESERVOIR_SIZE)
self._custom_events = SampledDataSet(capacity=DEFAULT_RESERVOIR_SIZE)
self._log_events = SampledDataSet(capacity=LOG_EVENT_RESERVOIR_SIZE)

def __del__(self):
Expand Down Expand Up @@ -1477,35 +1473,31 @@ def set_transaction_name(self, name, group=None, priority=None):
self._group = group
self._name = name


def record_log_event(self, message, level=None, timestamp=None, priority=None):
settings = self.settings
if not (
settings
and settings.application_logging
and settings.application_logging.enabled
and settings.application_logging.forwarding
and settings.application_logging.forwarding.enabled
):
if not (settings and settings.application_logging and settings.application_logging.enabled and settings.application_logging.forwarding and settings.application_logging.forwarding.enabled):
return

timestamp = timestamp if timestamp is not None else time.time()
level = str(level) if level is not None else "UNKNOWN"

if not message or message.isspace():
_logger.debug("record_log_event called where message was missing. No log event will be sent.")
return

message = truncate(message, MAX_LOG_MESSAGE_LENGTH)

event = LogEventNode(
timestamp=timestamp,
level=level,
message=message,
attributes=get_linking_metadata(),
attributes=get_linking_metadata(),
)

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


def record_exception(self, exc=None, value=None, tb=None, params=None, ignore_errors=None):
# Deprecation Warning
warnings.warn(
Expand Down Expand Up @@ -1877,9 +1869,7 @@ def record_log_event(message, level=None, timestamp=None, application=None, prio
"record_log_event has been called but no transaction or application was running. As a result, "
"the following event has not been recorded. message: %r level: %r timestamp %r. To correct "
"this problem, supply an application object as a parameter to this record_log_event call.",
message,
level,
timestamp,
message, level, timestamp,
)
elif application.enabled:
application.record_log_event(message, level, timestamp, priority=priority)
Expand Down
3 changes: 1 addition & 2 deletions newrelic/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
# reservoir. Error Events have a different default size.

DEFAULT_RESERVOIR_SIZE = 1200
CUSTOM_EVENT_RESERVOIR_SIZE = 30000
ERROR_EVENT_RESERVOIR_SIZE = 100
SPAN_EVENT_RESERVOIR_SIZE = 2000
LOG_EVENT_RESERVOIR_SIZE = 10000
Expand Down Expand Up @@ -739,7 +738,7 @@ def default_host(license_key):
)

_settings.event_harvest_config.harvest_limits.custom_event_data = _environ_as_int(
"NEW_RELIC_CUSTOM_INSIGHTS_EVENTS_MAX_SAMPLES_STORED", CUSTOM_EVENT_RESERVOIR_SIZE
"NEW_RELIC_CUSTOM_INSIGHTS_EVENTS_MAX_SAMPLES_STORED", DEFAULT_RESERVOIR_SIZE
)

_settings.event_harvest_config.harvest_limits.span_event_data = _environ_as_int(
Expand Down
8 changes: 4 additions & 4 deletions tests/agent_features/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,12 +438,12 @@ def test_delete_setting_parent():
TSetting("event_harvest_config.harvest_limits.error_event_data", 100, 100),
),
(
TSetting("custom_insights_events.max_samples_stored", 30000, 30000),
TSetting("event_harvest_config.harvest_limits.custom_event_data", 9999, 30000),
TSetting("custom_insights_events.max_samples_stored", 1200, 1200),
TSetting("event_harvest_config.harvest_limits.custom_event_data", 9999, 1200),
),
(
TSetting("custom_insights_events.max_samples_stored", 9999, 30000),
TSetting("event_harvest_config.harvest_limits.custom_event_data", 30000, 30000),
TSetting("custom_insights_events.max_samples_stored", 9999, 1200),
TSetting("event_harvest_config.harvest_limits.custom_event_data", 1200, 1200),
),
(
TSetting("application_logging.forwarding.max_samples_stored", 10000, 10000),
Expand Down

0 comments on commit aa23eaa

Please sign in to comment.