-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Add user_id and session_id in traces to track users and sessions #523
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
base: main
Are you sure you want to change the base?
feat: Add user_id and session_id in traces to track users and sessions #523
Conversation
@@ -0,0 +1,44 @@ | |||
"""OpenLayer tracing module.""" |
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.
Currently, we don't use this file.
We expose all features in the tracing
module in lib/__init__.py
(e.g., here.) This way, the user only needs to import from lib
. E.g.,
from openlayer.lib import trace # as opposed to from openlayer.lib.tracing.tracer import trace
In my opinion, we should maintain the pattern we're currently following. In that case, you should move the imports to https://github.com/openlayer-ai/openlayer-python/blob/main/src/openlayer/lib/__init__.py, to expose them there.
Open to hear your perspective as well.
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.
makes sense. updated.
src/openlayer/lib/tracing/context.py
Outdated
@@ -0,0 +1,167 @@ | |||
""" | |||
Streamlined user and session context management for OpenLayer tracing. |
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.
super nit: in this and other places, you have the "L" capitalized. We go by "Openlayer"
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.
haha. updated.
@@ -89,6 +89,12 @@ class ConfigLlmData(TypedDict, total=False): | |||
used. | |||
""" | |||
|
|||
user_id_column_name: Annotated[str, PropertyInfo(alias="userIdColumnName")] |
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.
This file is auto-generated by Stainless and we shouldn't modify it directly. I'm going to comment in your Linear how to regenerate this file.
For this (and our other SDKs generated by Stainless), we should only edit files inside /lib
and /examples
. The rest is fully autogenerated from our OpenAPI spec.
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.
got it.
6499738
to
03ed5a2
Compare
Pull Request
Summary
Add user and session context tracking to OpenLayer tracing functionality. This enhancement enables developers to associate traces with specific users and sessions, providing better observability and analytics for multi-user applications.
Changes
src/openlayer/lib/tracing/context.py
with user/session context functionsset_user_session_context()
- Set default user/session IDs (typically in middleware)update_trace_user_session()
- Override user/session IDs for specific tracesget_current_user_id()
/get_current_session_id()
- Retrieve current contextclear_user_session_context()
- Clear all contextuser_id
andsession_id
in trace datauser_id_column_name
andsession_id_column_name
in data stream configurationContext
This addresses the need to track user sessions and individual users within OpenLayer traces.