otel: go.opentelemetry.io/otel/metric/number Index | Files

package number

import "go.opentelemetry.io/otel/metric/number"

Package number provides a number abstraction for instruments that either support int64 or float64 input values.

This package is currently in a pre-GA phase. Backwards incompatible changes may be introduced in subsequent minor version releases as we work to track the evolving OpenTelemetry specification and user feedback.

Index

Package Files

doc.go kind_string.go number.go

type Kind Uses

type Kind int8

Kind describes the data type of the Number.

const (
    // Int64Kind means that the Number stores int64.
    Int64Kind Kind = iota
    // Float64Kind means that the Number stores float64.
    Float64Kind
)

func (Kind) Maximum Uses

func (k Kind) Maximum() Number

Maximum returns the maximum representable value for a given Kind

func (Kind) Minimum Uses

func (k Kind) Minimum() Number

Minimum returns the minimum representable value for a given Kind

func (Kind) String Uses

func (i Kind) String() string

func (Kind) Zero Uses

func (k Kind) Zero() Number

Zero returns a zero value for a given Kind

type Number Uses

type Number uint64

Number represents either an integral or a floating point value. It needs to be accompanied with a source of Kind that describes the actual type of the value stored within Number.

func NewFloat64Number Uses

func NewFloat64Number(f float64) Number

NewFloat64Number creates a floating point Number.

func NewInt64Number Uses

func NewInt64Number(i int64) Number

NewInt64Number creates an integral Number.

func NewNumberFromRaw Uses

func NewNumberFromRaw(r uint64) Number

NewNumberFromRaw creates a new Number from a raw value.

func NewNumberSignChange Uses

func NewNumberSignChange(kind Kind, nn Number) Number

NewNumberSignChange returns a number with the same magnitude and the opposite sign. `kind` must describe the kind of number in `nn`.

func (*Number) AddFloat64 Uses

func (n *Number) AddFloat64(f float64)

AddFloat64 assumes that the number contains a float64 and adds the passed float64 to it.

func (*Number) AddFloat64Atomic Uses

func (n *Number) AddFloat64Atomic(f float64)

AddFloat64Atomic assumes that the number contains a float64 and adds the passed float64 to it atomically.

func (*Number) AddInt64 Uses

func (n *Number) AddInt64(i int64)

AddInt64 assumes that the number contains an int64 and adds the passed int64 to it.

func (*Number) AddInt64Atomic Uses

func (n *Number) AddInt64Atomic(i int64)

AddInt64Atomic assumes that the number contains an int64 and adds the passed int64 to it atomically.

func (*Number) AddNumber Uses

func (n *Number) AddNumber(kind Kind, nn Number)

AddNumber assumes that this and the passed number are of the passed kind and adds the passed number to this number.

func (*Number) AddNumberAtomic Uses

func (n *Number) AddNumberAtomic(kind Kind, nn Number)

AddNumberAtomic assumes that this and the passed number are of the passed kind and adds the passed number to this number atomically.

func (*Number) AddRaw Uses

func (n *Number) AddRaw(kind Kind, r uint64)

AddRaw assumes that this number and the passed raw value are of the passed kind and adds the passed raw value to this number.

func (*Number) AddRawAtomic Uses

func (n *Number) AddRawAtomic(kind Kind, r uint64)

AddRawAtomic assumes that this number and the passed raw value are of the passed kind and adds the passed raw value to this number atomically.

func (*Number) AsFloat64 Uses

func (n *Number) AsFloat64() float64

AsFloat64 assumes that the measurement value contains a float64 and returns it as such.

func (*Number) AsFloat64Atomic Uses

func (n *Number) AsFloat64Atomic() float64

AsFloat64Atomic assumes that the measurement value contains a float64 and returns it as such atomically.

func (*Number) AsFloat64Ptr Uses

func (n *Number) AsFloat64Ptr() *float64

AsFloat64Ptr assumes that the number contains a float64 and returns a pointer to it.

