package label

Import Path
	go.opentelemetry.io/otel/label (on go.dev)

Dependency Relation
	imports 11 packages, and imported by 6 packages

Involved Source Files Package label provides key and value labels. encoder.go iterator.go key.go kv.go set.go type_string.go value.go
Package-Level Type Names (total 15, in which 12 are exported)
/* sort exporteds by: | */
Distinct wraps a variable-size array of `KeyValue`, constructed with keys in sorted order. This can be used as a map key or for equality checking between Sets. Valid returns true if this value refers to a valid `*Set`. func (*Set).Equivalent() Distinct
Encoder is a mechanism for serializing a label set into a specific string representation that supports caching, to avoid repeated serialization. An example could be an exporter encoding the label set into a wire representation. Encode returns the serialized encoding of the label set using its Iterator. This result may be cached by a label.Set. ID returns a value that is unique for each class of label encoder. Label encoders allocate these using `NewEncoderID`. func DefaultEncoder() Encoder func (*Set).Encoded(encoder Encoder) string
EncoderID is used to identify distinct Encoder implementations, for caching encoded results. Valid returns true if this encoder ID was allocated by `NewEncoderID`. Invalid encoder IDs will not be cached. func NewEncoderID() EncoderID func Encoder.ID() EncoderID
Filter supports removing certain labels from label sets. When the filter returns true, the label will be kept in the filtered label set. When the filter returns false, the label is excluded from the filtered label set, and the label instead appears in the `removed` list of excluded labels. func NewSetWithFiltered(kvs []KeyValue, filter Filter) (Set, []KeyValue) func NewSetWithSortableFiltered(kvs []KeyValue, tmp *Sortable, filter Filter) (Set, []KeyValue) func (*Set).Filter(re Filter) (Set, []KeyValue)
Iterator allows iterating over the set of labels in order, sorted by key. Attribute is a synonym for Label(). IndexedLabel returns current index and label. Must be called only after Next returns true. Label returns current KeyValue. Must be called only after Next returns true. Len returns a number of labels in the iterator's `*Set`. Next moves the iterator to the next position. Returns false if there are no more labels. ToSlice is a convenience function that creates a slice of labels from the passed iterator. The iterator is set up to start from the beginning before creating the slice. func (*Set).Iter() Iterator func Encoder.Encode(Iterator) 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. Array creates a KeyValue instance with a ARRAY Value. If creating both key and a array value at the same time, then instead of calling Key(name).String(value) consider using a convenience function provided by the api/key package - key.Array(name, value). Bool creates a KeyValue instance with a BOOL Value. If creating both key and a bool value at the same time, then instead of calling Key(name).Bool(value) consider using a convenience function provided by the api/key package - key.Bool(name, value). Defined returns true for non-empty keys. Float32 creates a KeyValue instance with a FLOAT32 Value. If creating both key and a float32 value at the same time, then instead of calling Key(name).Float32(value) consider using a convenience function provided by the api/key package - key.Float32(name, value). Float64 creates a KeyValue instance with a FLOAT64 Value. If creating both key and a float64 value at the same time, then instead of calling Key(name).Float64(value) consider using a convenience function provided by the api/key package - key.Float64(name, value). 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. If creating both key and an int value at the same time, then instead of calling Key(name).Int(value) consider using a convenience function provided by the api/key package - key.Int(name, value). Int32 creates a KeyValue instance with an INT32 Value. If creating both key and an int32 value at the same time, then instead of calling Key(name).Int32(value) consider using a convenience function provided by the api/key package - key.Int32(name, value). Int64 creates a KeyValue instance with an INT64 Value. If creating both key and an int64 value at the same time, then instead of calling Key(name).Int64(value) consider using a convenience function provided by the api/key package - key.Int64(name, value). String creates a KeyValue instance with a STRING Value. If creating both key and a string value at the same time, then instead of calling Key(name).String(value) consider using a convenience function provided by the api/key package - key.String(name, value). Uint creates a KeyValue instance with either a UINT32 or a UINT64 Value, depending on whether the uint type is 32 or 64 bits wide. If creating both key and a uint value at the same time, then instead of calling Key(name).Uint(value) consider using a convenience function provided by the api/key package - key.Uint(name, value). Uint32 creates a KeyValue instance with a UINT32 Value. If creating both key and a uint32 value at the same time, then instead of calling Key(name).Uint32(value) consider using a convenience function provided by the api/key package - key.Uint32(name, value). Uint64 creates a KeyValue instance with a UINT64 Value. If creating both key and a uint64 value at the same time, then instead of calling Key(name).Uint64(value) consider using a convenience function provided by the api/key package - key.Uint64(name, value). func (*Set).HasValue(k Key) bool func (*Set).Value(k Key) (Value, bool) func go.opentelemetry.io/otel/api/correlation.Map.HasValue(k Key) bool func go.opentelemetry.io/otel/api/correlation.Map.Value(k Key) (Value, bool)
KeyValue holds a key and value pair. Key Key Value Value func Any(k string, value interface{}) KeyValue func Array(k string, v interface{}) KeyValue func Bool(k string, v bool) KeyValue func Float32(k string, v float32) KeyValue func Float64(k string, v float64) KeyValue func Int(k string, v int) KeyValue func Int32(k string, v int32) KeyValue func Int64(k string, v int64) KeyValue func NewSetWithFiltered(kvs []KeyValue, filter Filter) (Set, []KeyValue) func NewSetWithSortableFiltered(kvs []KeyValue, tmp *Sortable, filter Filter) (Set, []KeyValue) func String(k, v string) KeyValue func Stringer(k string, v fmt.Stringer) KeyValue func Uint(k string, v uint) KeyValue func Uint32(k string, v uint32) KeyValue func Uint64(k string, v uint64) KeyValue func (*Iterator).Attribute() KeyValue func (*Iterator).IndexedLabel() (int, KeyValue) func (*Iterator).Label() KeyValue func (*Iterator).ToSlice() []KeyValue func Key.Array(v interface{}) KeyValue func Key.Bool(v bool) KeyValue func Key.Float32(v float32) KeyValue func Key.Float64(v float64) KeyValue func Key.Int(v int) KeyValue func Key.Int32(v int32) KeyValue func Key.Int64(v int64) KeyValue func Key.String(v string) KeyValue func Key.Uint(v uint) KeyValue func Key.Uint32(v uint32) KeyValue func Key.Uint64(v uint64) KeyValue func (*MergeItererator).Label() KeyValue func (*Set).Filter(re Filter) (Set, []KeyValue) func (*Set).Get(idx int) (KeyValue, bool) func (*Set).ToSlice() []KeyValue func NewSet(kvs ...KeyValue) Set func NewSetWithFiltered(kvs []KeyValue, filter Filter) (Set, []KeyValue) func NewSetWithSortable(kvs []KeyValue, tmp *Sortable) Set func NewSetWithSortableFiltered(kvs []KeyValue, tmp *Sortable, filter Filter) (Set, []KeyValue) func go.opentelemetry.io/otel/api/correlation.NewContext(ctx context.Context, keyvalues ...KeyValue) context.Context func go.opentelemetry.io/otel/api/metric.BatchObserverResult.Observe(labels []KeyValue, obs ...metric.Observation) func go.opentelemetry.io/otel/api/metric.Float64Counter.Add(ctx context.Context, value float64, labels ...KeyValue) func go.opentelemetry.io/otel/api/metric.Float64Counter.Bind(labels ...KeyValue) (h metric.BoundFloat64Counter) func go.opentelemetry.io/otel/api/metric.Float64ObserverResult.Observe(value float64, labels ...KeyValue) func go.opentelemetry.io/otel/api/metric.Float64UpDownCounter.Add(ctx context.Context, value float64, labels ...KeyValue) func go.opentelemetry.io/otel/api/metric.Float64UpDownCounter.Bind(labels ...KeyValue) (h metric.BoundFloat64UpDownCounter) func go.opentelemetry.io/otel/api/metric.Float64ValueRecorder.Bind(labels ...KeyValue) (h metric.BoundFloat64ValueRecorder) func go.opentelemetry.io/otel/api/metric.Float64ValueRecorder.Record(ctx context.Context, value float64, labels ...KeyValue) func go.opentelemetry.io/otel/api/metric.Int64Counter.Add(ctx context.Context, value int64, labels ...KeyValue) func go.opentelemetry.io/otel/api/metric.Int64Counter.Bind(labels ...KeyValue) (h metric.BoundInt64Counter) func go.opentelemetry.io/otel/api/metric.Int64ObserverResult.Observe(value int64, labels ...KeyValue) func go.opentelemetry.io/otel/api/metric.Int64UpDownCounter.Add(ctx context.Context, value int64, labels ...KeyValue) func go.opentelemetry.io/otel/api/metric.Int64UpDownCounter.Bind(labels ...KeyValue) (h metric.BoundInt64UpDownCounter) func go.opentelemetry.io/otel/api/metric.Int64ValueRecorder.Bind(labels ...KeyValue) (h metric.BoundInt64ValueRecorder) func go.opentelemetry.io/otel/api/metric.Int64ValueRecorder.Record(ctx context.Context, value int64, labels ...KeyValue) func go.opentelemetry.io/otel/api/metric.Meter.RecordBatch(ctx context.Context, ls []KeyValue, ms ...metric.Measurement) func go.opentelemetry.io/otel/api/metric.MeterImpl.RecordBatch(context.Context, []KeyValue, ...metric.Measurement) func go.opentelemetry.io/otel/api/metric.NoopSync.Bind([]KeyValue) metric.BoundSyncImpl func go.opentelemetry.io/otel/api/metric.NoopSync.RecordOne(context.Context, metric.Number, []KeyValue) func go.opentelemetry.io/otel/api/metric.SyncImpl.Bind(labels []KeyValue) metric.BoundSyncImpl func go.opentelemetry.io/otel/api/metric.SyncImpl.RecordOne(ctx context.Context, number metric.Number, labels []KeyValue) func go.opentelemetry.io/otel/api/trace.LinkedTo(sc trace.SpanContext, attrs ...KeyValue) trace.StartOption func go.opentelemetry.io/otel/api/trace.WithAttributes(attrs ...KeyValue) trace.StartOption func go.opentelemetry.io/otel/api/trace.NoopSpan.AddEvent(ctx context.Context, name string, attrs ...KeyValue) func go.opentelemetry.io/otel/api/trace.NoopSpan.AddEventWithTimestamp(ctx context.Context, timestamp time.Time, name string, attrs ...KeyValue) func go.opentelemetry.io/otel/api/trace.NoopSpan.SetAttributes(attributes ...KeyValue) func go.opentelemetry.io/otel/api/trace.Span.AddEvent(ctx context.Context, name string, attrs ...KeyValue) func go.opentelemetry.io/otel/api/trace.Span.AddEventWithTimestamp(ctx context.Context, timestamp time.Time, name string, attrs ...KeyValue) func go.opentelemetry.io/otel/api/trace.Span.SetAttributes(...KeyValue)
MergeIterator supports iterating over two sets of labels while eliminating duplicate values from the combined set. The first iterator value takes precedence. Label returns the current value after Next() returns true. Next returns true if there is another label available. func NewMergeIterator(s1, s2 *Set) MergeItererator
Set is the representation for a distinct label set. It manages an immutable set of labels, with an internal cache for storing label encodings. This type supports the `Equivalent` method of comparison using values of type `Distinct`. This type is used to implement: 1. Metric labels 2. Resource sets 3. Correlation map (TODO) Encoded returns the encoded form of this set, according to `encoder`. The result will be cached in this `*Set`. Equals returns true if the argument set is equivalent to this set. Equivalent returns a value that may be used as a map key. The Distinct type guarantees that the result will equal the equivalent Distinct value of any label set with the same elements as this, where sets are made unique by choosing the last value in the input for any given key. Filter returns a filtered copy of this `Set`. See the documentation for `NewSetWithSortableFiltered` for more details. Get returns the KeyValue at ordered position `idx` in this set. HasValue tests whether a key is defined in this set. Iter returns an iterator for visiting the labels in this set. Len returns the number of labels in this set. MarshalJSON returns the JSON encoding of the `*Set`. ToSlice returns the set of labels belonging to this set, sorted, where keys appear no more than once. Value returns the value of a specified key in this set. *T : encoding/json.Marshaler func EmptySet() *Set func NewSet(kvs ...KeyValue) Set func NewSetWithFiltered(kvs []KeyValue, filter Filter) (Set, []KeyValue) func NewSetWithSortable(kvs []KeyValue, tmp *Sortable) Set func NewSetWithSortableFiltered(kvs []KeyValue, tmp *Sortable, filter Filter) (Set, []KeyValue) func (*Set).Filter(re Filter) (Set, []KeyValue) func NewMergeIterator(s1, s2 *Set) MergeItererator func (*Set).Equals(o *Set) bool
Sortable implements `sort.Interface`, used for sorting `KeyValue`. This is an exported type to support a memory optimization. A pointer to one of these is needed for the call to `sort.Stable()`, which the caller may provide in order to avoid an allocation. See `NewSetWithSortable()`. Len implements `sort.Interface`. Less implements `sort.Interface`. Swap implements `sort.Interface`. *T : sort.Interface func NewSetWithSortable(kvs []KeyValue, tmp *Sortable) Set func NewSetWithSortableFiltered(kvs []KeyValue, tmp *Sortable, filter Filter) (Set, []KeyValue)
Type describes the type of the data Value holds. ( T) String() string T : expvar.Var T : fmt.Stringer func Value.Type() Type const ARRAY const BOOL const FLOAT32 const FLOAT64 const INT32 const INT64 const INVALID const STRING const UINT32 const UINT64
Value represents the value part in key-value pairs. AsArray returns the array Value as an interface{}. AsBool returns the bool value. Make sure that the Value's type is BOOL. AsFloat32 returns the float32 value. Make sure that the Value's type is FLOAT32. AsFloat64 returns the float64 value. Make sure that the Value's type is FLOAT64. AsInt32 returns the int32 value. Make sure that the Value's type is INT32. AsInt64 returns the int64 value. Make sure that the Value's type is INT64. AsInterface returns Value's data as interface{}. AsString returns the string value. Make sure that the Value's type is STRING. AsUint32 returns the uint32 value. Make sure that the Value's type is UINT32. AsUint64 returns the uint64 value. Make sure that the Value's type is UINT64. Emit returns a string representation of Value's data. MarshalJSON returns the JSON encoding of the Value. Type returns a type of the Value. T : encoding/json.Marshaler func ArrayValue(array interface{}) Value func BoolValue(v bool) Value func Float32Value(v float32) Value func Float64Value(v float64) Value func Int32Value(v int32) Value func Int64Value(v int64) Value func IntValue(v int) Value func StringValue(v string) Value func Uint32Value(v uint32) Value func Uint64Value(v uint64) Value func UintValue(v uint) Value func (*Set).Value(k Key) (Value, bool) func go.opentelemetry.io/otel/api/correlation.Map.Value(k Key) (Value, bool)
Package-Level Functions (total 39, in which 32 are exported)
Any creates a new key-value pair instance with a passed name and automatic type inference. This is slower, and not type-safe.
Array creates a new key-value pair with a passed name and a array. Only arrays of primitive type are supported.
Array creates an ARRAY value.
Bool creates a new key-value pair with a passed name and a bool value.
BoolValue creates a BOOL Value.
DefaultEncoder returns a label encoder that encodes labels in such a way that each escaped label's key is followed by an equal sign and then by an escaped label's value. All key-value pairs are separated by a comma. Escaping is done by prepending a backslash before either a backslash, equal sign or a comma.
Float32 creates a new key-value pair with a passed name and a float32 value.
Float32 creates a FLOAT32 Value.
Float64 creates a new key-value pair with a passed name and a float64 value.
Float64Value creates a FLOAT64 Value.
Int creates a new key-value pair instance with a passed name and either an int32 or an int64 value, depending on whether the int type is 32 or 64 bits wide.
Int32 creates a new key-value pair with a passed name and an int32 value.
Int32Value creates an INT32 Value.
Int64 creates a new key-value pair with a passed name and an int64 value.
Int64Value creates an INT64 Value.
Int creates either an INT32 or an INT64 Value, depending on whether the int type is 32 or 64 bits wide.
NewEncoderID returns a unique label encoder ID. It should be called once per each type of label encoder. Preferably in init() or in var definition.
NewMergeIterator returns a MergeIterator for merging two label sets Duplicates are resolved by taking the value from the first set.
NewSet returns a new `Set`. See the documentation for `NewSetWithSortableFiltered` for more details. Except for empty sets, this method adds an additional allocation compared with calls that include a `*Sortable`.
NewSetWithFiltered returns a new `Set`. See the documentation for `NewSetWithSortableFiltered` for more details. This call includes a `Filter` to include/exclude label keys from the return value. Excluded keys are returned as a slice of label values.
NewSetWithSortable returns a new `Set`. See the documentation for `NewSetWithSortableFiltered` for more details. This call includes a `*Sortable` option as a memory optimization.
NewSetWithSortableFiltered returns a new `Set`. Duplicate keys are eliminated by taking the last value. This re-orders the input slice so that unique last-values are contiguous at the end of the slice. This ensures the following: - Last-value-wins semantics - Caller sees the reordering, but doesn't lose values - Repeated call preserve last-value wins. Note that methods are defined on `*Set`, although this returns `Set`. Callers can avoid memory allocations by: - allocating a `Sortable` for use as a temporary in this method - allocating a `Set` for storing the return value of this constructor. The result maintains a cache of encoded labels, by label.EncoderID. This value should not be copied after its first use. The second `[]KeyValue` return value is a list of labels that were excluded by the Filter (if non-nil).
String creates a new key-value pair with a passed name and a string value.
Stringer creates a new key-value pair with a passed name and a string value generated by the passed Stringer interface.
String creates a STRING Value.
Uint creates a new key-value pair instance with a passed name and either an uint32 or an uint64 value, depending on whether the uint type is 32 or 64 bits wide.
Uint32 creates a new key-value pair with a passed name and a uint32 value.
Uint32 creates a UINT32 Value.
Uint64 creates a new key-value pair with a passed name and a uint64 value.
Uint64Value creates a UINT64 Value.
Uint creates either a UINT32 or a UINT64 Value, depending on whether the uint type is 32 or 64 bits wide.
Package-Level Variables (total 7, none are exported)
Package-Level Constants (total 13, in which 10 are exported)
const ARRAY Type = 9 // Array value of arbitrary type, use AsArray() to get it.
const BOOL Type = 1 // Boolean value, use AsBool() to get it.
const FLOAT32 Type = 6 // 32 bit floating point value, use AsFloat32() to get it.
const FLOAT64 Type = 7 // 64 bit floating point value, use AsFloat64() to get it.
const INT32 Type = 2 // 32 bit signed integral value, use AsInt32() to get it.
const INT64 Type = 3 // 64 bit signed integral value, use AsInt64() to get it.
const INVALID Type = 0 // No value.
const STRING Type = 8 // String value, use AsString() to get it.
const UINT32 Type = 4 // 32 bit unsigned integral value, use AsUint32() to get it.
const UINT64 Type = 5 // 64 bit unsigned integral value, use AsUint64() to get it.