pcommon

package
v1.22.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 12 Imported by: 623

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByteSlice added in v0.60.0

type ByteSlice internal.ByteSlice

ByteSlice represents a []byte slice. The instance of ByteSlice can be assigned to multiple objects since it's immutable.

Must use NewByteSlice function to create new instances. Important: zero-initialized instance is not valid for use.

func NewByteSlice added in v0.60.0

func NewByteSlice() ByteSlice

NewByteSlice creates a new empty ByteSlice.

func (ByteSlice) Append added in v0.61.0

func (ms ByteSlice) Append(elms ...byte)

Append appends extra elements to ByteSlice. Equivalent of byteSlice = append(byteSlice, elms...)

func (ByteSlice) AsRaw added in v0.60.0

func (ms ByteSlice) AsRaw() []byte

AsRaw returns a copy of the []byte slice.

func (ByteSlice) At added in v0.60.0

func (ms ByteSlice) At(i int) byte

At returns an item from particular index. Equivalent of byteSlice[i].

func (ByteSlice) CopyTo added in v0.60.0

func (ms ByteSlice) CopyTo(dest ByteSlice)

CopyTo copies all elements from the current slice overriding the destination.

func (ByteSlice) EnsureCapacity added in v0.61.0

func (ms ByteSlice) EnsureCapacity(newCap int)

EnsureCapacity ensures ByteSlice has at least the specified capacity.

  1. If the newCap <= cap, then is no change in capacity.
  2. If the newCap > cap, then the slice capacity will be expanded to the provided value which will be equivalent of: buf := make([]byte, len(byteSlice), newCap) copy(buf, byteSlice) byteSlice = buf

func (ByteSlice) FromRaw added in v0.60.0

func (ms ByteSlice) FromRaw(val []byte)

FromRaw copies raw []byte into the slice ByteSlice.

func (ByteSlice) Len added in v0.60.0

func (ms ByteSlice) Len() int

Len returns length of the []byte slice value. Equivalent of len(byteSlice).

func (ByteSlice) MoveTo added in v0.60.0

func (ms ByteSlice) MoveTo(dest ByteSlice)

MoveTo moves all elements from the current slice overriding the destination and resetting the current instance to its zero value.

func (ByteSlice) SetAt added in v0.60.0

func (ms ByteSlice) SetAt(i int, val byte)

SetAt sets byte item at particular index. Equivalent of byteSlice[i] = val

type Float64Slice added in v0.60.0

type Float64Slice internal.Float64Slice

Float64Slice represents a []float64 slice. The instance of Float64Slice can be assigned to multiple objects since it's immutable.

Must use NewFloat64Slice function to create new instances. Important: zero-initialized instance is not valid for use.

func NewFloat64Slice added in v0.60.0

func NewFloat64Slice() Float64Slice

NewFloat64Slice creates a new empty Float64Slice.

func (Float64Slice) Append added in v0.61.0

func (ms Float64Slice) Append(elms ...float64)

Append appends extra elements to Float64Slice. Equivalent of float64Slice = append(float64Slice, elms...)

func (Float64Slice) AsRaw added in v0.60.0

func (ms Float64Slice) AsRaw() []float64

AsRaw returns a copy of the []float64 slice.

func (Float64Slice) At added in v0.60.0

func (ms Float64Slice) At(i int) float64

At returns an item from particular index. Equivalent of float64Slice[i].

func (Float64Slice) CopyTo added in v0.60.0

func (ms Float64Slice) CopyTo(dest Float64Slice)

CopyTo copies all elements from the current slice overriding the destination.

func (Float64Slice) EnsureCapacity added in v0.61.0

func (ms Float64Slice) EnsureCapacity(newCap int)

EnsureCapacity ensures Float64Slice has at least the specified capacity.

  1. If the newCap <= cap, then is no change in capacity.
  2. If the newCap > cap, then the slice capacity will be expanded to the provided value which will be equivalent of: buf := make([]float64, len(float64Slice), newCap) copy(buf, float64Slice) float64Slice = buf

func (Float64Slice) FromRaw added in v0.60.0

func (ms Float64Slice) FromRaw(val []float64)

FromRaw copies raw []float64 into the slice Float64Slice.

func (Float64Slice) Len added in v0.60.0

func (ms Float64Slice) Len() int

Len returns length of the []float64 slice value. Equivalent of len(float64Slice).

func (Float64Slice) MoveTo added in v0.60.0

