AgentObs.Handlers.Phoenix.Translator (agent_obs v0.1.4)

View Source

Translates AgentObs event metadata to OpenInference semantic conventions.

This module is responsible for converting the backend-agnostic AgentObs event metadata into the flattened, indexed attribute format required by OpenInference.

OpenInference is an extension of OpenTelemetry semantic conventions specifically designed for AI and LLM observability. It enables rich, contextualized visualization in platforms like Arize Phoenix.

OpenInference Span Kinds

  • AGENT - Agent loop or orchestration
  • LLM - Large Language Model API call
  • TOOL - Tool or function execution
  • CHAIN - Sequence of operations (e.g., orchestrator iteration)
  • RETRIEVER - Vector/document retrieval (not used in AgentObs currently)

Key Attributes

The translator produces flattened attributes following the OpenInference spec:

  • openinference.span.kind - The span kind (AGENT, LLM, TOOL, etc.)
  • input.value / output.value - Primary input/output
  • llm.model_name - Model identifier
  • llm.input_messages.N.message.role - Message role (user, assistant, etc.)
  • llm.input_messages.N.message.content - Message content
  • llm.token_count.prompt / llm.token_count.completion - Token usage
  • tool.name / tool.description - Tool metadata

References

Summary

Functions

Translates exception event metadata to OpenInference attributes.

Translates start event metadata to OpenInference attributes.

Translates stop event metadata to OpenInference attributes.

Functions

from_exception_metadata(event_type, metadata, measurements)

@spec from_exception_metadata(atom(), map(), map()) :: map()

Translates exception event metadata to OpenInference attributes.

Parameters

  • event_type - One of :agent, :tool, :llm, :chain, :prompt
  • metadata - The exception metadata from telemetry
  • measurements - Measurements map containing duration

Returns

A map of OpenInference attributes for the exception.

from_start_metadata(atom, metadata)

@spec from_start_metadata(atom(), map()) :: map()

Translates start event metadata to OpenInference attributes.

Parameters

  • event_type - One of :agent, :tool, :llm, :chain, :prompt
  • metadata - The start metadata from AgentObs event

Returns

A map of OpenInference attributes (string keys, primitive values).

from_stop_metadata(atom, metadata, measurements)

@spec from_stop_metadata(atom(), map(), map()) :: map()

Translates stop event metadata to OpenInference attributes.

Parameters

  • event_type - One of :agent, :tool, :llm, :chain, :prompt
  • metadata - The stop metadata from AgentObs event
  • measurements - Measurements map containing duration

Returns

A map of OpenInference attributes to be added to the span.