-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mlobs] improve docs for user session tracking (#25955)
Co-authored-by: <[email protected]>
- Loading branch information
1 parent
be6d1e8
commit a4e2357
Showing
1 changed file
with
15 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -356,17 +356,29 @@ def get_relevant_docs(question): | |
|
||
## Tracking user sessions | ||
|
||
Session tracking allows you to associate multiple interactions with a given user. When starting a root span for a new trace or span in a new process, specify the `session_id` argument with the string ID of the underlying user session: | ||
Session tracking allows you to associate multiple interactions with a given user. When starting a root span for a new trace or span in a new process, specify the `session_id` argument with the string ID of the underlying user session, which is submitted as a tag on the span. Optionally, you can also specify the `user_handle`, `user_name`, and `user_id` tags. | ||
|
||
{{< code-block lang="python" >}} | ||
from ddtrace.llmobs.decorators import workflow | ||
|
||
@workflow(session_id="<SESSION_ID>") | ||
def process_message(): | ||
... # user application logic | ||
def process_user_message(): | ||
LLMObs.annotate( | ||
... | ||
tags = {"user_handle": "[email protected]", "user_id": "1234", "user_name": "poodle"} | ||
) | ||
return | ||
{{< /code-block >}} | ||
|
||
### Session Tracking Tags | ||
|
||
| Tag | Description | | ||
|---|---| | ||
| `session_id` | The ID representing a single user session, for example, a chat session. | | ||
| `user_handle` | The handle for the user of the chat session. | | ||
| `user_name` | The name for the user of the chat session. | | ||
| `user_id` | The ID for the user of the chat session. | | ||
|
||
## Annotating a span | ||
|
||
The SDK provides the method `LLMObs.annotate()` to annotate spans with inputs, outputs, and metadata. | ||
|