func (ms Float64Slice) MoveTo(dest Float64Slice)

MoveTo moves all elements from the current slice overriding the destination and resetting the current instance to its zero value.

func (Float64Slice) SetAt added in v0.60.0

func (ms Float64Slice) SetAt(i int, val float64)

SetAt sets float64 item at particular index. Equivalent of float64Slice[i] = val

type InstrumentationScope

type InstrumentationScope internal.InstrumentationScope

InstrumentationScope is a message representing the instrumentation scope information.

This is a reference type, if passed by value and callee modifies it the caller will see the modification.

Must use NewInstrumentationScope function to create new instances. Important: zero-initialized instance is not valid for use.

func NewInstrumentationScope

func NewInstrumentationScope() InstrumentationScope

NewInstrumentationScope creates a new empty InstrumentationScope.

This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, OR directly access the member if this is embedded in another struct.

func (InstrumentationScope) Attributes added in v0.59.0

func (ms InstrumentationScope) Attributes() Map

Attributes returns the Attributes associated with this InstrumentationScope.

func (InstrumentationScope) CopyTo added in v0.59.0

CopyTo copies all properties from the current struct overriding the destination.

func (InstrumentationScope) DroppedAttributesCount added in v0.59.0

func (ms InstrumentationScope) DroppedAttributesCount() uint32

DroppedAttributesCount returns the droppedattributescount associated with this InstrumentationScope.

func (InstrumentationScope) MoveTo added in v0.59.0

MoveTo moves all properties from the current struct overriding the destination and resetting the current instance to its zero value

func (InstrumentationScope) Name added in v0.59.0

func (ms InstrumentationScope) Name() string

Name returns the name associated with this InstrumentationScope.

func (InstrumentationScope) SetDroppedAttributesCount added in v0.59.0

func (ms InstrumentationScope) SetDroppedAttributesCount(v uint32)

SetDroppedAttributesCount replaces the droppedattributescount associated with this InstrumentationScope.

func (InstrumentationScope) SetName added in v0.59.0

func (ms InstrumentationScope) SetName(v string)

SetName replaces the name associated with this InstrumentationScope.

func (InstrumentationScope) SetVersion added in v0.59.0

func (ms InstrumentationScope) SetVersion(v string)

SetVersion replaces the version associated with this InstrumentationScope.

func (InstrumentationScope) Version added in v0.59.0

func (ms InstrumentationScope) Version() string

Version returns the version associated with this InstrumentationScope.

type Int32Slice added in v1.21.0

type Int32Slice internal.Int32Slice

Int32Slice represents a []int32 slice. The instance of Int32Slice can be assigned to multiple objects since it's immutable.

Must use NewInt32Slice function to create new instances. Important: zero-initialized instance is not valid for use.

func NewInt32Slice added in v1.21.0

func NewInt32Slice() Int32Slice

NewInt32Slice creates a new empty Int32Slice.

func (Int32Slice) Append added in v1.21.0

func (ms Int32Slice) Append(elms ...int32)

Append appends extra elements to Int32Slice. Equivalent of int32Slice = append(int32Slice, elms...)

func (Int32Slice) AsRaw added in v1.21.0

func (ms Int32Slice) AsRaw() []int32

AsRaw returns a copy of the []int32 slice.

func (Int32Slice) At added in v1.21.0

func (ms Int32Slice) At(i int) int32

At returns an item from particular index. Equivalent of int32Slice[i].

func (Int32Slice) CopyTo added in v1.21.0

func (ms Int32Slice) CopyTo(dest Int32Slice)

CopyTo copies all elements from the current slice overriding the destination.

func (Int32Slice) EnsureCapacity added in v1.21.0

func (ms Int32Slice) EnsureCapacity(newCap int)

EnsureCapacity ensures Int32Slice has at least the specified capacity.

  1. If the newCap <= cap, then is no change in capacity.
  2. If the newCap > cap, then the slice capacity will be expanded to the provided value which will be equivalent of: buf := make([]int32, len(int32Slice), newCap) copy(buf, int32Slice) int32Slice = buf

func (Int32Slice) FromRaw added in v1.21.0

func (ms Int32Slice) FromRaw(val []int32)

FromRaw copies raw []int32 into the slice Int32Slice.

func (Int32Slice) Len added in v1.21.0

func (ms Int32Slice) Len() int

Len returns length of the []int32 slice value. Equivalent of len(int32Slice).

func (Int32Slice) MoveTo added in v1.21.0

func (ms Int32Slice) MoveTo(dest Int32Slice)

MoveTo moves all elements from the current slice overriding the destination and resetting the current instance to its zero value.

func (Int32Slice) SetAt added in v1.21.0

func (ms Int32Slice) SetAt(i int, val int32)

SetAt sets int32 item at particular index. Equivalent of int32Slice[i] = val

type Int64Slice added in v1.9.0

type Int64Slice internal.Int64Slice

Int64Slice represents a []int64 slice. The instance of Int64Slice can be assigned to multiple objects since it's immutable.

Must use NewInt64Slice function to create new instances. Important: zero-initialized instance is not valid for use.

func NewInt64Slice added in v1.9.0

func NewInt64Slice() Int64Slice

NewInt64Slice creates a new empty Int64Slice.

func (Int64Slice) Append added in v1.9.0

func (ms Int64Slice) Append(elms ...int64)

Append appends extra elements to Int64Slice. Equivalent of int64Slice = append(int64Slice, elms...)

func (Int64Slice) AsRaw added in v1.9.0

func (ms Int64Slice) AsRaw() []int64

AsRaw returns a copy of the []int64 slice.

func (Int64Slice) At added in v1.9.0

func (ms Int64Slice) At(i int) int64

At returns an item from particular index. Equivalent of int64Slice[i].

func (Int64Slice) CopyTo added in v1.9.0

func (ms Int64Slice) CopyTo(dest Int64Slice)

CopyTo copies all elements from the current slice overriding the destination.

func (Int64Slice) EnsureCapacity added in v1.9.0

func (ms Int64Slice) EnsureCapacity(newCap int)

EnsureCapacity ensures Int64Slice has at least the specified capacity.

  1. If the newCap <= cap, then is no change in capacity.
  2. If the newCap > cap, then the slice capacity will be expanded to the provided value which will be equivalent of: buf := make([]int64, len(int64Slice), newCap) copy(buf, int64Slice) int64Slice = buf

func (Int64Slice) FromRaw added in v1.9.0

func (ms Int64Slice) FromRaw(val []int64)

FromRaw copies raw []int64 into the slice Int64Slice.

func (Int64Slice) Len added in v1.9.0

func (ms Int64Slice) Len() int

Len returns length of the []int64 slice value. Equivalent of len(int64Slice).

func (Int64Slice) MoveTo added in v1.9.0

func (ms Int64Slice) MoveTo(dest Int64Slice)

MoveTo moves all elements from the current slice overriding the destination and resetting the current instance to its zero value.

func (Int64Slice) SetAt added in v1.9.0

func (ms Int64Slice) SetAt(i int, val int64)

SetAt sets int64 item at particular index. Equivalent of int64Slice[i] = val

type IntSlice added in v1.21.0

type IntSlice internal.IntSlice

IntSlice represents a []int slice. The instance of IntSlice can be assigned to multiple objects since it's immutable.

Must use NewIntSlice function to create new instances. Important: zero-initialized instance is not valid for use.

func NewIntSlice added in v1.21.0

func NewIntSlice() IntSlice

NewIntSlice creates a new empty IntSlice.

func (IntSlice) Append added in v1.21.0

func (ms IntSlice) Append(elms ...int)

Append appends extra elements to IntSlice. Equivalent of intSlice = append(intSlice, elms...)

func (IntSlice) AsRaw added in v1.21.0

func (ms IntSlice) AsRaw() []int

AsRaw returns a copy of the []int slice.

func (IntSlice) At added in v1.21.0

func (ms IntSlice) At(i int) int

At returns an item from particular index. Equivalent of intSlice[i].

func (IntSlice) CopyTo added in v1.21.0

func (ms IntSlice) CopyTo(dest IntSlice)

CopyTo copies all elements from the current slice overriding the destination.

func (IntSlice) EnsureCapacity added in v1.21.0

func (ms IntSlice) EnsureCapacity(newCap int)

EnsureCapacity ensures IntSlice has at least the specified capacity.

  1. If the newCap <= cap, then is no change in capacity.
  2. If the newCap > cap, then the slice capacity will be expanded to the provided value which will be equivalent of: buf := make([]int, len(intSlice), newCap) copy(buf, intSlice) intSlice = buf

func (IntSlice) FromRaw added in v1.21.0

func (ms IntSlice) FromRaw(val []int)

FromRaw copies raw []int into the slice IntSlice.

