attribute

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 9, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package attribute provides key and value attributes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolToRaw

func BoolToRaw(b bool) uint64

func Float64ToRaw

func Float64ToRaw(f float64) uint64

func Int64ToRaw

func Int64ToRaw(i int64) uint64

func RawPtrToFloat64Ptr

func RawPtrToFloat64Ptr(r *uint64) *float64

func RawPtrToInt64Ptr

func RawPtrToInt64Ptr(r *uint64) *int64

func RawToBool

func RawToBool(r uint64) bool

func RawToFloat64

func RawToFloat64(r uint64) float64

func RawToInt64

func RawToInt64(r uint64) int64

Types

type Key

type Key string

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.

func (Key) Bool

func (k Key) Bool(v bool) KeyValue

Bool creates a KeyValue instance with a BOOL Value.

If creating both a key and value at the same time, use the provided convenience function instead -- Bool(name, value).

func (Key) BoolSlice

func (k Key) BoolSlice(v []bool) KeyValue

BoolSlice creates a KeyValue instance with a BOOLSLICE Value.

If creating both a key and value at the same time, use the provided convenience function instead -- BoolSlice(name, value).

func (Key) Defined

func (k Key) Defined() bool

Defined returns true for non-empty keys.

func (Key) Float64

func (k Key) Float64(v float64) KeyValue

Float64 creates a KeyValue instance with a FLOAT64 Value.

If creating both a key and value at the same time, use the provided convenience function instead -- Float64(name, value).

func (Key) Float64Slice

func (k Key) Float64Slice(v []float64) KeyValue

Float64Slice creates a KeyValue instance with a FLOAT64SLICE Value.

If creating both a key and value at the same time, use the provided convenience function instead -- Float64(name, value).

func (Key) Int

func (k Key) Int(v int) KeyValue

Int creates a KeyValue instance with an INT64 Value.

If creating both a key and value at the same time, use the provided convenience function instead -- Int(name, value).

func (Key) Int64

func (k Key) Int64(v int64) KeyValue

Int64 creates a KeyValue instance with an INT64 Value.

If creating both a key and value at the same time, use the provided convenience function instead -- Int64(name, value).

func (Key) Int64Slice

func (k Key) Int64Slice(v []int64) KeyValue

Int64Slice creates a KeyValue instance with an INT64SLICE Value.

If creating both a key and value at the same time, use the provided convenience function instead -- Int64Slice(name, value).

func (Key) IntSlice

func (k Key) IntSlice(v []int) KeyValue

IntSlice creates a KeyValue instance with an INT64SLICE Value.

If creating both a key and value at the same time, use the provided convenience function instead -- IntSlice(name, value).

func (Key) String

func (k Key) String(v string) KeyValue

String creates a KeyValue instance with a STRING Value.

If creating both a key and value at the same time, use the provided convenience function instead -- String(name, value).

func (Key) StringSlice

func (k Key) StringSlice(v []string) KeyValue

StringSlice creates a KeyValue instance with a STRINGSLICE Value.

If creating both a key and value at the same time, use the provided convenience function instead -- StringSlice(name, value).

type KeyValue

type KeyValue struct {
	Key   Key
	Value Value
}

KeyValue holds a key and value pair.

func Bool

func Bool(k string, v bool) KeyValue

Bool creates a KeyValue with a BOOL Value type.

func BoolSlice

func BoolSlice(k string, v []bool) KeyValue

BoolSlice creates a KeyValue with a BOOLSLICE Value type.

func Float64

func Float64(k string, v float64) KeyValue

Float64 creates a KeyValue with a FLOAT64 Value type.

func Float64Slice

func Float64Slice(k string, v []float64) KeyValue

Float64Slice creates a KeyValue with a FLOAT64SLICE Value type.

func Int

func Int(k string, v int) KeyValue

Int creates a KeyValue with an INT64 Value type.

func Int64

func Int64(k string, v int64) KeyValue

Int64 creates a KeyValue with an INT64 Value type.

func Int64Slice

func Int64Slice(k string, v []int64) KeyValue

Int64Slice creates a KeyValue with an INT64SLICE Value type.

func IntSlice

func IntSlice(k string, v []int) KeyValue

