.agents/skills/llmobs-integration/SKILL.md
This skill covers creating LLMObs plugins that instrument LLM library operations and emit span events. Supported operations: chat completions (streaming and non-streaming), embeddings, agent runs, orchestration (workflows / graphs), tool calls, retrieval (RAG / vector DB).
All LLMObs plugins extend LLMObsPlugin. Two methods must be implemented:
getLLMObsSpanRegisterOptions(ctx) — returns { modelProvider, modelName, kind, name }.setLLMObsTags(ctx) — extracts and tags input / output messages, token metrics, and model metadata.Lifecycle: start(ctx) registers the span and captures context; the wrapped operation runs; asyncEnd(ctx) calls setLLMObsTags(); end(ctx) restores the parent.
See references/plugin-architecture.md for the full implementation surface.
CRITICAL: Every integration must be classified into one category using the LlmObsCategory enum. This determines test strategy and implementation approach.
LlmObsCategory.LLM_CLIENT - Direct API wrappers (openai, anthropic, genai)
LlmObsCategory.MULTI_PROVIDER - Multi-provider frameworks (ai-sdk, langchain)
LlmObsCategory.ORCHESTRATION - Workflow managers (langgraph)
LlmObsCategory.INFRASTRUCTURE - Protocols/servers (MCP)
Answer these questions by reading the code:
Does the package make direct HTTP calls to LLM provider endpoints?
Does it support multiple LLM providers via configuration?
LlmObsCategory.MULTI_PROVIDERLlmObsCategory.LLM_CLIENTDoes it implement workflow/graph orchestration with state management?
LlmObsCategory.ORCHESTRATIONLlmObsCategory.INFRASTRUCTURESee references/category-detection.md for detailed heuristics and examples.
Use the LlmObsSpanKind enum:
LlmObsSpanKind.LLM - Chat completions, text generationLlmObsSpanKind.WORKFLOW - Graph/chain executionLlmObsSpanKind.AGENT - Agent runsLlmObsSpanKind.TOOL - Tool/function callsLlmObsSpanKind.EMBEDDING - Embedding generationLlmObsSpanKind.RETRIEVAL - Vector DB/RAG retrievalMost common: Use 'llm' for chat completions/text generation in LLM_CLIENT and MULTI_PROVIDER categories.
All plugins must convert provider-specific message formats to the standard format:
Standard format: [{content: string, role: string}]
Common roles: 'user', 'assistant', 'system', 'tool'
Provider-specific handling:
function_call and tool_callsrole values, flatten nested content arraysparts arrays, map role namesSee references/message-extraction.md for provider-specific patterns.
Detect package category (REQUIRED FIRST STEP)
Create plugin file
packages/dd-trace/src/llmobs/plugins/{integration}/index.jsLLMObsPlugin base classImplement getLLMObsSpanRegisterOptions(ctx)
'llm')Implement setLLMObsTags(ctx)
ctx.argumentsctx.resultthis._tagger methodsHandle edge cases
See references/plugin-architecture.md for step-by-step implementation guide.
All plugins must export an array:
Static properties required:
integration - Integration name (e.g., 'openai')id - Unique plugin ID (e.g., 'llmobs_openai')prefix - Channel prefix (e.g., 'tracing:apm:openai:chat')For detailed information, see: