Skip to content

Commit

Permalink
[mlobs] improve docs for user session tracking (#25955)
Browse files Browse the repository at this point in the history
Co-authored-by:  <[email protected]>
  • Loading branch information
lievan authored and theraffoul committed Nov 25, 2024
1 parent be6d1e8 commit a4e2357
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions content/en/llm_observability/setup/sdk/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit a4e2357

Please sign in to comment.