IntSlice creates a KeyValue with an INT64SLICE Value type.

func String

func String(k, v string) KeyValue

String creates a KeyValue with a STRING Value type.

func StringSlice

func StringSlice(k string, v []string) KeyValue

StringSlice creates a KeyValue with a STRINGSLICE Value type.

func Stringer

func Stringer(k string, v fmt.Stringer) KeyValue

Stringer creates a new key-value pair with a passed name and a string value generated by the passed Stringer interface.

func (KeyValue) Valid

func (kv KeyValue) Valid() bool

Valid returns if kv is a valid OpenTelemetry attribute.

type Type

type Type int

Type describes the type of the data Value holds.

const (
	// INVALID is used for a Value with no value set.
	INVALID Type = iota
	// BOOL is a boolean Type Value.
	BOOL
	// INT64 is a 64-bit signed integral Type Value.
	INT64
	// FLOAT64 is a 64-bit floating point Type Value.
	FLOAT64
	// STRING is a string Type Value.
	STRING
	// BOOLSLICE is a slice of booleans Type Value.
	BOOLSLICE
	// INT64SLICE is a slice of 64-bit signed integral numbers Type Value.
	INT64SLICE
	// FLOAT64SLICE is a slice of 64-bit floating point numbers Type Value.
	FLOAT64SLICE
	// STRINGSLICE is a slice of strings Type Value.
	STRINGSLICE
)

func (Type) String

func (i Type) String() string

type Value

type Value struct {
	// contains filtered or unexported fields
}

Value represents the value part in key-value pairs.

func BoolSliceValue

func BoolSliceValue(v []bool) Value

BoolSliceValue creates a BOOLSLICE Value.

func BoolValue

func BoolValue(v bool) Value

BoolValue creates a BOOL Value.

func Float64SliceValue

func Float64SliceValue(v []float64) Value

Float64SliceValue creates a FLOAT64SLICE Value.

func Float64Value

func Float64Value(v float64) Value

Float64Value creates a FLOAT64 Value.

func Int64SliceValue

func Int64SliceValue(v []int64) Value

Int64SliceValue creates an INT64SLICE Value.

func Int64Value

func Int64Value(v int64) Value

Int64Value creates an INT64 Value.

func IntSliceValue

func IntSliceValue(v []int) Value

IntSliceValue creates an INTSLICE Value.

func IntValue

func IntValue(v int) Value

IntValue creates an INT64 Value.

func StringSliceValue

func StringSliceValue(v []string) Value

StringSliceValue creates a STRINGSLICE Value.

func StringValue

func StringValue(v string) Value

StringValue creates a STRING Value.

func (Value) AsBool

func (v Value) AsBool() bool

AsBool returns the bool value. Make sure that the Value's type is BOOL.

func (Value) AsBoolSlice

func (v Value) AsBoolSlice() []bool

AsBoolSlice returns the []bool value. Make sure that the Value's type is BOOLSLICE.

func (Value) AsFloat64

func (v Value) AsFloat64() float64

AsFloat64 returns the float64 value. Make sure that the Value's type is FLOAT64.

func (Value) AsFloat64Slice

func (v Value) AsFloat64Slice() []float64

AsFloat64Slice returns the []float64 value. Make sure that the Value's type is INT64SLICE.

func (Value) AsInt64

func (v Value) AsInt64() int64

AsInt64 returns the int64 value. Make sure that the Value's type is INT64.

func (Value) AsInt64Slice

func (v Value) AsInt64Slice() []int64

AsInt64Slice returns the []int64 value. Make sure that the Value's type is INT64SLICE.

func (Value) AsInterface

func (v Value) AsInterface() interface{}

AsInterface returns Value's data as interface{}.

func (Value) AsString

func (v Value) AsString() string

AsString returns the string value. Make sure that the Value's type is STRING.

func (Value) AsStringSlice

func (v Value) AsStringSlice() []string

AsStringSlice returns the []string value. Make sure that the Value's type is INT64SLICE.

func (Value) Emit

func (v Value) Emit() string

Emit returns a string representation of Value's data.

func (Value) MarshalJSON

func (v Value) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of the Value.

func (Value) Type

func (v Value) Type() Type

Type returns a type of the Value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL