otel: go.opentelemetry.io/otel/api/core Index | Files

package core

import "go.opentelemetry.io/otel/api/core"

This package provides basic types used in OpenTelemetry - keys, values, numbers and span contexts.

Index

Package Files

doc.go key.go number.go numberkind_string.go rawhelpers.go span_context.go valuetype_string.go

Constants

const (

    // TraceFlagsSampled is a byte with sampled bit set. It is a convenient value initializer
    // for SpanContext TraceFlags field when a trace is sampled.
    TraceFlagsSampled = traceFlagsBitMaskSampled
    TraceFlagsUnused  = traceFlagsBitMaskUnused

    ErrInvalidHexID errorConst = "trace-id and span-id can only contain [0-9a-f] characters, all lowercase"

    ErrInvalidTraceIDLength errorConst = "hex encoded trace-id must have length equals to 32"
    ErrNilTraceID           errorConst = "trace-id can't be all zero"

    ErrInvalidSpanIDLength errorConst = "hex encoded span-id must have length equals to 16"
    ErrNilSpanID           errorConst = "span-id can't be all zero"
)

type Key Uses

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 Uses

func (k Key) Bool(v bool) KeyValue

Bool creates a KeyValue instance with a BOOL Value.

func (Key) Defined Uses

func (k Key) Defined() bool

Defined returns true for non-empty keys.

func (Key) Float32 Uses

func (k Key) Float32(v float32) KeyValue

Float32 creates a KeyValue instance with a FLOAT32 Value.

func (Key) Float64 Uses

func (k Key) Float64(v float64) KeyValue

Float64 creates a KeyValue instance with a FLOAT64 Value.

func (Key) Int Uses

func (k Key) Int(v int) KeyValue

Int creates a KeyValue instance with either an INT32 or an INT64 Value, depending on whether the int type is 32 or 64 bits wide.

func (Key) Int32 Uses

func (k Key) Int32(v int32) KeyValue

Int32 creates a KeyValue instance with an INT32 Value.

func (Key) Int64 Uses

func (k Key) Int64(v int64) KeyValue

Int64 creates a KeyValue instance with an INT64 Value.

func (Key) String Uses

func (k Key) String(v string) KeyValue

String creates a KeyValue instance with a STRING Value.

func (Key) Uint Uses

func (k Key) Uint(v uint) KeyValue

Uint creates a KeyValue instance with either an UINT32 or an UINT64 Value, depending on whether the uint type is 32 or 64 bits wide.

func (Key) Uint32 Uses

func (k Key) Uint32(v uint32) KeyValue

Uint32 creates a KeyValue instance with a UINT32 Value.

func (Key) Uint64 Uses

func (k Key) Uint64(v uint64) KeyValue

Uint64 creates a KeyValue instance with a UINT64 Value.

type KeyValue Uses

type KeyValue struct {
    Key   Key
    Value Value
}

KeyValue holds a key and value pair.

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 NumberKind 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 NewUint64Number Uses

func NewUint64Number(u uint64) Number

NewInt64Number creates an integral Number.

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 NumberKind, 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 NumberKind, 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 NumberKind, 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 NumberKind, 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) AddUint64 Uses

func (n *Number) AddUint64(u uint64)

AddUint64 assumes that the number contains a uint64 and adds the passed uint64 to it.

func (*Number) AddUint64Atomic Uses

func (n *Number) AddUint64Atomic(u uint64)

AddUint64Atomic assumes that the number contains a uint64 and atomically adds the passed uint64 to it.

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 NumberKind) interface{}

AsInterface returns the number as an interface{}, typically used for NumberKind-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) AsUint64 Uses

func (n *Number) AsUint64() uint64

AsUint64 assumes that the value contains an uint64 and returns it as such.

func (*Number) AsUint64Atomic Uses

func (n *Number) AsUint64Atomic() uint64

AsUint64Atomic assumes that the number contains a uint64 and returns it as such atomically.

func (*Number) AsUint64Ptr Uses

func (n *Number) AsUint64Ptr() *uint64

AsUint64Ptr assumes that the number contains a uint64 and returns a pointer to it.

func (*Number) CoerceToFloat64 Uses

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

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

func (*Number) CoerceToInt64 Uses

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

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

