Skip to content

Commit

Permalink
Cleaning out agent protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
TimPansino committed Jun 1, 2023
1 parent c87d31d commit 7a384c5
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions newrelic/core/agent_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ def _to_http(self, method, payload=()):
for event in event_data:
event_info, event_attrs = event
event_attrs.update({"event.domain": "newrelic.ml_events", "event.name": event_info["type"]})
ml_attrs = [self._create_key_value(key, value) for key, value in event_attrs.items()]
ml_attrs = [create_key_value(key, value) for key, value in event_attrs.items()]
ml_attrs = [key_value for key_value in ml_attrs if key_value]
ml_events.append(
{
Expand All @@ -615,18 +615,3 @@ def _to_http(self, method, payload=()):
payload = LogsData(resource_logs=[ResourceLogs(scope_logs=[ScopeLogs(log_records=ml_events)])])
return params, self._headers, payload.SerializeToString()
return params, self._headers, json_encode(payload).encode("utf-8")

def _create_key_value(self, key, value):
if isinstance(value, bool):
return KeyValue(key=key, value=AnyValue(bool_value=value))
elif isinstance(value, int):
return KeyValue(key=key, value=AnyValue(int_value=value))
elif isinstance(value, float):
return KeyValue(key=key, value=AnyValue(double_value=value))
elif isinstance(value, str):
return KeyValue(key=key, value=AnyValue(string_value=value))
# Techincally AnyValue accepts array, kvlist, and bytes however, since
# those are not valid custom attribute types according to our api spec,
# we will not bother to support them here either.
else:
_logger.warn("Unsupported ML event attribute value type %s: %s." % (key, value))

0 comments on commit 7a384c5

Please sign in to comment.