package genaiconv
import "go.opentelemetry.io/otel/semconv/v1.32.0/genaiconv"
Package genaiconv provides types and functionality for OpenTelemetry semantic conventions in the "gen_ai" namespace.
Index ¶
- type ClientOperationDuration
- func NewClientOperationDuration( m metric.Meter, opt ...metric.Float64HistogramOption, ) (ClientOperationDuration, error)
- func (ClientOperationDuration) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue
- func (ClientOperationDuration) AttrRequestModel(val string) attribute.KeyValue
- func (ClientOperationDuration) AttrResponseModel(val string) attribute.KeyValue
- func (ClientOperationDuration) AttrServerAddress(val string) attribute.KeyValue
- func (ClientOperationDuration) AttrServerPort(val int) attribute.KeyValue
- func (ClientOperationDuration) Description() string
- func (m ClientOperationDuration) Inst() metric.Float64Histogram
- func (ClientOperationDuration) Name() string
- func (m ClientOperationDuration) Record( ctx context.Context, val float64, operationName OperationNameAttr, system SystemAttr, attrs ...attribute.KeyValue, )
- func (ClientOperationDuration) Unit() string
- type ClientTokenUsage
- func NewClientTokenUsage( m metric.Meter, opt ...metric.Int64HistogramOption, ) (ClientTokenUsage, error)
- func (ClientTokenUsage) AttrRequestModel(val string) attribute.KeyValue
- func (ClientTokenUsage) AttrResponseModel(val string) attribute.KeyValue
- func (ClientTokenUsage) AttrServerAddress(val string) attribute.KeyValue
- func (ClientTokenUsage) AttrServerPort(val int) attribute.KeyValue
- func (ClientTokenUsage) Description() string
- func (m ClientTokenUsage) Inst() metric.Int64Histogram
- func (ClientTokenUsage) Name() string
- func (m ClientTokenUsage) Record( ctx context.Context, val int64, operationName OperationNameAttr, system SystemAttr, tokenType TokenTypeAttr, attrs ...attribute.KeyValue, )
- func (ClientTokenUsage) Unit() string
- type ErrorTypeAttr
- type OperationNameAttr
- type ServerRequestDuration
- func NewServerRequestDuration( m metric.Meter, opt ...metric.Float64HistogramOption, ) (ServerRequestDuration, error)
- func (ServerRequestDuration) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue
- func (ServerRequestDuration) AttrRequestModel(val string) attribute.KeyValue
- func (ServerRequestDuration) AttrResponseModel(val string) attribute.KeyValue
- func (ServerRequestDuration) AttrServerAddress(val string) attribute.KeyValue
- func (ServerRequestDuration) AttrServerPort(val int) attribute.KeyValue
- func (ServerRequestDuration) Description() string
- func (m ServerRequestDuration) Inst() metric.Float64Histogram
- func (ServerRequestDuration) Name() string
- func (m ServerRequestDuration) Record( ctx context.Context, val float64, operationName OperationNameAttr, system SystemAttr, attrs ...attribute.KeyValue, )
- func (ServerRequestDuration) Unit() string
- type ServerTimePerOutputToken
- func NewServerTimePerOutputToken( m metric.Meter, opt ...metric.Float64HistogramOption, ) (ServerTimePerOutputToken, error)
- func (ServerTimePerOutputToken) AttrRequestModel(val string) attribute.KeyValue
- func (ServerTimePerOutputToken) AttrResponseModel(val string) attribute.KeyValue
- func (ServerTimePerOutputToken) AttrServerAddress(val string) attribute.KeyValue
- func (ServerTimePerOutputToken) AttrServerPort(val int) attribute.KeyValue
- func (ServerTimePerOutputToken) Description() string
- func (m ServerTimePerOutputToken) Inst() metric.Float64Histogram
- func (ServerTimePerOutputToken) Name() string
- func (m ServerTimePerOutputToken) Record( ctx context.Context, val float64, operationName OperationNameAttr, system SystemAttr, attrs ...attribute.KeyValue, )
- func (ServerTimePerOutputToken) Unit() string
- type ServerTimeToFirstToken
- func NewServerTimeToFirstToken( m metric.Meter, opt ...metric.Float64HistogramOption, ) (ServerTimeToFirstToken, error)
- func (ServerTimeToFirstToken) AttrRequestModel(val string) attribute.KeyValue
- func (ServerTimeToFirstToken) AttrResponseModel(val string) attribute.KeyValue
- func (ServerTimeToFirstToken) AttrServerAddress(val string) attribute.KeyValue
- func (ServerTimeToFirstToken) AttrServerPort(val int) attribute.KeyValue
- func (ServerTimeToFirstToken) Description() string
- func (m ServerTimeToFirstToken) Inst() metric.Float64Histogram
- func (ServerTimeToFirstToken) Name() string
- func (m ServerTimeToFirstToken) Record( ctx context.Context, val float64, operationName OperationNameAttr, system SystemAttr, attrs ...attribute.KeyValue, )
- func (ServerTimeToFirstToken) Unit() string
- type SystemAttr
- type TokenTypeAttr
Types ¶
type ClientOperationDuration ¶
type ClientOperationDuration struct {
metric.Float64Histogram
}
ClientOperationDuration is an instrument used to record metric values conforming to the "gen_ai.client.operation.duration" semantic conventions. It represents the genAI operation duration.
func NewClientOperationDuration ¶
func NewClientOperationDuration( m metric.Meter, opt ...metric.Float64HistogramOption, ) (ClientOperationDuration, error)
NewClientOperationDuration returns a new ClientOperationDuration instrument.
func (ClientOperationDuration) AttrErrorType ¶
func (ClientOperationDuration) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue
AttrErrorType returns an optional attribute for the "error.type" semantic convention. It represents the describes a class of error the operation ended with.
func (ClientOperationDuration) AttrRequestModel ¶
func (ClientOperationDuration) AttrRequestModel(val string) attribute.KeyValue
AttrRequestModel returns an optional attribute for the "gen_ai.request.model" semantic convention. It represents the name of the GenAI model a request is being made to.
func (ClientOperationDuration) AttrResponseModel ¶
func (ClientOperationDuration) AttrResponseModel(val string) attribute.KeyValue
AttrResponseModel returns an optional attribute for the "gen_ai.response.model" semantic convention. It represents the name of the model that generated the response.
func (ClientOperationDuration) AttrServerAddress ¶
func (ClientOperationDuration) AttrServerAddress(val string) attribute.KeyValue
AttrServerAddress returns an optional attribute for the "server.address" semantic convention. It represents the genAI server address.
func (ClientOperationDuration) AttrServerPort ¶
func (ClientOperationDuration) AttrServerPort(val int) attribute.KeyValue
AttrServerPort returns an optional attribute for the "server.port" semantic convention. It represents the genAI server port.
func (ClientOperationDuration) Description ¶
func (ClientOperationDuration) Description() string
Description returns the semantic convention description of the instrument
func (ClientOperationDuration) Inst ¶
func (m ClientOperationDuration) Inst() metric.Float64Histogram
Inst returns the underlying metric instrument.
func (ClientOperationDuration) Name ¶
func (ClientOperationDuration) Name() string
Name returns the semantic convention name of the instrument.
func (ClientOperationDuration) Record ¶
func (m ClientOperationDuration) Record( ctx context.Context, val float64, operationName OperationNameAttr, system SystemAttr, attrs ...attribute.KeyValue, )
Record records val to the current distribution.
The operationName is the the name of the operation being performed.
The system is the the Generative AI product as identified by the client or server instrumentation.
All additional attrs passed are included in the recorded value.
func (ClientOperationDuration) Unit ¶
func (ClientOperationDuration) Unit() string
Unit returns the semantic convention unit of the instrument
type ClientTokenUsage ¶
type ClientTokenUsage struct {
metric.Int64Histogram
}
ClientTokenUsage is an instrument used to record metric values conforming to the "gen_ai.client.token.usage" semantic conventions. It represents the measures number of input and output tokens used.
func NewClientTokenUsage ¶
func NewClientTokenUsage( m metric.Meter, opt ...metric.Int64HistogramOption, ) (ClientTokenUsage, error)
NewClientTokenUsage returns a new ClientTokenUsage instrument.
func (ClientTokenUsage) AttrRequestModel ¶
func (ClientTokenUsage) AttrRequestModel(val string) attribute.KeyValue
AttrRequestModel returns an optional attribute for the "gen_ai.request.model" semantic convention. It represents the name of the GenAI model a request is being made to.
func (ClientTokenUsage) AttrResponseModel ¶
func (ClientTokenUsage) AttrResponseModel(val string) attribute.KeyValue
AttrResponseModel returns an optional attribute for the "gen_ai.response.model" semantic convention. It represents the name of the model that generated the response.
func (ClientTokenUsage) AttrServerAddress ¶
func (ClientTokenUsage) AttrServerAddress(val string) attribute.KeyValue
AttrServerAddress returns an optional attribute for the "server.address" semantic convention. It represents the genAI server address.
func (ClientTokenUsage) AttrServerPort ¶
func (ClientTokenUsage) AttrServerPort(val int) attribute.KeyValue
AttrServerPort returns an optional attribute for the "server.port" semantic convention. It represents the genAI server port.
func (ClientTokenUsage) Description ¶
func (ClientTokenUsage) Description() string
Description returns the semantic convention description of the instrument
func (ClientTokenUsage) Inst ¶
func (m ClientTokenUsage) Inst() metric.Int64Histogram
Inst returns the underlying metric instrument.
func (ClientTokenUsage) Name ¶
func (ClientTokenUsage) Name() string
Name returns the semantic convention name of the instrument.
func (ClientTokenUsage) Record ¶
func (m ClientTokenUsage) Record( ctx context.Context, val int64, operationName OperationNameAttr, system SystemAttr, tokenType TokenTypeAttr, attrs ...attribute.KeyValue, )
Record records val to the current distribution.
The operationName is the the name of the operation being performed.
The system is the the Generative AI product as identified by the client or server instrumentation.
The tokenType is the the type of token being counted.
All additional attrs passed are included in the recorded value.
func (ClientTokenUsage) Unit ¶
func (ClientTokenUsage) Unit() string
Unit returns the semantic convention unit of the instrument
type ErrorTypeAttr ¶
type ErrorTypeAttr string
ErrorTypeAttr is an attribute conforming to the error.type semantic conventions. It represents the describes a class of error the operation ended with.
var ( // ErrorTypeOther is a fallback error value to be used when the instrumentation // doesn't define a custom value. ErrorTypeOther ErrorTypeAttr = "_OTHER" )
type OperationNameAttr ¶
type OperationNameAttr string
OperationNameAttr is an attribute conforming to the gen_ai.operation.name semantic conventions. It represents the name of the operation being performed.
var ( // OperationNameChat is the chat completion operation such as [OpenAI Chat API] // . // // [OpenAI Chat API]: https://platform.openai.com/docs/api-reference/chat OperationNameChat OperationNameAttr = "chat" // OperationNameTextCompletion is the text completions operation such as // [OpenAI Completions API (Legacy)]. // // [OpenAI Completions API (Legacy)]: https://platform.openai.com/docs/api-reference/completions OperationNameTextCompletion OperationNameAttr = "text_completion" // OperationNameEmbeddings is the embeddings operation such as // [OpenAI Create embeddings API]. // // [OpenAI Create embeddings API]: https://platform.openai.com/docs/api-reference/embeddings/create OperationNameEmbeddings OperationNameAttr = "embeddings" // OperationNameCreateAgent is the create GenAI agent. OperationNameCreateAgent OperationNameAttr = "create_agent" // OperationNameExecuteTool is the execute a tool. OperationNameExecuteTool OperationNameAttr = "execute_tool" )
type ServerRequestDuration ¶
type ServerRequestDuration struct {
metric.Float64Histogram
}
ServerRequestDuration is an instrument used to record metric values conforming to the "gen_ai.server.request.duration" semantic conventions. It represents the generative AI server request duration such as time-to-last byte or last output token.
func NewServerRequestDuration ¶
func NewServerRequestDuration( m metric.Meter, opt ...metric.Float64HistogramOption, ) (ServerRequestDuration, error)
NewServerRequestDuration returns a new ServerRequestDuration instrument.
func (ServerRequestDuration) AttrErrorType ¶
func (ServerRequestDuration) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue
AttrErrorType returns an optional attribute for the "error.type" semantic convention. It represents the describes a class of error the operation ended with.
func (ServerRequestDuration) AttrRequestModel ¶
func (ServerRequestDuration) AttrRequestModel(val string) attribute.KeyValue
AttrRequestModel returns an optional attribute for the "gen_ai.request.model" semantic convention. It represents the name of the GenAI model a request is being made to.
func (ServerRequestDuration) AttrResponseModel ¶
func (ServerRequestDuration) AttrResponseModel(val string) attribute.KeyValue
AttrResponseModel returns an optional attribute for the "gen_ai.response.model" semantic convention. It represents the name of the model that generated the response.
func (ServerRequestDuration) AttrServerAddress ¶
func (ServerRequestDuration) AttrServerAddress(val string) attribute.KeyValue
AttrServerAddress returns an optional attribute for the "server.address" semantic convention. It represents the genAI server address.
func (ServerRequestDuration) AttrServerPort ¶
func (ServerRequestDuration) AttrServerPort(val int) attribute.KeyValue
AttrServerPort returns an optional attribute for the "server.port" semantic convention. It represents the genAI server port.
func (ServerRequestDuration) Description ¶
func (ServerRequestDuration) Description() string
Description returns the semantic convention description of the instrument
func (ServerRequestDuration) Inst ¶
func (m ServerRequestDuration) Inst() metric.Float64Histogram
Inst returns the underlying metric instrument.
func (ServerRequestDuration) Name ¶
func (ServerRequestDuration) Name() string
Name returns the semantic convention name of the instrument.
func (ServerRequestDuration) Record ¶
func (m ServerRequestDuration) Record( ctx context.Context, val float64, operationName OperationNameAttr, system SystemAttr, attrs ...attribute.KeyValue, )
Record records val to the current distribution.
The operationName is the the name of the operation being performed.
The system is the the Generative AI product as identified by the client or server instrumentation.
All additional attrs passed are included in the recorded value.
func (ServerRequestDuration) Unit ¶
func (ServerRequestDuration) Unit() string
Unit returns the semantic convention unit of the instrument
type ServerTimePerOutputToken ¶
type ServerTimePerOutputToken struct {
metric.Float64Histogram
}
ServerTimePerOutputToken is an instrument used to record metric values conforming to the "gen_ai.server.time_per_output_token" semantic conventions. It represents the time per output token generated after the first token for successful responses.
func NewServerTimePerOutputToken ¶
func NewServerTimePerOutputToken( m metric.Meter, opt ...metric.Float64HistogramOption, ) (ServerTimePerOutputToken, error)
NewServerTimePerOutputToken returns a new ServerTimePerOutputToken instrument.
func (ServerTimePerOutputToken) AttrRequestModel ¶
func (ServerTimePerOutputToken) AttrRequestModel(val string) attribute.KeyValue
AttrRequestModel returns an optional attribute for the "gen_ai.request.model" semantic convention. It represents the name of the GenAI model a request is being made to.
func (ServerTimePerOutputToken) AttrResponseModel ¶
func (ServerTimePerOutputToken) AttrResponseModel(val string) attribute.KeyValue
AttrResponseModel returns an optional attribute for the "gen_ai.response.model" semantic convention. It represents the name of the model that generated the response.
func (ServerTimePerOutputToken) AttrServerAddress ¶
func (ServerTimePerOutputToken) AttrServerAddress(val string) attribute.KeyValue
AttrServerAddress returns an optional attribute for the "server.address" semantic convention. It represents the genAI server address.
func (ServerTimePerOutputToken) AttrServerPort ¶
func (ServerTimePerOutputToken) AttrServerPort(val int) attribute.KeyValue
AttrServerPort returns an optional attribute for the "server.port" semantic convention. It represents the genAI server port.
func (ServerTimePerOutputToken) Description ¶
func (ServerTimePerOutputToken) Description() string
Description returns the semantic convention description of the instrument
func (ServerTimePerOutputToken) Inst ¶
func (m ServerTimePerOutputToken) Inst() metric.Float64Histogram
Inst returns the underlying metric instrument.
func (ServerTimePerOutputToken) Name ¶
func (ServerTimePerOutputToken) Name() string
Name returns the semantic convention name of the instrument.
func (ServerTimePerOutputToken) Record ¶
func (m ServerTimePerOutputToken) Record( ctx context.Context, val float64, operationName OperationNameAttr, system SystemAttr, attrs ...attribute.KeyValue, )
Record records val to the current distribution.
The operationName is the the name of the operation being performed.
The system is the the Generative AI product as identified by the client or server instrumentation.
All additional attrs passed are included in the recorded value.
func (ServerTimePerOutputToken) Unit ¶
func (ServerTimePerOutputToken) Unit() string
Unit returns the semantic convention unit of the instrument
type ServerTimeToFirstToken ¶
type ServerTimeToFirstToken struct {
metric.Float64Histogram
}
ServerTimeToFirstToken is an instrument used to record metric values conforming to the "gen_ai.server.time_to_first_token" semantic conventions. It represents the time to generate first token for successful responses.
func NewServerTimeToFirstToken ¶
func NewServerTimeToFirstToken( m metric.Meter, opt ...metric.Float64HistogramOption, ) (ServerTimeToFirstToken, error)
NewServerTimeToFirstToken returns a new ServerTimeToFirstToken instrument.
func (ServerTimeToFirstToken) AttrRequestModel ¶
func (ServerTimeToFirstToken) AttrRequestModel(val string) attribute.KeyValue
AttrRequestModel returns an optional attribute for the "gen_ai.request.model" semantic convention. It represents the name of the GenAI model a request is being made to.
func (ServerTimeToFirstToken) AttrResponseModel ¶
func (ServerTimeToFirstToken) AttrResponseModel(val string) attribute.KeyValue
AttrResponseModel returns an optional attribute for the "gen_ai.response.model" semantic convention. It represents the name of the model that generated the response.
func (ServerTimeToFirstToken) AttrServerAddress ¶
func (ServerTimeToFirstToken) AttrServerAddress(val string) attribute.KeyValue
AttrServerAddress returns an optional attribute for the "server.address" semantic convention. It represents the genAI server address.
func (ServerTimeToFirstToken) AttrServerPort ¶
func (ServerTimeToFirstToken) AttrServerPort(val int) attribute.KeyValue
AttrServerPort returns an optional attribute for the "server.port" semantic convention. It represents the genAI server port.
func (ServerTimeToFirstToken) Description ¶
func (ServerTimeToFirstToken) Description() string
Description returns the semantic convention description of the instrument
func (ServerTimeToFirstToken) Inst ¶
func (m ServerTimeToFirstToken) Inst() metric.Float64Histogram
Inst returns the underlying metric instrument.
func (ServerTimeToFirstToken) Name ¶
func (ServerTimeToFirstToken) Name() string
Name returns the semantic convention name of the instrument.
func (ServerTimeToFirstToken) Record ¶
func (m ServerTimeToFirstToken) Record( ctx context.Context, val float64, operationName OperationNameAttr, system SystemAttr, attrs ...attribute.KeyValue, )
Record records val to the current distribution.
The operationName is the the name of the operation being performed.
The system is the the Generative AI product as identified by the client or server instrumentation.
All additional attrs passed are included in the recorded value.
func (ServerTimeToFirstToken) Unit ¶
func (ServerTimeToFirstToken) Unit() string
Unit returns the semantic convention unit of the instrument
type SystemAttr ¶
type SystemAttr string
SystemAttr is an attribute conforming to the gen_ai.system semantic conventions. It represents the Generative AI product as identified by the client or server instrumentation.
var ( // SystemOpenAI is the openAI. SystemOpenAI SystemAttr = "openai" // SystemVertexAI is the vertex AI. SystemVertexAI SystemAttr = "vertex_ai" // SystemGemini is the gemini. SystemGemini SystemAttr = "gemini" // SystemAnthropic is the anthropic. SystemAnthropic SystemAttr = "anthropic" // SystemCohere is the cohere. SystemCohere SystemAttr = "cohere" // SystemAzAIInference is the azure AI Inference. SystemAzAIInference SystemAttr = "az.ai.inference" // SystemAzAIOpenAI is the azure OpenAI. SystemAzAIOpenAI SystemAttr = "az.ai.openai" // SystemIBMWatsonxAI is the IBM Watsonx AI. SystemIBMWatsonxAI SystemAttr = "ibm.watsonx.ai" // SystemAWSBedrock is the AWS Bedrock. SystemAWSBedrock SystemAttr = "aws.bedrock" // SystemPerplexity is the perplexity. SystemPerplexity SystemAttr = "perplexity" // SystemXai is the xAI. SystemXai SystemAttr = "xai" // SystemDeepseek is the deepSeek. SystemDeepseek SystemAttr = "deepseek" // SystemGroq is the groq. SystemGroq SystemAttr = "groq" // SystemMistralAI is the mistral AI. SystemMistralAI SystemAttr = "mistral_ai" )
type TokenTypeAttr ¶
type TokenTypeAttr string
TokenTypeAttr is an attribute conforming to the gen_ai.token.type semantic conventions. It represents the type of token being counted.
var ( // TokenTypeInput is the input tokens (prompt, input, etc.). TokenTypeInput TokenTypeAttr = "input" // TokenTypeOutput is the output tokens (completion, response, etc.). TokenTypeOutput TokenTypeAttr = "output" )
Source Files ¶
metric.go
- Version
- v1.43.0 (latest)
- Published
- Apr 3, 2026
- Platform
- linux/amd64
- Imports
- 5 packages
- Last checked
- 3 hours ago –
Tools for package owners.