genaiconv

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2026 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package genaiconv exposes free-function constructors for OpenTelemetry GenAI span attributes.

Upstream go.opentelemetry.io/otel/semconv/v1.40.0/genaiconv packages its attributes as methods on instrument structs (metric-scoped), which does not help span-level instrumentation. This package fills that gap with thin wrappers over upstream's typed enums. For metrics, use upstream directly via `genaiconv.NewClientOperationDuration(meter)` etc.

The upstream semconv version is exposed via UpstreamSemconvVersion so consumers can pin both this module and upstream in lock-step.

Index

Constants

View Source
const UpstreamSemconvVersion = "v1.40.0"

UpstreamSemconvVersion is the upstream semconv version this package's attribute keys and typed-enum lifts target.

Variables

View Source
var (
	OperationNameKey   = attribute.Key("gen_ai.operation.name")
	ProviderNameKey    = attribute.Key("gen_ai.provider.name")
	ConversationIDKey  = attribute.Key("gen_ai.conversation.id")
	RequestModelKey    = attribute.Key("gen_ai.request.model")
	ResponseModelKey   = attribute.Key("gen_ai.response.model")
	ResponseIDKey      = attribute.Key("gen_ai.response.id")
	OutputTypeKey      = attribute.Key("gen_ai.output.type")
	TokenTypeKey       = attribute.Key("gen_ai.token.type")
	ToolNameKey        = attribute.Key("gen_ai.tool.name")
	ToolCallIDKey      = attribute.Key("gen_ai.tool.call.id")
	ToolDescriptionKey = attribute.Key("gen_ai.tool.description")
	ToolTypeKey        = attribute.Key("gen_ai.tool.type")
	AgentIDKey         = attribute.Key("gen_ai.agent.id")
	AgentNameKey       = attribute.Key("gen_ai.agent.name")
)

Attribute keys.

Functions

func AgentID

func AgentID(v string) attribute.KeyValue

func AgentName

func AgentName(v string) attribute.KeyValue

func ConversationID

func ConversationID(v string) attribute.KeyValue

String-valued attributes (no upstream typed enum).

func OperationName

Typed-enum lifts. These accept upstream's strongly-typed attribute values (genaiconv.OperationNameChat, ProviderNameAnthropic, etc.) and return a span-ready attribute.KeyValue.

func OutputType

func OutputType(v string) attribute.KeyValue

func RequestModel

func RequestModel(v string) attribute.KeyValue

func ResponseID

func ResponseID(v string) attribute.KeyValue

func ResponseModel

func ResponseModel(v string) attribute.KeyValue

func SpanName

func SpanName(op upstream.OperationNameAttr, target string) string

SpanName formats a span name per the GenAI semconv rule: "{gen_ai.operation.name} {target}" when target is non-empty, otherwise just the operation name. target is typically the request model (for chat / generate_content / text_completion / embeddings), the tool name (for execute_tool), or the agent name (for invoke_agent / create_agent).

func ToolCallID

func ToolCallID(v string) attribute.KeyValue

func ToolDescription

func ToolDescription(v string) attribute.KeyValue

func ToolName

func ToolName(v string) attribute.KeyValue

func ToolType

func ToolType(v string) attribute.KeyValue

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL