Get actor name inside the actor

  • Medium: It contributes to significant difficulty to complete my task, but I can work around it.

Inside the actor functions I need to access the actor name for my own logging purposes.
It is not part of the runtime context or any other api that I can see.
I could pass it as an argument to the actor function but it doesn’t seem like the correct solution
Is there a way I can just access it inside the actor?

Hey @shiranbi , would the python class name be enough for your case? E.g. self.__class__.__name__ ?

Hi @rickyyx
No, since I create multiple instances of the same class as different instances of the actors,
I give each one a unique name,
I thought about using actor id but it doesn’t tell me which instance it was, just makes it unique.

Hey @shiranbi I see. In that case, I think having a name attribute for each instance as you suggested is probably the best way. I agree there could be a more “rayish” way, e.g., by injecting the supplied “name” option into the class instance itself.