func (IntSlice) Len added in v1.21.0

func (ms IntSlice) Len() int

Len returns length of the []int slice value. Equivalent of len(intSlice).

func (IntSlice) MoveTo added in v1.21.0

func (ms IntSlice) MoveTo(dest IntSlice)

MoveTo moves all elements from the current slice overriding the destination and resetting the current instance to its zero value.

func (IntSlice) SetAt added in v1.21.0

func (ms IntSlice) SetAt(i int, val int)

SetAt sets int item at particular index. Equivalent of intSlice[i] = val

type Map

type Map internal.Map

Map stores a map of string keys to elements of Value type.

Must use NewMap function to create new instances. Important: zero-initialized instance is not valid for use.

func NewMap

func NewMap() Map

NewMap creates a Map with 0 elements.

func (Map) AsRaw added in v0.59.0

func (m Map) AsRaw() map[string]any

AsRaw returns a standard go map representation of this Map.

func (Map) Clear added in v0.59.0

func (m Map) Clear()

Clear erases any existing entries in this Map instance.

func (Map) CopyTo added in v0.59.0

func (m Map) CopyTo(dest Map)

CopyTo copies all elements from the current map overriding the destination.

func (Map) EnsureCapacity added in v0.59.0

func (m Map) EnsureCapacity(capacity int)

EnsureCapacity increases the capacity of this Map instance, if necessary, to ensure that it can hold at least the number of elements specified by the capacity argument.

func (Map) FromRaw added in v0.60.0

func (m Map) FromRaw(rawMap map[string]any) error

FromRaw overrides this Map instance from a standard go map.

func (Map) Get added in v0.59.0

func (m Map) Get(key string) (Value, bool)

Get returns the Value associated with the key and true. Returned Value is not a copy, it is a reference to the value stored in this map. It is allowed to modify the returned value using Value.Set* functions. Such modification will be applied to the value stored in this map.

If the key does not exist returns a zero-initialized KeyValue and false. Calling any functions on the returned invalid instance may cause a panic.

func (Map) Len added in v0.59.0

func (m Map) Len() int

Len returns the length of this map.

Because the Map is represented internally by a slice of pointers, and the data are comping from the wire, it is possible that when iterating using "Range" to get access to fewer elements because nil elements are skipped.

func (Map) MoveTo added in v1.16.0

func (m Map) MoveTo(dest Map)

MoveTo moves all key/values from the current map overriding the destination and resetting the current instance to its zero value

func (Map) PutBool added in v0.60.0

func (m Map) PutBool(k string, v bool)

PutBool performs the Insert or Update action. The bool Value is inserted to the map that did not originally have the key. The key/value is updated to the map where the key already existed.

func (Map) PutDouble added in v0.60.0

func (m Map) PutDouble(k string, v float64)

PutDouble performs the Insert or Update action. The double Value is inserted to the map that did not originally have the key. The key/value is updated to the map where the key already existed.

func (Map) PutEmpty added in v0.60.0

func (m Map) PutEmpty(k string) Value

PutEmpty inserts or updates an empty value to the map under given key and return the updated/inserted value.

func (Map) PutEmptyBytes added in v0.60.0

func (m Map) PutEmptyBytes(k string) ByteSlice

PutEmptyBytes inserts or updates an empty byte slice under given key and returns it.

func (Map) PutEmptyMap added in v0.60.0

func (m Map) PutEmptyMap(k string) Map

PutEmptyMap inserts or updates an empty map under given key and returns it.

func (Map) PutEmptySlice added in v0.60.0

func (m Map) PutEmptySlice(k string) Slice

PutEmptySlice inserts or updates an empty slice under given key and returns it.

func (Map) PutInt added in v0.60.0

func (m Map) PutInt(k string, v int64)

PutInt performs the Insert or Update action. The int Value is inserted to the map that did not originally have the key. The key/value is updated to the map where the key already existed.

func (Map) PutStr added in v0.62.0

func (m Map) PutStr(k string, v string)

PutStr performs the Insert or Update action. The Value is inserted to the map that did not originally have the key. The key/value is updated to the map where the key already existed.

func (Map) Range added in v0.59.0

func (m Map) Range(f func(k string, v Value) bool)

Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.

Example:

sm.Range(func(k string, v Value) bool {
    ...
})

func (Map) Remove added in v0.59.0

func (m Map) Remove(key string) bool

Remove removes the entry associated with the key and returns true if the key was present in the map, otherwise returns false.