func (*Number) CoerceToUint64 Uses

func (n *Number) CoerceToUint64(kind NumberKind) uint64

CoerceToUint64 casts the number to uint64. 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) CompareAndSwapUint64 Uses

func (n *Number) CompareAndSwapUint64(ou, nu uint64) bool

CompareAndSwapUint64 assumes that this number contains a uint64 and does the atomic CAS operation on it.

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 NumberKind, 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 NumberKind, 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) CompareUint64 Uses

func (n *Number) CompareUint64(u uint64) int

CompareUint64 assumes that the Number contains an uint64 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) Emit Uses

func (n *Number) Emit(kind NumberKind) 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 NumberKind) bool

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

func (*Number) IsPositive Uses

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

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

func (*Number) IsZero Uses

func (n *Number) IsZero(kind NumberKind) 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) SetUint64 Uses

func (n *Number) SetUint64(u uint64)

SetUint64 assumes that the number contains a uint64 and sets it to the passed value.

func (*Number) SetUint64Atomic Uses

func (n *Number) SetUint64Atomic(u uint64)

SetUint64Atomic assumes that the number contains a uint64 and sets it to the passed value atomically.

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.

func (*Number) SwapUint64 Uses

func (n *Number) SwapUint64(u uint64) uint64

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

func (*Number) SwapUint64Atomic Uses

func (n *Number) SwapUint64Atomic(u uint64) uint64

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

type NumberKind Uses

type NumberKind int8

NumberKind describes the data type of the Number.

const (
    // Int64NumberKind means that the Number stores int64.
    Int64NumberKind NumberKind = iota
    // Float64NumberKind means that the Number stores float64.
    Float64NumberKind
    // Uint64NumberKind means that the Number stores uint64.
    Uint64NumberKind
)

func (NumberKind) Maximum Uses

func (k NumberKind) Maximum() Number

Maximum returns the maximum representable value for a given NumberKind

func (NumberKind) Minimum Uses

func (k NumberKind) Minimum() Number

Minimum returns the minimum representable value for a given NumberKind

func (NumberKind) String Uses

func (i NumberKind) String() string

func (NumberKind) Zero Uses

func (k NumberKind) Zero() Number

Zero returns a zero value for a given NumberKind

type SpanContext Uses

type SpanContext struct {
    TraceID    TraceID
    SpanID     SpanID
    TraceFlags byte
}

SpanContext contains basic information about the span - its trace ID, span ID and trace flags.

func EmptySpanContext Uses

func EmptySpanContext() SpanContext

EmptySpanContext is meant for internal use to return invalid span context during error conditions.

func (SpanContext) HasSpanID Uses

func (sc SpanContext) HasSpanID() bool

HasSpanID checks if the span context has a valid span ID.

func (SpanContext) HasTraceID Uses

func (sc SpanContext) HasTraceID() bool

HasTraceID checks if the span context has a valid trace ID.

func (SpanContext) IsSampled Uses

func (sc SpanContext) IsSampled() bool

IsSampled check if the sampling bit in trace flags is set.

func (SpanContext) IsValid Uses

func (sc SpanContext) IsValid() bool

IsValid checks if the span context is valid. A valid span context has a valid trace ID and a valid span ID.

func (SpanContext) SpanIDString Uses

func (sc SpanContext) SpanIDString() string

SpanIDString returns a hex string representation of the span ID in the span context.

func (SpanContext) TraceIDString Uses

func (sc SpanContext) TraceIDString() string

TraceIDString returns a hex string representation of the trace ID in the span context.

type SpanID Uses

type SpanID [8]byte

SpanID is a unique identify of a span in a trace.

func SpanIDFromHex Uses

func SpanIDFromHex(h string) (SpanID, error)

SpanIDFromHex returns a SpanID from a hex string if it is compliant with the w3c trace-context specification. See more at https://www.w3.org/TR/trace-context/#parent-id

func (SpanID) IsValid Uses

func (s SpanID) IsValid() bool

IsValid checks whether the span ID is valid. A valid span ID does not consist of zeros only.

func (SpanID) MarshalJSON Uses

func (s SpanID) MarshalJSON() ([]byte, error)

