Skip to content

Commit

Permalink
Replace all TODOs w/ new config settings
Browse files Browse the repository at this point in the history
  • Loading branch information
hmstepanek committed May 2, 2023
1 parent 435b01c commit 20cf30d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
3 changes: 1 addition & 2 deletions newrelic/api/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -1626,8 +1626,7 @@ def record_ml_event(self, event_type, params):
if not settings:
return

# TODO Fix settings
if not settings.custom_insights_events.enabled:
if not settings.machine_learning.inference_events.enabled:
return

event = create_custom_event(event_type, params)
Expand Down
6 changes: 2 additions & 4 deletions newrelic/core/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -882,8 +882,7 @@ def record_ml_event(self, event_type, params):

settings = self._stats_engine.settings

# TODO Fix this with actual settings
if settings is None or not settings.custom_insights_events.enabled:
if settings in None or not settings.machine_learning.inference_events.enabled:
return

event = create_custom_event(event_type, params)
Expand Down Expand Up @@ -1354,8 +1353,7 @@ def harvest(self, shutdown=False, flexible=False):

# Send machine learning events

# TODO Fix this with actual settings names
if configuration.collect_custom_events and configuration.custom_insights_events.enabled:
if configuration.machine_learning and configuration.machine_learning.inference_events.enabled:
ml_events = stats.ml_events

if ml_events:
Expand Down
7 changes: 5 additions & 2 deletions newrelic/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1114,11 +1114,14 @@ def apply_server_side_settings(server_side_config=None, settings=_settings):
for name, value in server_side_config.items():
apply_config_setting(settings_snapshot, name, value)

# TODO: override ml_events / 5 s harvest
# 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.
# TODO: override ml_events / (60s/5s) harvest
apply_config_setting(
settings_snapshot.event_harvest_config.harvest_limits.ml_event_data,
"event_harvest_config.harvest_limits.ml_event_data",
event_harvest_config.harvest_limits.ml_event_data / 12,
settings_snapshot.event_harvest_config.harvest_limits.ml_event_data / 12,
)

event_harvest_config = server_side_config.get("event_harvest_config", {})
Expand Down
9 changes: 3 additions & 6 deletions newrelic/core/stats_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,8 +848,7 @@ def record_ml_event(self, event):
if not settings:
return

# TODO Fix this with actual settings
if settings.collect_custom_events and settings.custom_insights_events.enabled:
if settings.machine_learning and settings.machine_learning.inference_events.enabled:
self._ml_events.add(event)

def record_custom_metric(self, name, value):
Expand Down Expand Up @@ -1067,8 +1066,7 @@ def record_transaction(self, transaction):

# Merge in machine learning events

# TODO Fix this with actual settings
if settings.collect_custom_events and settings.custom_insights_events.enabled:
if settings.machine_learning and settings.machine_learning.inference_events.enabled:
self.ml_events.merge(transaction.ml_events)

# Merge in span events
Expand Down Expand Up @@ -1521,8 +1519,7 @@ def reset_custom_events(self):

def reset_ml_events(self):
if self.__settings is not None:
# TODO fix this with the actual setting
self._ml_events = SampledDataSet(8333)
self._ml_events = SampledDataSet(self.__settings.event_harvest_config.harvest_limits.ml_event_data)
else:
self._ml_events = SampledDataSet()

Expand Down

0 comments on commit 20cf30d

Please sign in to comment.