Source File
kv.go
Belonging Package
go.opentelemetry.io/otel/attribute
// Copyright The OpenTelemetry Authors// SPDX-License-Identifier: Apache-2.0package attributeimport ()// KeyValue holds a key and value pair.type KeyValue struct {Key KeyValue Value}// String returns a string representation of KeyValue using the// [OpenTelemetry Attribute representation for non-OTLP protocols] rules.//// The KeyValue is encoded as a JSON object containing a single key-value pair.//// [OpenTelemetry Attribute representation for non-OTLP protocols]: https://opentelemetry.io/docs/specs/otel/common/#attribute-representation-for-non-otlpfunc ( KeyValue) () string {return formatMap([]KeyValue{})}// Valid reports whether kv is a valid OpenTelemetry attribute.func ( KeyValue) () bool {return .Key.Defined()}// Bool returns a [KeyValue] for a bool value.func ( string, bool) KeyValue {return Key().Bool()}// BoolSlice returns a [KeyValue] for a []bool value.//// Note that many observability backends are not optimized to query, index, or// aggregate complex attribute values. Complex values may also carry// additional performance overhead. Prefer primitive values when// possible.func ( string, []bool) KeyValue {return Key().BoolSlice()}// Int returns a [KeyValue] for an int value.//// It is provided as a convenience for [Int64].func ( string, int) KeyValue {return Key().Int()}// IntSlice returns a [KeyValue] for a []int value.//// It is provided as a convenience for [Int64Slice].//// Note that many observability backends are not optimized to query, index, or// aggregate complex attribute values. Complex values may also carry// additional performance overhead. Prefer primitive values when// possible.func ( string, []int) KeyValue {return Key().IntSlice()}// Int64 returns a [KeyValue] for an int64 value.func ( string, int64) KeyValue {return Key().Int64()}// Int64Slice returns a [KeyValue] for a []int64 value.//// Note that many observability backends are not optimized to query, index, or// aggregate complex attribute values. Complex values may also carry// additional performance overhead. Prefer primitive values when// possible.func ( string, []int64) KeyValue {return Key().Int64Slice()}// Float64 returns a [KeyValue] for a float64 value.func ( string, float64) KeyValue {return Key().Float64()}// Float64Slice returns a [KeyValue] for a []float64 value.//// Note that many observability backends are not optimized to query, index, or// aggregate complex attribute values. Complex values may also carry// additional performance overhead. Prefer primitive values when// possible.func ( string, []float64) KeyValue {return Key().Float64Slice()}// String returns a [KeyValue] for a string value.func (, string) KeyValue {return Key().String()}// StringSlice returns a [KeyValue] for a []string value.//// Note that many observability backends are not optimized to query, index, or// aggregate complex attribute values. Complex values may also carry// additional performance overhead. Prefer primitive values when// possible.func ( string, []string) KeyValue {return Key().StringSlice()}// ByteSlice returns a [KeyValue] for a []byte value.//// Note that many observability backends are not optimized to query, index, or// aggregate complex attribute values. Complex values may also carry// additional performance overhead. Prefer primitive values when// possible.func ( string, []byte) KeyValue {return Key().ByteSlice()}// Slice returns a [KeyValue] for a []Value value.//// Note that many observability backends are not optimized to query, index, or// aggregate complex attribute values. Complex values may also carry// additional performance overhead. Prefer primitive values when// possible.func ( string, ...Value) KeyValue {return Key().Slice(...)}// Map returns a [KeyValue] for a []KeyValue value.//// Note that many observability backends are not optimized to query, index, or// aggregate complex attribute values. Complex values may also carry// additional performance overhead. Prefer primitive values when// possible.//// Users should avoid providing duplicate keys; many receivers handle maps// containing duplicate keys unpredictably.//// The order of v is not preserved.func ( string, ...KeyValue) KeyValue {return Key().Map(...)}// Stringer creates a new key-value pair with a passed name and a string// value generated by the passed Stringer interface.func ( string, fmt.Stringer) KeyValue {return Key().String(.String())}
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64)