MarshalJSON implements a custom marshal function to encode SpanID as a hex string.

type TraceID Uses

type TraceID [16]byte

TraceID is a unique identity of a trace.

func TraceIDFromHex Uses

func TraceIDFromHex(h string) (TraceID, error)

TraceIDFromHex returns a TraceID from a hex string if it is compliant with the w3c trace-context specification. See more at https://www.w3.org/TR/trace-context/#trace-id

func (TraceID) IsValid Uses

func (t TraceID) IsValid() bool

IsValid checks whether the trace ID is valid. A valid trace ID does not consist of zeros only.

func (TraceID) MarshalJSON Uses

func (t TraceID) MarshalJSON() ([]byte, error)

MarshalJSON implements a custom marshal function to encode TraceID as a hex string.

type Value Uses

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

Value represents the value part in key-value pairs.

func Bool Uses

func Bool(v bool) Value

Bool creates a BOOL Value.

func Float32 Uses

func Float32(v float32) Value

Float32 creates a FLOAT32 Value.

func Float64 Uses

func Float64(v float64) Value

Float64 creates a FLOAT64 Value.

func Int Uses

func Int(v int) Value

Int creates either an INT32 or an INT64 Value, depending on whether the int type is 32 or 64 bits wide.

func Int32 Uses

func Int32(v int32) Value

Int32 creates an INT32 Value.

func Int64 Uses

func Int64(v int64) Value

Int64 creates an INT64 Value.

func String Uses

func String(v string) Value

String creates a STRING Value.

func Uint Uses

func Uint(v uint) Value

Uint creates either a UINT32 or a UINT64 Value, depending on whether the uint type is 32 or 64 bits wide.

func Uint32 Uses

func Uint32(v uint32) Value

Uint32 creates a UINT32 Value.

func Uint64 Uses

func Uint64(v uint64) Value

Uint64 creates a UINT64 Value.

func (*Value) AsBool Uses

func (v *Value) AsBool() bool

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

func (*Value) AsFloat32 Uses

func (v *Value) AsFloat32() float32

AsFloat32 returns the float32 value. Make sure that the Value's type is FLOAT32.

func (*Value) AsFloat64 Uses

func (v *Value) AsFloat64() float64

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

func (*Value) AsInt32 Uses

func (v *Value) AsInt32() int32

AsInt32 returns the int32 value. Make sure that the Value's type is INT32.

func (*Value) AsInt64 Uses

func (v *Value) AsInt64() int64

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

func (*Value) AsInterface Uses

func (v *Value) AsInterface() interface{}

AsInterface returns Value's data as interface{}.

func (*Value) AsString Uses

func (v *Value) AsString() string

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

func (*Value) AsUint32 Uses

func (v *Value) AsUint32() uint32

AsUint32 returns the uint32 value. Make sure that the Value's type is UINT32.

func (*Value) AsUint64 Uses

func (v *Value) AsUint64() uint64

AsUint64 returns the uint64 value. Make sure that the Value's type is UINT64.

func (*Value) Emit Uses

func (v *Value) Emit() string

Emit returns a string representation of Value's data.

func (*Value) MarshalJSON Uses

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

MarshalJSON returns the JSON encoding of the Value.

func (*Value) Type Uses

func (v *Value) Type() ValueType

Type returns a type of the Value.

type ValueType Uses

type ValueType int

ValueType describes the type of the data Value holds.

const (
    INVALID ValueType = iota // No value.
    BOOL                     // Boolean value, use AsBool() to get it.
    INT32                    // 32 bit signed integral value, use AsInt32() to get it.
    INT64                    // 64 bit signed integral value, use AsInt64() to get it.
    UINT32                   // 32 bit unsigned integral value, use AsUint32() to get it.
    UINT64                   // 64 bit unsigned integral value, use AsUint64() to get it.
    FLOAT32                  // 32 bit floating point value, use AsFloat32() to get it.
    FLOAT64                  // 64 bit floating point value, use AsFloat64() to get it.
    STRING                   // String value, use AsString() to get it.
)

func (ValueType) String Uses

func (i ValueType) String() string

Package core imports 8 packages (graph) and is imported by 60 packages. Updated 2020-03-24. Refresh now. Tools for package owners.