func (*Number) AsInt64 Uses

func (n *Number) AsInt64() int64

AsInt64 assumes that the value contains an int64 and returns it as such.

func (*Number) AsInt64Atomic Uses

func (n *Number) AsInt64Atomic() int64

AsInt64Atomic assumes that the number contains an int64 and returns it as such atomically.

func (*Number) AsInt64Ptr Uses

func (n *Number) AsInt64Ptr() *int64

AsInt64Ptr assumes that the number contains an int64 and returns a pointer to it.

func (*Number) AsInterface Uses

func (n *Number) AsInterface(kind Kind) interface{}

AsInterface returns the number as an interface{}, typically used for Kind-correct JSON conversion.

func (*Number) AsNumber Uses

func (n *Number) AsNumber() Number

AsNumber gets the Number.

func (*Number) AsNumberAtomic Uses

func (n *Number) AsNumberAtomic() Number

AsNumberAtomic gets the Number atomically.

func (*Number) AsRaw Uses

func (n *Number) AsRaw() uint64

AsRaw gets the uninterpreted raw value. Might be useful for some atomic operations.

func (*Number) AsRawAtomic Uses

func (n *Number) AsRawAtomic() uint64

AsRawAtomic gets the uninterpreted raw value atomically. Might be useful for some atomic operations.

func (*Number) AsRawPtr Uses

func (n *Number) AsRawPtr() *uint64

AsRawPtr gets the pointer to the raw, uninterpreted raw value. Might be useful for some atomic operations.

func (*Number) CoerceToFloat64 Uses

func (n *Number) CoerceToFloat64(kind Kind) float64

CoerceToFloat64 casts the number to float64. May result in data/precision loss.

func (*Number) CoerceToInt64 Uses

func (n *Number) CoerceToInt64(kind Kind) int64

CoerceToInt64 casts the number to int64. May result in data/precision loss.

func (*Number) CompareAndSwapFloat64 Uses

func (n *Number) CompareAndSwapFloat64(of, nf float64) bool

CompareAndSwapFloat64 assumes that this number contains a float64 and does the atomic CAS operation on it.

func (*Number) CompareAndSwapInt64 Uses

func (n *Number) CompareAndSwapInt64(oi, ni int64) bool

CompareAndSwapInt64 assumes that this number contains an int64 and does the atomic CAS operation on it.

func (*Number) CompareAndSwapNumber Uses

func (n *Number) CompareAndSwapNumber(on, nn Number) bool

CompareAndSwapNumber does the atomic CAS operation on this number. This number and passed old and new numbers should be of the same kind.

func (*Number) CompareAndSwapRaw Uses

func (n *Number) CompareAndSwapRaw(or, nr uint64) bool

CompareAndSwapRaw does the atomic CAS operation on this number. This number and passed old and new raw values should be of the same kind.

func (*Number) CompareFloat64 Uses

func (n *Number) CompareFloat64(f float64) int

CompareFloat64 assumes that the Number contains a float64 and performs a comparison between the value and the other value. It returns the typical result of the compare function: -1 if the value is less than the other, 0 if both are equal, 1 if the value is greater than the other.

Do not compare NaN values.

func (*Number) CompareInt64 Uses

func (n *Number) CompareInt64(i int64) int

CompareInt64 assumes that the Number contains an int64 and performs a comparison between the value and the other value. It returns the typical result of the compare function: -1 if the value is less than the other, 0 if both are equal, 1 if the value is greater than the other.

func (*Number) CompareNumber Uses

func (n *Number) CompareNumber(kind Kind, nn Number) int

CompareNumber compares two Numbers given their kind. Both numbers should have the same kind. This returns:

0 if the numbers are equal
-1 if the subject `n` is less than the argument `nn`
+1 if the subject `n` is greater than the argument `nn`

func (*Number) CompareRaw Uses

func (n *Number) CompareRaw(kind Kind, r uint64) int

