From 1ac0c10af41b1c3274608f2e1b4ba7e754097e42 Mon Sep 17 00:00:00 2001 From: lievan <42917263+lievan@users.noreply.github.com> Date: Tue, 29 Oct 2024 11:08:00 -0400 Subject: [PATCH] [mlobs] improve docs for user session tracking (#25955) Co-authored-by: --- .../en/llm_observability/setup/sdk/_index.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/content/en/llm_observability/setup/sdk/_index.md b/content/en/llm_observability/setup/sdk/_index.md index 66d5d1b239819..43f9af5120bb7 100644 --- a/content/en/llm_observability/setup/sdk/_index.md +++ b/content/en/llm_observability/setup/sdk/_index.md @@ -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="") -def process_message(): - ... # user application logic +def process_user_message(): + LLMObs.annotate( + ... + tags = {"user_handle": "poodle@dog.com", "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.