Skip to content

Commit 5897873

Browse files
Emit user.category for Last9 dashboard compatibility
When metadata.category is provided to @observe(), automatically emit it as both metadata.category and user.category attributes. The Last9 dashboard LLM page specifically looks for user.category to populate the Category column and filter dropdown. This allows users to simply use metadata={"category": "support"} and have it work correctly in the Last9 UI without needing to know the platform-specific attribute name. Also ignore send_test_spans.py in .gitignore. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 6a7557b commit 5897873

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,4 @@ dmyp.json
6868
# Claude Code
6969
.claude/
7070
test_telemetry.py
71+
send_test_spans.py

last9_genai/decorators.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ def _observe_sync(
162162
for key, value in metadata.items():
163163
span.set_attribute(f"metadata.{key}", str(value))
164164

165+
# Special handling: emit metadata.category as user.category for Last9 dashboard
166+
if "category" in metadata:
167+
span.set_attribute("user.category", str(metadata["category"]))
168+
165169
# Capture function arguments
166170
if capture_args:
167171
_add_function_arguments(span, func, args, kwargs)
@@ -239,6 +243,10 @@ async def _observe_async(
239243
for key, value in metadata.items():
240244
span.set_attribute(f"metadata.{key}", str(value))
241245

246+
# Special handling: emit metadata.category as user.category for Last9 dashboard
247+
if "category" in metadata:
248+
span.set_attribute("user.category", str(metadata["category"]))
249+
242250
# Capture function arguments
243251
if capture_args:
244252
_add_function_arguments(span, func, args, kwargs)

0 commit comments

Comments
 (0)