func (Map) RemoveIf added in v0.59.0

func (m Map) RemoveIf(f func(string, Value) bool)

RemoveIf removes the entries for which the function in question returns true

type Resource

type Resource internal.Resource

Resource is a message representing the resource information.

This is a reference type, if passed by value and callee modifies it the caller will see the modification.

Must use NewResource function to create new instances. Important: zero-initialized instance is not valid for use.

func NewResource

func NewResource() Resource

NewResource creates a new empty Resource.

This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, OR directly access the member if this is embedded in another struct.

func (Resource) Attributes added in v0.59.0

func (ms Resource) Attributes() Map

Attributes returns the Attributes associated with this Resource.

func (Resource) CopyTo added in v0.59.0

func (ms Resource) CopyTo(dest Resource)

CopyTo copies all properties from the current struct overriding the destination.

func (Resource) DroppedAttributesCount added in v0.59.0

func (ms Resource) DroppedAttributesCount() uint32

DroppedAttributesCount returns the droppedattributescount associated with this Resource.

func (Resource) MoveTo added in v0.59.0

func (ms Resource) MoveTo(dest Resource)

MoveTo moves all properties from the current struct overriding the destination and resetting the current instance to its zero value

func (Resource) SetDroppedAttributesCount added in v0.59.0

func (ms Resource) SetDroppedAttributesCount(v uint32)

SetDroppedAttributesCount replaces the droppedattributescount associated with this Resource.

type Slice

type Slice internal.Slice

Slice logically represents a slice of Value.

This is a reference type. If passed by value and callee modifies it, the caller will see the modification.

Must use NewSlice function to create new instances. Important: zero-initialized instance is not valid for use.

func NewSlice

func NewSlice() Slice

NewSlice creates a Slice with 0 elements. Can use "EnsureCapacity" to initialize with a given capacity.

func (Slice) AppendEmpty added in v0.59.0

func (es Slice) AppendEmpty() Value

AppendEmpty will append to the end of the slice an empty Value. It returns the newly added Value.

func (Slice) AsRaw added in v0.59.0

func (es Slice) AsRaw() []any

AsRaw return []any copy of the Slice.

func (Slice) At added in v0.59.0

func (es Slice) At(ix int) Value

At returns the element at the given index.

This function is used mostly for iterating over all the values in the slice:

for i := 0; i < es.Len(); i++ {
    e := es.At(i)
    ... // Do something with the element
}

func (Slice) CopyTo added in v0.59.0

func (es Slice) CopyTo(dest Slice)

CopyTo copies all elements from the current slice overriding the destination.

func (Slice) EnsureCapacity added in v0.59.0

func (es Slice) EnsureCapacity(newCap int)

EnsureCapacity is an operation that ensures the slice has at least the specified capacity. 1. If the newCap <= cap then no change in capacity. 2. If the newCap > cap then the slice capacity will be expanded to equal newCap.

Here is how a new Slice can be initialized:

es := NewSlice()
es.EnsureCapacity(4)
for i := 0; i < 4; i++ {
    e := es.AppendEmpty()
    // Here should set all the values for e.
}

func (Slice) FromRaw added in v0.60.0

func (es Slice) FromRaw(rawSlice []any) error

FromRaw copies []any into the Slice.

func (Slice) Len added in v0.59.0

func (es Slice) Len() int

Len returns the number of elements in the slice.

Returns "0" for a newly instance created with "NewSlice()".

func (Slice) MoveAndAppendTo added in v0.59.0

func (es Slice) MoveAndAppendTo(dest Slice)

MoveAndAppendTo moves all elements from the current slice and appends them to the dest. The current slice will be cleared.

func (Slice) RemoveIf added in v0.59.0

func (es Slice) RemoveIf(f func(Value) bool)

RemoveIf calls f sequentially for each element present in the slice. If f returns true, the element is removed from the slice.

type SpanID

type SpanID [8]byte

SpanID is span identifier.

func NewSpanIDEmpty added in v0.60.0

func NewSpanIDEmpty() SpanID

NewSpanIDEmpty returns a new empty (all zero bytes) SpanID.

func (SpanID) IsEmpty added in v0.59.0

func (ms SpanID) IsEmpty() bool

IsEmpty returns true if id doesn't contain at least one non-zero byte.

func (SpanID) String added in v0.65.0

func (ms SpanID) String() string

String returns string representation of the SpanID.