CompareRaw compares two numbers, where one is input as a raw uint64, interpreting both values as a `kind` of number.

func (*Number) Emit Uses

func (n *Number) Emit(kind Kind) string

Emit returns a string representation of the raw value of the Number. A %d is used for integral values, %f for floating point values.

func (*Number) IsNegative Uses

func (n *Number) IsNegative(kind Kind) bool

IsNegative returns true if the actual value is less than zero.

func (*Number) IsPositive Uses

func (n *Number) IsPositive(kind Kind) bool

IsPositive returns true if the actual value is greater than zero.

func (*Number) IsZero Uses

func (n *Number) IsZero(kind Kind) bool

IsZero returns true if the actual value is equal to zero.

func (*Number) SetFloat64 Uses

func (n *Number) SetFloat64(f float64)

SetFloat64 assumes that the number contains a float64 and sets it to the passed value.

func (*Number) SetFloat64Atomic Uses

func (n *Number) SetFloat64Atomic(f float64)

SetFloat64Atomic assumes that the number contains a float64 and sets it to the passed value atomically.

func (*Number) SetInt64 Uses

func (n *Number) SetInt64(i int64)

SetInt64 assumes that the number contains an int64 and sets it to the passed value.

func (*Number) SetInt64Atomic Uses

func (n *Number) SetInt64Atomic(i int64)

SetInt64Atomic assumes that the number contains an int64 and sets it to the passed value atomically.

func (*Number) SetNumber Uses

func (n *Number) SetNumber(nn Number)

SetNumber sets the number to the passed number. Both should be of the same kind.

func (*Number) SetNumberAtomic Uses

func (n *Number) SetNumberAtomic(nn Number)

SetNumberAtomic sets the number to the passed number atomically. Both should be of the same kind.

func (*Number) SetRaw Uses

func (n *Number) SetRaw(r uint64)

SetRaw sets the number to the passed raw value. Both number and the raw number should represent the same kind.

func (*Number) SetRawAtomic Uses

func (n *Number) SetRawAtomic(r uint64)

SetRawAtomic sets the number to the passed raw value atomically. Both number and the raw number should represent the same kind.

func (*Number) SwapFloat64 Uses

func (n *Number) SwapFloat64(f float64) float64

SwapFloat64 assumes that the number contains an float64, sets it to the passed value and returns the old float64 value.

func (*Number) SwapFloat64Atomic Uses

func (n *Number) SwapFloat64Atomic(f float64) float64

SwapFloat64Atomic assumes that the number contains an float64, sets it to the passed value and returns the old float64 value atomically.

func (*Number) SwapInt64 Uses

func (n *Number) SwapInt64(i int64) int64

SwapInt64 assumes that the number contains an int64, sets it to the passed value and returns the old int64 value.

func (*Number) SwapInt64Atomic Uses

func (n *Number) SwapInt64Atomic(i int64) int64

SwapInt64Atomic assumes that the number contains an int64, sets it to the passed value and returns the old int64 value atomically.

func (*Number) SwapNumber Uses

func (n *Number) SwapNumber(nn Number) Number

SwapNumber sets the number to the passed number and returns the old number. Both this number and the passed number should be of the same kind.

func (*Number) SwapNumberAtomic Uses

func (n *Number) SwapNumberAtomic(nn Number) Number

SwapNumberAtomic sets the number to the passed number and returns the old number atomically. Both this number and the passed number should be of the same kind.

func (*Number) SwapRaw Uses

func (n *Number) SwapRaw(r uint64) uint64

SwapRaw sets the number to the passed raw value and returns the old raw value. Both number and the raw number should represent the same kind.

func (*Number) SwapRawAtomic Uses

func (n *Number) SwapRawAtomic(r uint64) uint64

SwapRawAtomic sets the number to the passed raw value and returns the old raw value atomically. Both number and the raw number should represent the same kind.

Package number imports 5 packages (graph) and is imported by 25 packages. Updated 2020-11-19. Refresh now. Tools for package owners.