Source File
key.go
Belonging Package
go.opentelemetry.io/otel/attribute
// Copyright The OpenTelemetry Authors// SPDX-License-Identifier: Apache-2.0package attribute// Key represents the key part in key-value pairs. It's a string. The// allowed character set in the key depends on the use of the key.type Key string// Bool returns a [KeyValue] for a bool value.//// If creating both a key and value at the same time, use the package-level// [Bool] function.func ( Key) ( bool) KeyValue {return KeyValue{Key: ,Value: BoolValue(),}}// 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.//// If creating both a key and value at the same time, use the package-level// [BoolSlice] function.func ( Key) ( []bool) KeyValue {return KeyValue{Key: ,Value: BoolSliceValue(),}}// Int returns a [KeyValue] for an int value.//// It is provided as a convenience for [Key.Int64].//// If creating both a key and value at the same time, use the package-level [Int]// function.func ( Key) ( int) KeyValue {return KeyValue{Key: ,Value: IntValue(),}}// IntSlice returns a [KeyValue] for a []int value.//// It is provided as a convenience for [Key.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.//// If creating both a key and value at the same time, use the package-level// [IntSlice] function.func ( Key) ( []int) KeyValue {return KeyValue{Key: ,Value: IntSliceValue(),}}// Int64 returns a [KeyValue] for an int64 value.//// If creating both a key and value at the same time, use the package-level// [Int64] function.func ( Key) ( int64) KeyValue {return KeyValue{Key: ,Value: Int64Value(),}}// 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.//// If creating both a key and value at the same time, use the package-level// [Int64Slice] function.func ( Key) ( []int64) KeyValue {return KeyValue{Key: ,Value: Int64SliceValue(),}}// Float64 returns a [KeyValue] for a float64 value.//// If creating both a key and value at the same time, use the package-level// [Float64] function.func ( Key) ( float64) KeyValue {return KeyValue{Key: ,Value: Float64Value(),}}// 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.//// If creating both a key and value at the same time, use the package-level// [Float64Slice] function.func ( Key) ( []float64) KeyValue {return KeyValue{Key: ,Value: Float64SliceValue(),}}// String returns a [KeyValue] for a string value.//// If creating both a key and value at the same time, use the package-level// [String] function.func ( Key) ( string) KeyValue {return KeyValue{Key: ,Value: StringValue(),}}// 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.//// If creating both a key and value at the same time, use the package-level// [StringSlice] function.func ( Key) ( []string) KeyValue {return KeyValue{Key: ,Value: StringSliceValue(),}}// 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.//// If creating both a key and value at the same time, use the package-level// [ByteSlice] function.func ( Key) ( []byte) KeyValue {return KeyValue{Key: ,Value: ByteSliceValue(),}}// 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.//// If creating both a key and value at the same time, use the package-level// [Slice] function.func ( Key) ( ...Value) KeyValue {return KeyValue{Key: ,Value: SliceValue(...),}}// 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.//// If creating both a key and value at the same time, use the package-level [Map]// function.func ( Key) ( ...KeyValue) KeyValue {return KeyValue{Key: ,Value: MapValue(...),}}// Defined reports whether the key is not empty.func ( Key) () bool {return len() != 0}
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |