Copyright The OpenTelemetry Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

package label

import (
	
	
	
)
KeyValue holds a key and value pair.
type KeyValue struct {
	Key   Key
	Value Value
}
Bool creates a new key-value pair with a passed name and a bool value.
func ( string,  bool) KeyValue {
	return Key().Bool()
}
Int64 creates a new key-value pair with a passed name and an int64 value.
func ( string,  int64) KeyValue {
	return Key().Int64()
}
Uint64 creates a new key-value pair with a passed name and a uint64 value.
func ( string,  uint64) KeyValue {
	return Key().Uint64()
}
Float64 creates a new key-value pair with a passed name and a float64 value.
func ( string,  float64) KeyValue {
	return Key().Float64()
}
Int32 creates a new key-value pair with a passed name and an int32 value.
func ( string,  int32) KeyValue {
	return Key().Int32()
}
Uint32 creates a new key-value pair with a passed name and a uint32 value.
func ( string,  uint32) KeyValue {
	return Key().Uint32()
}
Float32 creates a new key-value pair with a passed name and a float32 value.
func ( string,  float32) KeyValue {
	return Key().Float32()
}
String creates a new key-value pair with a passed name and a string value.
func (,  string) KeyValue {
	return Key().String()
}
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())
}
Int creates a new key-value pair instance with a passed name and either an int32 or an int64 value, depending on whether the int type is 32 or 64 bits wide.
func ( string,  int) KeyValue {
	return Key().Int()
}
Uint creates a new key-value pair instance with a passed name and either an uint32 or an uint64 value, depending on whether the uint type is 32 or 64 bits wide.
func ( string,  uint) KeyValue {
	return Key().Uint()
}
Array creates a new key-value pair with a passed name and a array. Only arrays of primitive type are supported.
func ( string,  interface{}) KeyValue {
	return Key().Array()
}
Any creates a new key-value pair instance with a passed name and automatic type inference. This is slower, and not type-safe.
func ( string,  interface{}) KeyValue {
	if  == nil {
		return String(, "<nil>")
	}

	if ,  := .(fmt.Stringer);  {
		return String(, .String())
	}

	 := reflect.ValueOf()

	switch .Kind() {
	case reflect.Array, reflect.Slice:
		return Array(, )
	case reflect.Bool:
		return Bool(, .Bool())
	case reflect.Int, reflect.Int8, reflect.Int16:
		return Int(, int(.Int()))
	case reflect.Int32:
		return Int32(, int32(.Int()))
	case reflect.Int64:
		return Int64(, int64(.Int()))
	case reflect.Uint, reflect.Uint8, reflect.Uint16:
		return Uint(, uint(.Uint()))
	case reflect.Uint32:
		return Uint32(, uint32(.Uint()))
	case reflect.Uint64, reflect.Uintptr:
		return Uint64(, .Uint())
	case reflect.Float32:
		return Float32(, float32(.Float()))
	case reflect.Float64:
		return Float64(, .Float())
	case reflect.String:
		return String(, .String())
	}
	if ,  := json.Marshal();  != nil &&  == nil {
		return String(, string())
	}
	return String(, fmt.Sprint())