-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Serve] Add actor id and worker id to Serve structured logs #43725
Changes from all commits
aa21e5a
0ab01ce
ad62669
074c511
356d544
59ef04f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -248,6 +248,8 @@ def fn(*args): | |
"app_name": request_context.app_name, | ||
"log_file": logger.handlers[1].baseFilename, | ||
"replica": serve.get_replica_context().replica_tag, | ||
"actor_id": ray.get_runtime_context().get_actor_id(), | ||
"worker_id": ray.get_runtime_context().get_worker_id(), | ||
} | ||
|
||
@serve.deployment( | ||
|
@@ -263,6 +265,8 @@ def __call__(self, req: starlette.requests.Request): | |
"app_name": request_context.app_name, | ||
"log_file": logger.handlers[1].baseFilename, | ||
"replica": serve.get_replica_context().replica_tag, | ||
"actor_id": ray.get_runtime_context().get_actor_id(), | ||
"worker_id": ray.get_runtime_context().get_worker_id(), | ||
} | ||
|
||
serve.run(fn.bind(), name="app1", route_prefix="/fn") | ||
|
@@ -306,21 +310,28 @@ def check_log(): | |
class_method_replica_id = resp2["replica"].split("#")[-1] | ||
if json_log_format: | ||
user_method_log_regex = ( | ||
f'.*"deployment": "{resp["app_name"]}_fn", ' | ||
".*" | ||
f'"actor_id": "{resp["actor_id"]}", ' | ||
f'"worker_id": "{resp["worker_id"]}", ' | ||
f'"deployment": "{resp["app_name"]}_fn", ' | ||
f'"replica": "{method_replica_id}", ' | ||
f'"component_name": "replica", ' | ||
f'"request_id": "{resp["request_id"]}", ' | ||
f'"route": "{resp["route"]}", ' | ||
f'"application": "{resp["app_name"]}", "message":.* user func.*' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are the message fields removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's just reordered to before the request id. This is due to my refactor for drying up the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nope doesn't matter |
||
f'"application": "{resp["app_name"]}", ' | ||
'"message":.* user func.*' | ||
) | ||
user_class_method_log_regex = ( | ||
f'.*"deployment": "{resp2["app_name"]}_Model", ' | ||
".*" | ||
f'"actor_id": "{resp2["actor_id"]}", ' | ||
f'"worker_id": "{resp2["worker_id"]}", ' | ||
f'"deployment": "{resp2["app_name"]}_Model", ' | ||
f'"replica": "{class_method_replica_id}", ' | ||
f'"component_name": "replica", ' | ||
f'"request_id": "{resp2["request_id"]}", ' | ||
f'"route": "{resp2["route"]}", ' | ||
f'"application": "{resp2["app_name"]}", "message":.* user log ' | ||
"message from class method.*" | ||
f'"application": "{resp2["app_name"]}", ' | ||
'"message":.* user log message from class method.*' | ||
) | ||
else: | ||
user_method_log_regex = ( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the attributes added here can be included in the base
record_format
that's generated in the constructorThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would require us to pass more things to the constructor, but I guess it makes more sense there since they won't change between each log messages. Let me update it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These ones are just calling
get_runtime_context()
anywaysThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't you just call it in there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh that's right. Let me just call those in init 😅