Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions python/ray/dashboard/modules/aggregator/aggregator_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@
PUBLISH_EVENTS_TO_EXTERNAL_HTTP_SERVICE = ray_constants.env_bool(
f"{env_var_prefix}_PUBLISH_EVENTS_TO_EXTERNAL_HTTP_SERVICE", True
)
# flag to control whether preserve the proto field name when converting the events to
# JSON. If True, the proto field name will be preserved. If False, the proto field name
# will be converted to camel case.
PRESERVE_PROTO_FIELD_NAME = ray_constants.env_bool(
f"{env_var_prefix}_PRESERVE_PROTO_FIELD_NAME", False
)


class AggregatorAgent(
Expand Down Expand Up @@ -124,6 +130,7 @@ def __init__(self, dashboard_agent) -> None:
endpoint=self._events_export_addr,
executor=self._executor,
events_filter_fn=self._can_expose_event,
preserve_proto_field_name=PRESERVE_PROTO_FIELD_NAME,
),
event_buffer=self._event_buffer,
common_metric_tags=self._common_tags,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,14 @@ def __init__(
executor: ThreadPoolExecutor,
events_filter_fn: Callable[[object], bool],
timeout: float = PUBLISHER_TIMEOUT_SECONDS,
preserve_proto_field_name: bool = False,
) -> None:
self._endpoint = endpoint
self._executor = executor
self._events_filter_fn = events_filter_fn
self._timeout = aiohttp.ClientTimeout(total=timeout)
self._session = None
self._preserve_proto_field_name = preserve_proto_field_name

async def publish(self, batch: PublishBatch) -> PublishStats:
events_batch: list[events_base_event_pb2.RayEvent] = batch.events
Expand All @@ -89,7 +91,11 @@ async def publish(self, batch: PublishBatch) -> PublishStats:
self._executor,
lambda: [
json.loads(
message_to_json(e, always_print_fields_with_no_presence=True)
message_to_json(
e,
always_print_fields_with_no_presence=True,
preserving_proto_field_name=self._preserve_proto_field_name,
)
)
for e in filtered
],
Expand Down
Loading