chore: upgrade dependencies
This commit is contained in:
		
							
								
								
									
										82
									
								
								vendor/go.opentelemetry.io/otel/attribute/encoder.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										82
									
								
								vendor/go.opentelemetry.io/otel/attribute/encoder.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -21,19 +21,17 @@ import (
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type (
 | 
			
		||||
	// 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.
 | 
			
		||||
	// Encoder is a mechanism for serializing an attribute set into a specific
 | 
			
		||||
	// string representation that supports caching, to avoid repeated
 | 
			
		||||
	// serialization. An example could be an exporter encoding the attribute
 | 
			
		||||
	// set into a wire representation.
 | 
			
		||||
	Encoder interface {
 | 
			
		||||
		// Encode returns the serialized encoding of the label
 | 
			
		||||
		// set using its Iterator.  This result may be cached
 | 
			
		||||
		// by a attribute.Set.
 | 
			
		||||
		// Encode returns the serialized encoding of the attribute set using
 | 
			
		||||
		// its Iterator. This result may be cached by a attribute.Set.
 | 
			
		||||
		Encode(iterator Iterator) string
 | 
			
		||||
 | 
			
		||||
		// ID returns a value that is unique for each class of
 | 
			
		||||
		// label encoder.  Label encoders allocate these using
 | 
			
		||||
		// `NewEncoderID`.
 | 
			
		||||
		// ID returns a value that is unique for each class of attribute
 | 
			
		||||
		// encoder. Attribute encoders allocate these using `NewEncoderID`.
 | 
			
		||||
		ID() EncoderID
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -43,54 +41,53 @@ type (
 | 
			
		||||
		value uint64
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// defaultLabelEncoder uses a sync.Pool of buffers to reduce
 | 
			
		||||
	// the number of allocations used in encoding labels.  This
 | 
			
		||||
	// implementation encodes a comma-separated list of key=value,
 | 
			
		||||
	// with '/'-escaping of '=', ',', and '\'.
 | 
			
		||||
	defaultLabelEncoder struct {
 | 
			
		||||
		// pool is a pool of labelset builders.  The buffers in this
 | 
			
		||||
		// pool grow to a size that most label encodings will not
 | 
			
		||||
		// allocate new memory.
 | 
			
		||||
	// defaultAttrEncoder uses a sync.Pool of buffers to reduce the number of
 | 
			
		||||
	// allocations used in encoding attributes. This implementation encodes a
 | 
			
		||||
	// comma-separated list of key=value, with '/'-escaping of '=', ',', and
 | 
			
		||||
	// '\'.
 | 
			
		||||
	defaultAttrEncoder struct {
 | 
			
		||||
		// pool is a pool of attribute set builders. The buffers in this pool
 | 
			
		||||
		// grow to a size that most attribute encodings will not allocate new
 | 
			
		||||
		// memory.
 | 
			
		||||
		pool sync.Pool // *bytes.Buffer
 | 
			
		||||
	}
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// escapeChar is used to ensure uniqueness of the label encoding where
 | 
			
		||||
// keys or values contain either '=' or ','.  Since there is no parser
 | 
			
		||||
// needed for this encoding and its only requirement is to be unique,
 | 
			
		||||
// this choice is arbitrary.  Users will see these in some exporters
 | 
			
		||||
// (e.g., stdout), so the backslash ('\') is used as a conventional choice.
 | 
			
		||||
// escapeChar is used to ensure uniqueness of the attribute encoding where
 | 
			
		||||
// keys or values contain either '=' or ','.  Since there is no parser needed
 | 
			
		||||
// for this encoding and its only requirement is to be unique, this choice is
 | 
			
		||||
// arbitrary.  Users will see these in some exporters (e.g., stdout), so the
 | 
			
		||||
// backslash ('\') is used as a conventional choice.
 | 
			
		||||
const escapeChar = '\\'
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	_ Encoder = &defaultLabelEncoder{}
 | 
			
		||||
	_ Encoder = &defaultAttrEncoder{}
 | 
			
		||||
 | 
			
		||||
	// encoderIDCounter is for generating IDs for other label
 | 
			
		||||
	// encoders.
 | 
			
		||||
	// encoderIDCounter is for generating IDs for other attribute encoders.
 | 
			
		||||
	encoderIDCounter uint64
 | 
			
		||||
 | 
			
		||||
	defaultEncoderOnce     sync.Once
 | 
			
		||||
	defaultEncoderID       = NewEncoderID()
 | 
			
		||||
	defaultEncoderInstance *defaultLabelEncoder
 | 
			
		||||
	defaultEncoderInstance *defaultAttrEncoder
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// 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.
 | 
			
		||||
// NewEncoderID returns a unique attribute encoder ID. It should be called
 | 
			
		||||
// once per each type of attribute encoder. Preferably in init() or in var
 | 
			
		||||
// definition.
 | 
			
		||||
func NewEncoderID() EncoderID {
 | 
			
		||||
	return EncoderID{value: atomic.AddUint64(&encoderIDCounter, 1)}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 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.
 | 
			
		||||
// DefaultEncoder returns an attribute encoder that encodes attributes in such
 | 
			
		||||
// a way that each escaped attribute's key is followed by an equal sign and
 | 
			
		||||
// then by an escaped attribute'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.
 | 
			
		||||
// Escaping is done by prepending a backslash before either a backslash, equal
 | 
			
		||||
// sign or a comma.
 | 
			
		||||
func DefaultEncoder() Encoder {
 | 
			
		||||
	defaultEncoderOnce.Do(func() {
 | 
			
		||||
		defaultEncoderInstance = &defaultLabelEncoder{
 | 
			
		||||
		defaultEncoderInstance = &defaultAttrEncoder{
 | 
			
		||||
			pool: sync.Pool{
 | 
			
		||||
				New: func() interface{} {
 | 
			
		||||
					return &bytes.Buffer{}
 | 
			
		||||
@@ -101,15 +98,14 @@ func DefaultEncoder() Encoder {
 | 
			
		||||
	return defaultEncoderInstance
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Encode is a part of an implementation of the LabelEncoder
 | 
			
		||||
// interface.
 | 
			
		||||
func (d *defaultLabelEncoder) Encode(iter Iterator) string {
 | 
			
		||||
// Encode is a part of an implementation of the AttributeEncoder interface.
 | 
			
		||||
func (d *defaultAttrEncoder) Encode(iter Iterator) string {
 | 
			
		||||
	buf := d.pool.Get().(*bytes.Buffer)
 | 
			
		||||
	defer d.pool.Put(buf)
 | 
			
		||||
	buf.Reset()
 | 
			
		||||
 | 
			
		||||
	for iter.Next() {
 | 
			
		||||
		i, keyValue := iter.IndexedLabel()
 | 
			
		||||
		i, keyValue := iter.IndexedAttribute()
 | 
			
		||||
		if i > 0 {
 | 
			
		||||
			_, _ = buf.WriteRune(',')
 | 
			
		||||
		}
 | 
			
		||||
@@ -126,8 +122,8 @@ func (d *defaultLabelEncoder) Encode(iter Iterator) string {
 | 
			
		||||
	return buf.String()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ID is a part of an implementation of the LabelEncoder interface.
 | 
			
		||||
func (*defaultLabelEncoder) ID() EncoderID {
 | 
			
		||||
// ID is a part of an implementation of the AttributeEncoder interface.
 | 
			
		||||
func (*defaultAttrEncoder) ID() EncoderID {
 | 
			
		||||
	return defaultEncoderID
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										80
									
								
								vendor/go.opentelemetry.io/otel/attribute/iterator.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										80
									
								
								vendor/go.opentelemetry.io/otel/attribute/iterator.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -14,16 +14,16 @@
 | 
			
		||||
 | 
			
		||||
package attribute // import "go.opentelemetry.io/otel/attribute"
 | 
			
		||||
 | 
			
		||||
// Iterator allows iterating over the set of labels in order,
 | 
			
		||||
// sorted by key.
 | 
			
		||||
// Iterator allows iterating over the set of attributes in order, sorted by
 | 
			
		||||
// key.
 | 
			
		||||
type Iterator struct {
 | 
			
		||||
	storage *Set
 | 
			
		||||
	idx     int
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MergeIterator supports iterating over two sets of labels while
 | 
			
		||||
// eliminating duplicate values from the combined set.  The first
 | 
			
		||||
// iterator value takes precedence.
 | 
			
		||||
// MergeIterator supports iterating over two sets of attributes while
 | 
			
		||||
// eliminating duplicate values from the combined set. The first iterator
 | 
			
		||||
// value takes precedence.
 | 
			
		||||
type MergeIterator struct {
 | 
			
		||||
	one     oneIterator
 | 
			
		||||
	two     oneIterator
 | 
			
		||||
@@ -31,13 +31,13 @@ type MergeIterator struct {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type oneIterator struct {
 | 
			
		||||
	iter  Iterator
 | 
			
		||||
	done  bool
 | 
			
		||||
	label KeyValue
 | 
			
		||||
	iter Iterator
 | 
			
		||||
	done bool
 | 
			
		||||
	attr KeyValue
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Next moves the iterator to the next position. Returns false if there
 | 
			
		||||
// are no more labels.
 | 
			
		||||
// Next moves the iterator to the next position. Returns false if there are no
 | 
			
		||||
// more attributes.
 | 
			
		||||
func (i *Iterator) Next() bool {
 | 
			
		||||
	i.idx++
 | 
			
		||||
	return i.idx < i.Len()
 | 
			
		||||
@@ -45,30 +45,41 @@ func (i *Iterator) Next() bool {
 | 
			
		||||
 | 
			
		||||
// Label returns current KeyValue. Must be called only after Next returns
 | 
			
		||||
// true.
 | 
			
		||||
//
 | 
			
		||||
// Deprecated: Use Attribute instead.
 | 
			
		||||
func (i *Iterator) Label() KeyValue {
 | 
			
		||||
	return i.Attribute()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Attribute returns the current KeyValue of the Iterator. It must be called
 | 
			
		||||
// only after Next returns true.
 | 
			
		||||
func (i *Iterator) Attribute() KeyValue {
 | 
			
		||||
	kv, _ := i.storage.Get(i.idx)
 | 
			
		||||
	return kv
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Attribute is a synonym for Label().
 | 
			
		||||
func (i *Iterator) Attribute() KeyValue {
 | 
			
		||||
	return i.Label()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IndexedLabel returns current index and attribute. Must be called only
 | 
			
		||||
// after Next returns true.
 | 
			
		||||
//
 | 
			
		||||
// Deprecated: Use IndexedAttribute instead.
 | 
			
		||||
func (i *Iterator) IndexedLabel() (int, KeyValue) {
 | 
			
		||||
	return i.idx, i.Label()
 | 
			
		||||
	return i.idx, i.Attribute()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Len returns a number of labels in the iterator's `*Set`.
 | 
			
		||||
// IndexedAttribute returns current index and attribute. Must be called only
 | 
			
		||||
// after Next returns true.
 | 
			
		||||
func (i *Iterator) IndexedAttribute() (int, KeyValue) {
 | 
			
		||||
	return i.idx, i.Attribute()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Len returns a number of attributes in the iterated set.
 | 
			
		||||
func (i *Iterator) Len() int {
 | 
			
		||||
	return i.storage.Len()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 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.
 | 
			
		||||
// ToSlice is a convenience function that creates a slice of attributes from
 | 
			
		||||
// the passed iterator. The iterator is set up to start from the beginning
 | 
			
		||||
// before creating the slice.
 | 
			
		||||
func (i *Iterator) ToSlice() []KeyValue {
 | 
			
		||||
	l := i.Len()
 | 
			
		||||
	if l == 0 {
 | 
			
		||||
@@ -77,12 +88,12 @@ func (i *Iterator) ToSlice() []KeyValue {
 | 
			
		||||
	i.idx = -1
 | 
			
		||||
	slice := make([]KeyValue, 0, l)
 | 
			
		||||
	for i.Next() {
 | 
			
		||||
		slice = append(slice, i.Label())
 | 
			
		||||
		slice = append(slice, i.Attribute())
 | 
			
		||||
	}
 | 
			
		||||
	return slice
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NewMergeIterator returns a MergeIterator for merging two label sets
 | 
			
		||||
// NewMergeIterator returns a MergeIterator for merging two attribute sets.
 | 
			
		||||
// Duplicates are resolved by taking the value from the first set.
 | 
			
		||||
func NewMergeIterator(s1, s2 *Set) MergeIterator {
 | 
			
		||||
	mi := MergeIterator{
 | 
			
		||||
@@ -102,42 +113,49 @@ func makeOne(iter Iterator) oneIterator {
 | 
			
		||||
 | 
			
		||||
func (oi *oneIterator) advance() {
 | 
			
		||||
	if oi.done = !oi.iter.Next(); !oi.done {
 | 
			
		||||
		oi.label = oi.iter.Label()
 | 
			
		||||
		oi.attr = oi.iter.Attribute()
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Next returns true if there is another label available.
 | 
			
		||||
// Next returns true if there is another attribute available.
 | 
			
		||||
func (m *MergeIterator) Next() bool {
 | 
			
		||||
	if m.one.done && m.two.done {
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
	if m.one.done {
 | 
			
		||||
		m.current = m.two.label
 | 
			
		||||
		m.current = m.two.attr
 | 
			
		||||
		m.two.advance()
 | 
			
		||||
		return true
 | 
			
		||||
	}
 | 
			
		||||
	if m.two.done {
 | 
			
		||||
		m.current = m.one.label
 | 
			
		||||
		m.current = m.one.attr
 | 
			
		||||
		m.one.advance()
 | 
			
		||||
		return true
 | 
			
		||||
	}
 | 
			
		||||
	if m.one.label.Key == m.two.label.Key {
 | 
			
		||||
		m.current = m.one.label // first iterator label value wins
 | 
			
		||||
	if m.one.attr.Key == m.two.attr.Key {
 | 
			
		||||
		m.current = m.one.attr // first iterator attribute value wins
 | 
			
		||||
		m.one.advance()
 | 
			
		||||
		m.two.advance()
 | 
			
		||||
		return true
 | 
			
		||||
	}
 | 
			
		||||
	if m.one.label.Key < m.two.label.Key {
 | 
			
		||||
		m.current = m.one.label
 | 
			
		||||
	if m.one.attr.Key < m.two.attr.Key {
 | 
			
		||||
		m.current = m.one.attr
 | 
			
		||||
		m.one.advance()
 | 
			
		||||
		return true
 | 
			
		||||
	}
 | 
			
		||||
	m.current = m.two.label
 | 
			
		||||
	m.current = m.two.attr
 | 
			
		||||
	m.two.advance()
 | 
			
		||||
	return true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Label returns the current value after Next() returns true.
 | 
			
		||||
//
 | 
			
		||||
// Deprecated: Use Attribute instead.
 | 
			
		||||
func (m *MergeIterator) Label() KeyValue {
 | 
			
		||||
	return m.current
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Attribute returns the current value after Next() returns true.
 | 
			
		||||
func (m *MergeIterator) Attribute() KeyValue {
 | 
			
		||||
	return m.current
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								vendor/go.opentelemetry.io/otel/attribute/kv.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/go.opentelemetry.io/otel/attribute/kv.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -26,7 +26,7 @@ type KeyValue struct {
 | 
			
		||||
 | 
			
		||||
// Valid returns if kv is a valid OpenTelemetry attribute.
 | 
			
		||||
func (kv KeyValue) Valid() bool {
 | 
			
		||||
	return kv.Key != "" && kv.Value.Type() != INVALID
 | 
			
		||||
	return kv.Key.Defined() && kv.Value.Type() != INVALID
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Bool creates a KeyValue with a BOOL Value type.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										152
									
								
								vendor/go.opentelemetry.io/otel/attribute/set.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										152
									
								
								vendor/go.opentelemetry.io/otel/attribute/set.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -21,49 +21,42 @@ import (
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type (
 | 
			
		||||
	// Set is the representation for a distinct label set.  It
 | 
			
		||||
	// manages an immutable set of labels, with an internal cache
 | 
			
		||||
	// for storing label encodings.
 | 
			
		||||
	// Set is the representation for a distinct attribute set. It manages an
 | 
			
		||||
	// immutable set of attributes, with an internal cache for storing
 | 
			
		||||
	// attribute 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)
 | 
			
		||||
	// This type supports the Equivalent method of comparison using values of
 | 
			
		||||
	// type Distinct.
 | 
			
		||||
	Set struct {
 | 
			
		||||
		equivalent Distinct
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 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.
 | 
			
		||||
	// 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.
 | 
			
		||||
	Distinct struct {
 | 
			
		||||
		iface interface{}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 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.
 | 
			
		||||
	// Filter supports removing certain attributes from attribute sets. When
 | 
			
		||||
	// the filter returns true, the attribute will be kept in the filtered
 | 
			
		||||
	// attribute set. When the filter returns false, the attribute is excluded
 | 
			
		||||
	// from the filtered attribute set, and the attribute instead appears in
 | 
			
		||||
	// the removed list of excluded attributes.
 | 
			
		||||
	Filter func(KeyValue) 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()`.
 | 
			
		||||
	// 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().
 | 
			
		||||
	Sortable []KeyValue
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	// keyValueType is used in `computeDistinctReflect`.
 | 
			
		||||
	// keyValueType is used in computeDistinctReflect.
 | 
			
		||||
	keyValueType = reflect.TypeOf(KeyValue{})
 | 
			
		||||
 | 
			
		||||
	// emptySet is returned for empty label sets.
 | 
			
		||||
	// emptySet is returned for empty attribute sets.
 | 
			
		||||
	emptySet = &Set{
 | 
			
		||||
		equivalent: Distinct{
 | 
			
		||||
			iface: [0]KeyValue{},
 | 
			
		||||
@@ -78,17 +71,17 @@ func EmptySet() *Set {
 | 
			
		||||
	return emptySet
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// reflect abbreviates `reflect.ValueOf`.
 | 
			
		||||
// reflect abbreviates reflect.ValueOf.
 | 
			
		||||
func (d Distinct) reflect() reflect.Value {
 | 
			
		||||
	return reflect.ValueOf(d.iface)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Valid returns true if this value refers to a valid `*Set`.
 | 
			
		||||
// Valid returns true if this value refers to a valid Set.
 | 
			
		||||
func (d Distinct) Valid() bool {
 | 
			
		||||
	return d.iface != nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Len returns the number of labels in this set.
 | 
			
		||||
// Len returns the number of attributes in this set.
 | 
			
		||||
func (l *Set) Len() int {
 | 
			
		||||
	if l == nil || !l.equivalent.Valid() {
 | 
			
		||||
		return 0
 | 
			
		||||
@@ -96,7 +89,7 @@ func (l *Set) Len() int {
 | 
			
		||||
	return l.equivalent.reflect().Len()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Get returns the KeyValue at ordered position `idx` in this set.
 | 
			
		||||
// Get returns the KeyValue at ordered position idx in this set.
 | 
			
		||||
func (l *Set) Get(idx int) (KeyValue, bool) {
 | 
			
		||||
	if l == nil {
 | 
			
		||||
		return KeyValue{}, false
 | 
			
		||||
@@ -142,7 +135,7 @@ func (l *Set) HasValue(k Key) bool {
 | 
			
		||||
	return ok
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Iter returns an iterator for visiting the labels in this set.
 | 
			
		||||
// Iter returns an iterator for visiting the attributes in this set.
 | 
			
		||||
func (l *Set) Iter() Iterator {
 | 
			
		||||
	return Iterator{
 | 
			
		||||
		storage: l,
 | 
			
		||||
@@ -150,18 +143,17 @@ func (l *Set) Iter() Iterator {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ToSlice returns the set of labels belonging to this set, sorted,
 | 
			
		||||
// where keys appear no more than once.
 | 
			
		||||
// ToSlice returns the set of attributes belonging to this set, sorted, where
 | 
			
		||||
// keys appear no more than once.
 | 
			
		||||
func (l *Set) ToSlice() []KeyValue {
 | 
			
		||||
	iter := l.Iter()
 | 
			
		||||
	return iter.ToSlice()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 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.
 | 
			
		||||
// 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
 | 
			
		||||
// attribute set with the same elements as this, where sets are made unique by
 | 
			
		||||
// choosing the last value in the input for any given key.
 | 
			
		||||
func (l *Set) Equivalent() Distinct {
 | 
			
		||||
	if l == nil || !l.equivalent.Valid() {
 | 
			
		||||
		return emptySet.equivalent
 | 
			
		||||
@@ -174,8 +166,7 @@ func (l *Set) Equals(o *Set) bool {
 | 
			
		||||
	return l.Equivalent() == o.Equivalent()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Encoded returns the encoded form of this set, according to
 | 
			
		||||
// `encoder`.
 | 
			
		||||
// Encoded returns the encoded form of this set, according to encoder.
 | 
			
		||||
func (l *Set) Encoded(encoder Encoder) string {
 | 
			
		||||
	if l == nil || encoder == nil {
 | 
			
		||||
		return ""
 | 
			
		||||
@@ -190,11 +181,11 @@ func empty() Set {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NewSet returns a new `Set`.  See the documentation for
 | 
			
		||||
// `NewSetWithSortableFiltered` for more details.
 | 
			
		||||
// 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`.
 | 
			
		||||
// Except for empty sets, this method adds an additional allocation compared
 | 
			
		||||
// with calls that include a Sortable.
 | 
			
		||||
func NewSet(kvs ...KeyValue) Set {
 | 
			
		||||
	// Check for empty set.
 | 
			
		||||
	if len(kvs) == 0 {
 | 
			
		||||
@@ -204,10 +195,10 @@ func NewSet(kvs ...KeyValue) Set {
 | 
			
		||||
	return s
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NewSetWithSortable returns a new `Set`.  See the documentation for
 | 
			
		||||
// `NewSetWithSortableFiltered` for more details.
 | 
			
		||||
// NewSetWithSortable returns a new Set. See the documentation for
 | 
			
		||||
// NewSetWithSortableFiltered for more details.
 | 
			
		||||
//
 | 
			
		||||
// This call includes a `*Sortable` option as a memory optimization.
 | 
			
		||||
// This call includes a Sortable option as a memory optimization.
 | 
			
		||||
func NewSetWithSortable(kvs []KeyValue, tmp *Sortable) Set {
 | 
			
		||||
	// Check for empty set.
 | 
			
		||||
	if len(kvs) == 0 {
 | 
			
		||||
@@ -217,12 +208,11 @@ func NewSetWithSortable(kvs []KeyValue, tmp *Sortable) Set {
 | 
			
		||||
	return s
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NewSetWithFiltered returns a new `Set`.  See the documentation for
 | 
			
		||||
// `NewSetWithSortableFiltered` for more details.
 | 
			
		||||
// 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.
 | 
			
		||||
// This call includes a Filter to include/exclude attribute keys from the
 | 
			
		||||
// return value. Excluded keys are returned as a slice of attribute values.
 | 
			
		||||
func NewSetWithFiltered(kvs []KeyValue, filter Filter) (Set, []KeyValue) {
 | 
			
		||||
	// Check for empty set.
 | 
			
		||||
	if len(kvs) == 0 {
 | 
			
		||||
@@ -231,7 +221,7 @@ func NewSetWithFiltered(kvs []KeyValue, filter Filter) (Set, []KeyValue) {
 | 
			
		||||
	return NewSetWithSortableFiltered(kvs, new(Sortable), filter)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NewSetWithSortableFiltered returns a new `Set`.
 | 
			
		||||
// 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
 | 
			
		||||
@@ -243,17 +233,16 @@ func NewSetWithFiltered(kvs []KeyValue, filter Filter) (Set, []KeyValue) {
 | 
			
		||||
// - 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:
 | 
			
		||||
// 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.
 | 
			
		||||
// - 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 attribute.EncoderID.
 | 
			
		||||
// The result maintains a cache of encoded attributes, by attribute.EncoderID.
 | 
			
		||||
// This value should not be copied after its first use.
 | 
			
		||||
//
 | 
			
		||||
// The second `[]KeyValue` return value is a list of labels that were
 | 
			
		||||
// The second []KeyValue return value is a list of attributes that were
 | 
			
		||||
// excluded by the Filter (if non-nil).
 | 
			
		||||
func NewSetWithSortableFiltered(kvs []KeyValue, tmp *Sortable, filter Filter) (Set, []KeyValue) {
 | 
			
		||||
	// Check for empty set.
 | 
			
		||||
@@ -293,13 +282,13 @@ func NewSetWithSortableFiltered(kvs []KeyValue, tmp *Sortable, filter Filter) (S
 | 
			
		||||
	}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// filterSet reorders `kvs` so that included keys are contiguous at
 | 
			
		||||
// the end of the slice, while excluded keys precede the included keys.
 | 
			
		||||
// filterSet reorders kvs so that included keys are contiguous at the end of
 | 
			
		||||
// the slice, while excluded keys precede the included keys.
 | 
			
		||||
func filterSet(kvs []KeyValue, filter Filter) (Set, []KeyValue) {
 | 
			
		||||
	var excluded []KeyValue
 | 
			
		||||
 | 
			
		||||
	// Move labels that do not match the filter so
 | 
			
		||||
	// they're adjacent before calling computeDistinct().
 | 
			
		||||
	// Move attributes that do not match the filter so they're adjacent before
 | 
			
		||||
	// calling computeDistinct().
 | 
			
		||||
	distinctPosition := len(kvs)
 | 
			
		||||
 | 
			
		||||
	// Swap indistinct keys forward and distinct keys toward the
 | 
			
		||||
@@ -319,8 +308,8 @@ func filterSet(kvs []KeyValue, filter Filter) (Set, []KeyValue) {
 | 
			
		||||
	}, excluded
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Filter returns a filtered copy of this `Set`.  See the
 | 
			
		||||
// documentation for `NewSetWithSortableFiltered` for more details.
 | 
			
		||||
// Filter returns a filtered copy of this Set. See the documentation for
 | 
			
		||||
// NewSetWithSortableFiltered for more details.
 | 
			
		||||
func (l *Set) Filter(re Filter) (Set, []KeyValue) {
 | 
			
		||||
	if re == nil {
 | 
			
		||||
		return Set{
 | 
			
		||||
@@ -333,9 +322,9 @@ func (l *Set) Filter(re Filter) (Set, []KeyValue) {
 | 
			
		||||
	return filterSet(l.ToSlice(), re)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// computeDistinct returns a `Distinct` using either the fixed- or
 | 
			
		||||
// reflect-oriented code path, depending on the size of the input.
 | 
			
		||||
// The input slice is assumed to already be sorted and de-duplicated.
 | 
			
		||||
// computeDistinct returns a Distinct using either the fixed- or
 | 
			
		||||
// reflect-oriented code path, depending on the size of the input. The input
 | 
			
		||||
// slice is assumed to already be sorted and de-duplicated.
 | 
			
		||||
func computeDistinct(kvs []KeyValue) Distinct {
 | 
			
		||||
	iface := computeDistinctFixed(kvs)
 | 
			
		||||
	if iface == nil {
 | 
			
		||||
@@ -346,8 +335,8 @@ func computeDistinct(kvs []KeyValue) Distinct {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// computeDistinctFixed computes a `Distinct` for small slices.  It
 | 
			
		||||
// returns nil if the input is too large for this code path.
 | 
			
		||||
// computeDistinctFixed computes a Distinct for small slices. It returns nil
 | 
			
		||||
// if the input is too large for this code path.
 | 
			
		||||
func computeDistinctFixed(kvs []KeyValue) interface{} {
 | 
			
		||||
	switch len(kvs) {
 | 
			
		||||
	case 1:
 | 
			
		||||
@@ -395,8 +384,8 @@ func computeDistinctFixed(kvs []KeyValue) interface{} {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// computeDistinctReflect computes a `Distinct` using reflection,
 | 
			
		||||
// works for any size input.
 | 
			
		||||
// computeDistinctReflect computes a Distinct using reflection, works for any
 | 
			
		||||
// size input.
 | 
			
		||||
func computeDistinctReflect(kvs []KeyValue) interface{} {
 | 
			
		||||
	at := reflect.New(reflect.ArrayOf(len(kvs), keyValueType)).Elem()
 | 
			
		||||
	for i, keyValue := range kvs {
 | 
			
		||||
@@ -405,22 +394,31 @@ func computeDistinctReflect(kvs []KeyValue) interface{} {
 | 
			
		||||
	return at.Interface()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MarshalJSON returns the JSON encoding of the `*Set`.
 | 
			
		||||
// MarshalJSON returns the JSON encoding of the Set.
 | 
			
		||||
func (l *Set) MarshalJSON() ([]byte, error) {
 | 
			
		||||
	return json.Marshal(l.equivalent.iface)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Len implements `sort.Interface`.
 | 
			
		||||
// MarshalLog is the marshaling function used by the logging system to represent this exporter.
 | 
			
		||||
func (l Set) MarshalLog() interface{} {
 | 
			
		||||
	kvs := make(map[string]string)
 | 
			
		||||
	for _, kv := range l.ToSlice() {
 | 
			
		||||
		kvs[string(kv.Key)] = kv.Value.Emit()
 | 
			
		||||
	}
 | 
			
		||||
	return kvs
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Len implements sort.Interface.
 | 
			
		||||
func (l *Sortable) Len() int {
 | 
			
		||||
	return len(*l)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Swap implements `sort.Interface`.
 | 
			
		||||
// Swap implements sort.Interface.
 | 
			
		||||
func (l *Sortable) Swap(i, j int) {
 | 
			
		||||
	(*l)[i], (*l)[j] = (*l)[j], (*l)[i]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Less implements `sort.Interface`.
 | 
			
		||||
// Less implements sort.Interface.
 | 
			
		||||
func (l *Sortable) Less(i, j int) bool {
 | 
			
		||||
	return (*l)[i].Key < (*l)[j].Key
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										4
									
								
								vendor/go.opentelemetry.io/otel/attribute/value.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/go.opentelemetry.io/otel/attribute/value.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -187,7 +187,7 @@ func (v Value) AsFloat64() float64 {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// AsFloat64Slice returns the []float64 value. Make sure that the Value's type is
 | 
			
		||||
// INT64SLICE.
 | 
			
		||||
// FLOAT64SLICE.
 | 
			
		||||
func (v Value) AsFloat64Slice() []float64 {
 | 
			
		||||
	if s, ok := v.slice.(*[]float64); ok {
 | 
			
		||||
		return *s
 | 
			
		||||
@@ -202,7 +202,7 @@ func (v Value) AsString() string {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// AsStringSlice returns the []string value. Make sure that the Value's type is
 | 
			
		||||
// INT64SLICE.
 | 
			
		||||
// STRINGSLICE.
 | 
			
		||||
func (v Value) AsStringSlice() []string {
 | 
			
		||||
	if s, ok := v.slice.(*[]string); ok {
 | 
			
		||||
		return *s
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user