Important: Don't rely on this method to get a string identifier of SpanID, Use hex.EncodeToString explicitly instead. This method meant to implement Stringer interface for display purposes only.

type StringSlice added in v1.9.0

type StringSlice internal.StringSlice

StringSlice represents a []string slice. The instance of StringSlice can be assigned to multiple objects since it's immutable.

Must use NewStringSlice function to create new instances. Important: zero-initialized instance is not valid for use.

func NewStringSlice added in v1.9.0

func NewStringSlice() StringSlice

NewStringSlice creates a new empty StringSlice.

func (StringSlice) Append added in v1.9.0

func (ms StringSlice) Append(elms ...string)

Append appends extra elements to StringSlice. Equivalent of stringSlice = append(stringSlice, elms...)

func (StringSlice) AsRaw added in v1.9.0

func (ms StringSlice) AsRaw() []string

AsRaw returns a copy of the []string slice.

func (StringSlice) At added in v1.9.0

func (ms StringSlice) At(i int) string

At returns an item from particular index. Equivalent of stringSlice[i].

func (StringSlice) CopyTo added in v1.9.0

func (ms StringSlice) CopyTo(dest StringSlice)

CopyTo copies all elements from the current slice overriding the destination.

func (StringSlice) EnsureCapacity added in v1.9.0

func (ms StringSlice) EnsureCapacity(newCap int)

EnsureCapacity ensures StringSlice has at least the specified capacity.

  1. If the newCap <= cap, then is no change in capacity.
  2. If the newCap > cap, then the slice capacity will be expanded to the provided value which will be equivalent of: buf := make([]string, len(stringSlice), newCap) copy(buf, stringSlice) stringSlice = buf

func (StringSlice) FromRaw added in v1.9.0

func (ms StringSlice) FromRaw(val []string)

FromRaw copies raw []string into the slice StringSlice.

func (StringSlice) Len added in v1.9.0

func (ms StringSlice) Len() int

Len returns length of the []string slice value. Equivalent of len(stringSlice).

func (StringSlice) MoveTo added in v1.9.0

func (ms StringSlice) MoveTo(dest StringSlice)

MoveTo moves all elements from the current slice overriding the destination and resetting the current instance to its zero value.

func (StringSlice) SetAt added in v1.9.0

func (ms StringSlice) SetAt(i int, val string)

SetAt sets string item at particular index. Equivalent of stringSlice[i] = val

type Timestamp

type Timestamp uint64

Timestamp is a time specified as UNIX Epoch time in nanoseconds since 1970-01-01 00:00:00 +0000 UTC.

func NewTimestampFromTime

func NewTimestampFromTime(t time.Time) Timestamp

NewTimestampFromTime constructs a new Timestamp from the provided time.Time.

func (Timestamp) AsTime added in v0.59.0

func (ts Timestamp) AsTime() time.Time

AsTime converts this to a time.Time.

func (Timestamp) String added in v0.59.0

func (ts Timestamp) String() string

String returns the string representation of this in UTC.

type TraceID

type TraceID [16]byte

TraceID is a trace identifier.

func NewTraceIDEmpty added in v0.60.0

func NewTraceIDEmpty() TraceID

NewTraceIDEmpty returns a new empty (all zero bytes) TraceID.

func (TraceID) IsEmpty added in v0.59.0

func (ms TraceID) IsEmpty() bool

IsEmpty returns true if id doesn't contain at least one non-zero byte.

func (TraceID) String added in v0.65.0

func (ms TraceID) String() string

String returns string representation of the TraceID.

Important: Don't rely on this method to get a string identifier of TraceID. Use hex.EncodeToString explicitly instead. This method meant to implement Stringer interface for display purposes only.

type TraceState added in v0.60.0

type TraceState internal.TraceState

TraceState represents the trace state from the w3c-trace-context.

Must use NewTraceState function to create new instances. Important: zero-initialized instance is not valid for use.

func NewTraceState added in v0.60.0

func NewTraceState() TraceState

func (TraceState) AsRaw added in v0.60.0

func (ms TraceState) AsRaw() string

AsRaw returns the string representation of the tracestate in w3c-trace-context format: https://www.w3.org/TR/trace-context/#tracestate-header

func (TraceState) CopyTo added in v0.60.0

func (ms TraceState) CopyTo(dest TraceState)

CopyTo copies the TraceState instance overriding the destination.

func (TraceState) FromRaw added in v0.60.0

func (ms TraceState) FromRaw(v string)

FromRaw copies the string representation in w3c-trace-context format of the tracestate into this TraceState.

func (TraceState) MoveTo added in v0.60.0

func (ms TraceState) MoveTo(dest TraceState)

MoveTo moves the TraceState instance overriding the destination and resetting the current instance to its zero value.

type UInt64Slice added in v0.60.0

type UInt64Slice internal.UInt64Slice

UInt64Slice represents a []uint64 slice. The instance of UInt64Slice can be assigned to multiple objects since it's immutable.

Must use NewUInt64Slice function to create new instances. Important: zero-initialized instance is not valid for use.

func NewUInt64Slice added in v0.60.0

func NewUInt64Slice() UInt64Slice

NewUInt64Slice creates a new empty UInt64Slice.

func (UInt64Slice) Append added in v0.61.0

func (ms UInt64Slice) Append(elms ...uint64)

Append appends extra elements to UInt64Slice. Equivalent of uInt64Slice = append(uInt64Slice, elms...)

func (UInt64Slice) AsRaw added in v0.60.0

func (ms UInt64Slice) AsRaw() []uint64

AsRaw returns a copy of the []uint64 slice.

func (UInt64Slice) At added in v0.60.0

func (ms UInt64Slice) At(i int) uint64

At returns an item from particular index. Equivalent of uInt64Slice[i].

func (UInt64Slice) CopyTo added in v0.60.0

func (ms UInt64Slice) CopyTo(dest UInt64Slice)

CopyTo copies all elements from the current slice overriding the destination.

func (UInt64Slice) EnsureCapacity added in v0.61.0

func (ms UInt64Slice) EnsureCapacity(newCap int)

EnsureCapacity ensures UInt64Slice has at least the specified capacity.

  1. If the newCap <= cap, then is no change in capacity.
  2. If the newCap > cap, then the slice capacity will be expanded to the provided value which will be equivalent of: buf := make([]uint64, len(uInt64Slice), newCap) copy(buf, uInt64Slice) uInt64Slice = buf

func (UInt64Slice) FromRaw added in v0.60.0

func (ms UInt64Slice) FromRaw(val []uint64)

FromRaw copies raw []uint64 into the slice UInt64Slice.

func (UInt64Slice) Len added in v0.60.0

func (ms UInt64Slice) Len() int

Len returns length of the []uint64 slice value. Equivalent of len(uInt64Slice).

func (UInt64Slice) MoveTo added in v0.60.0

func (ms UInt64Slice) MoveTo(dest UInt64Slice)

MoveTo moves all elements from the current slice overriding the destination and resetting the current instance to its zero value.

func (UInt64Slice) SetAt added in v0.60.0

func (ms UInt64Slice) SetAt(i int, val uint64)

SetAt sets uint64 item at particular index. Equivalent of uInt64Slice[i] = val

type Value

type Value internal.Value

Value is a mutable cell containing any value. Typically used as an element of Map or Slice. Must use one of NewValue+ functions below to create new instances.

Intended to be passed by value since internally it is just a pointer to actual value representation. For the same reason passing by value and calling setters will modify the original, e.g.:

func f1(val Value) { val.SetInt(234) }
func f2() {
    v := NewValueStr("a string")
    f1(v)
    _ := v.Type() // this will return ValueTypeInt
}

Important: zero-initialized instance is not valid for use. All Value functions below must be called only on instances that are created via NewValue+ functions.

func NewValueBool

func NewValueBool(v bool) Value

NewValueBool creates a new Value with the given bool value.

func NewValueBytes

func NewValueBytes() Value

NewValueBytes creates a new empty Value of byte type.

func NewValueDouble

func NewValueDouble(v float64) Value

NewValueDouble creates a new Value with the given float64 value.

func NewValueEmpty

func NewValueEmpty() Value

NewValueEmpty creates a new Value with an empty value.

func NewValueInt

func NewValueInt(v int64) Value

NewValueInt creates a new Value with the given int64 value.

func NewValueMap

func NewValueMap() Value

NewValueMap creates a new Value of map type.

func NewValueSlice

func NewValueSlice() Value

NewValueSlice creates a new Value of array type.

func NewValueStr added in v0.62.0

func NewValueStr(v string) Value

NewValueStr creates a new Value with the given string value.

func (Value) AsRaw added in v0.61.0

func (v Value) AsRaw() any

func (Value) AsString added in v0.59.0

func (v Value) AsString() string

AsString converts an OTLP Value object of any type to its equivalent string representation. This differs from Str which only returns a non-empty value if the ValueType is ValueTypeStr. Calling this function on zero-initialized Value will cause a panic.

func (Value) Bool added in v0.61.0

func (v Value) Bool() bool

Bool returns the bool value associated with this Value. If the Type() is not ValueTypeBool then returns false.

func (Value) Bytes added in v0.61.0

func (v Value) Bytes() ByteSlice

Bytes returns the ByteSlice value associated with this Value. If the function is called on zero-initialized Value or if the Type() is not ValueTypeBytes then returns an invalid ByteSlice object. Note that using such slice can cause panic.

func (Value) CopyTo added in v0.59.0

func (v Value) CopyTo(dest Value)

CopyTo copies the Value instance overriding the destination. Calling this function on zero-initialized Value will cause a panic.

func (Value) Double added in v0.61.0

func (v Value) Double() float64

Double returns the float64 value associated with this Value. If the Type() is not ValueTypeDouble then returns float64(0).

func (Value) FromRaw added in v0.61.0

func (v Value) FromRaw(iv any) error

FromRaw sets the value from the given raw value. Calling this function on zero-initialized Value will cause a panic.

func (Value) Int added in v0.61.0

func (v Value) Int() int64

Int returns the int64 value associated with this Value. If the Type() is not ValueTypeInt then returns int64(0).

func (Value) Map added in v0.61.0

func (v Value) Map() Map

Map returns the map value associated with this Value. If the function is called on zero-initialized Value or if the Type() is not ValueTypeMap then it returns an invalid map. Note that using such map can cause panic.

func (Value) SetBool added in v0.61.0

func (v Value) SetBool(bv bool)

SetBool replaces the bool value associated with this Value, it also changes the type to be ValueTypeBool. Calling this function on zero-initialized Value will cause a panic.

func (Value) SetDouble added in v0.61.0

func (v Value) SetDouble(dv float64)

SetDouble replaces the float64 value associated with this Value, it also changes the type to be ValueTypeDouble. Calling this function on zero-initialized Value will cause a panic.

func (Value) SetEmptyBytes added in v0.61.0

func (v Value) SetEmptyBytes() ByteSlice

SetEmptyBytes sets value to an empty byte slice and returns it. Calling this function on zero-initialized Value will cause a panic.

func (Value) SetEmptyMap added in v0.61.0

func (v Value) SetEmptyMap() Map

SetEmptyMap sets value to an empty map and returns it. Calling this function on zero-initialized Value will cause a panic.

func (Value) SetEmptySlice added in v0.61.0

func (v Value) SetEmptySlice() Slice

SetEmptySlice sets value to an empty slice and returns it. Calling this function on zero-initialized Value will cause a panic.

func (Value) SetInt added in v0.61.0

func (v Value) SetInt(iv int64)

SetInt replaces the int64 value associated with this Value, it also changes the type to be ValueTypeInt. Calling this function on zero-initialized Value will cause a panic.

func (Value) SetStr added in v0.61.0

func (v Value) SetStr(sv string)

SetStr replaces the string value associated with this Value, it also changes the type to be ValueTypeStr. The shorter name is used instead of SetString to avoid implementing fmt.Stringer interface by the corresponding getter method. Calling this function on zero-initialized Value will cause a panic.

func (Value) Slice added in v0.61.0

func (v Value) Slice() Slice

Slice returns the slice value associated with this Value. If the function is called on zero-initialized Value or if the Type() is not ValueTypeSlice then returns an invalid slice. Note that using such slice can cause panic.

func (Value) Str added in v0.61.0

func (v Value) Str() string

Str returns the string value associated with this Value. The shorter name is used instead of String to avoid implementing fmt.Stringer interface. If the Type() is not ValueTypeStr then returns empty string.

func (Value) Type added in v0.59.0

func (v Value) Type() ValueType

Type returns the type of the value for this Value. Calling this function on zero-initialized Value will cause a panic.

type ValueType

type ValueType int32

ValueType specifies the type of Value.

const (
	ValueTypeEmpty ValueType = iota
	ValueTypeStr
	ValueTypeInt
	ValueTypeDouble
	ValueTypeBool
	ValueTypeMap
	ValueTypeSlice
	ValueTypeBytes
)

func (ValueType) String added in v0.59.0

func (avt ValueType) String() string

String returns the string representation of the ValueType.

Jump to

Keyboard shortcuts

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