Skip to content

Commit 639c4c5

Browse files
sampan-s-nayaksampan
andauthored
[core] Add repr_name to actor_lifecycle_event (#59925)
## Description Adds repr_name field to actor_lifecycle_event schema and populates it when available. ## Related issues Closes #59813 ## Additional information > Optional: Add implementation details, API changes, usage examples, screenshots, etc. --------- Signed-off-by: sampan <sampan@anyscale.com> Signed-off-by: Sampan S Nayak <sampansnayak2@gmail.com> Co-authored-by: sampan <sampan@anyscale.com>
1 parent c49b666 commit 639c4c5

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

src/ray/observability/ray_actor_lifecycle_event.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ RayActorLifecycleEvent::RayActorLifecycleEvent(
3131
state_transition.set_state(state);
3232
state_transition.mutable_timestamp()->CopyFrom(AbslTimeNanosToProtoTimestamp(
3333
absl::ToInt64Nanoseconds(absl::Now() - absl::UnixEpoch())));
34+
state_transition.set_repr_name(data.repr_name());
3435

3536
// Set state specific fields
3637
if (state == rpc::events::ActorLifecycleEvent::ALIVE) {

src/ray/observability/tests/ray_actor_lifecycle_event_test.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ TEST_F(RayActorLifecycleEventTest, TestMergeAndSerialize) {
3333

3434
auto event1 = std::make_unique<RayActorLifecycleEvent>(
3535
data, rpc::events::ActorLifecycleEvent::DEPENDENCIES_UNREADY, "sess1");
36+
37+
// repr_name is only available after actor creation.
38+
data.set_repr_name("MyActor(id=123)");
3639
auto event2 = std::make_unique<RayActorLifecycleEvent>(
3740
data, rpc::events::ActorLifecycleEvent::ALIVE, "sess1");
3841

@@ -54,6 +57,8 @@ TEST_F(RayActorLifecycleEventTest, TestMergeAndSerialize) {
5457
rpc::events::ActorLifecycleEvent::ALIVE);
5558
ASSERT_EQ(actor_life.state_transitions(1).node_id(), "node-1");
5659
ASSERT_EQ(actor_life.state_transitions(1).worker_id(), "worker-123");
60+
ASSERT_EQ(actor_life.state_transitions(0).repr_name(), "");
61+
ASSERT_EQ(actor_life.state_transitions(1).repr_name(), "MyActor(id=123)");
5762
}
5863

5964
} // namespace observability

src/ray/protobuf/public/events_actor_lifecycle_event.proto

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ message ActorLifecycleEvent {
4343
// The worker id of the worker on which this actor is running. available when state is ALIVE.
4444
// The worker id can change when the actor is restarted.
4545
bytes worker_id = 4;
46+
// The repr name of the actor if specified with a customized repr method, e.g. __repr__
47+
// This field is only available after the actor creation task has been run since it
48+
// might depend on actor fields to be initialized in __init__.
49+
// Default to empty string if no customized repr is defined.
50+
string repr_name = 5;
4651
// Contains metadata about why the actor is dead. available when state is DEAD.
4752
ActorDeathCause death_cause = 6;
4853
}

0 commit comments

Comments
 (0)