Source File
kv.go
Belonging Package
go.opentelemetry.io/otel/attribute
// 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 attribute // import "go.opentelemetry.io/otel/attribute"
import (
)
// KeyValue holds a key and value pair.
type KeyValue struct {
Key Key
Value Value
}
// Valid returns if kv is a valid OpenTelemetry attribute.
func ( KeyValue) () bool {
return .Key.Defined() && .Value.Type() != INVALID
}
// Bool creates a KeyValue with a BOOL Value type.
func ( string, bool) KeyValue {
return Key().Bool()
}
// BoolSlice creates a KeyValue with a BOOLSLICE Value type.
func ( string, []bool) KeyValue {
return Key().BoolSlice()
}
// Int creates a KeyValue with an INT64 Value type.
func ( string, int) KeyValue {
return Key().Int()
}
// IntSlice creates a KeyValue with an INT64SLICE Value type.
func ( string, []int) KeyValue {
return Key().IntSlice()
}
// Int64 creates a KeyValue with an INT64 Value type.
func ( string, int64) KeyValue {
return Key().Int64()
}
// Int64Slice creates a KeyValue with an INT64SLICE Value type.
func ( string, []int64) KeyValue {
return Key().Int64Slice()
}
// Float64 creates a KeyValue with a FLOAT64 Value type.
func ( string, float64) KeyValue {
return Key().Float64()
}
// Float64Slice creates a KeyValue with a FLOAT64SLICE Value type.
func ( string, []float64) KeyValue {
return Key().Float64Slice()
}
// String creates a KeyValue with a STRING Value type.
func (, string) KeyValue {
return Key().String()
}
// StringSlice creates a KeyValue with a STRINGSLICE Value type.
func ( string, []string) KeyValue {
return Key().StringSlice()
}
// 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.6.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 @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |