Skip to content

Conversation

@shuningc
Copy link
Contributor

@shuningc shuningc commented Nov 18, 2025

Core Implementation:

_handle_llm_start(): Captures model name, input messages, creates LLMInvocation entity
_handle_llm_end(): Extracts response content, token usage, finalizes span
Handles LlamaIndex-specific message formats (ChatMessage objects, blocks[0].text structure)
Supports both dict and object response types
Token extraction from response.raw.usage (OpenAI format)
Testing:

test_llm_instrumentation.py: Live OpenAI API integration test
Validates span attributes, message content, token counts
Verifies metrics emission
Documentation:

Quick start guide with code example
Expected span attributes and metrics output
Key differences vs LangChain (event-based callbacks, CBEventType enum)
Span Attributes (Gen AI Semantic Conventions)
Metrics:

gen_ai.client.operation.duration (histogram)
gen_ai.client.token.usage (counter)

@shuningc shuningc requested review from a team as code owners November 18, 2025 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant