package attribute

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

Dependency Relation
	imports 10 packages, and imported by 2 packages

Involved Source Files Package attribute provides key and value attributes. encoder.go filter.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 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. Encode returns the serialized encoding of the attribute set using its Iterator. This result may be cached by a attribute.Set. ID returns a value that is unique for each class of attribute encoder. Attribute 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 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. func NewAllowKeysFilter(keys ...Key) Filter func NewDenyKeysFilter(keys ...Key) Filter 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 attributes in order, sorted by key. Attribute returns the current KeyValue of the Iterator. It must be called only after Next returns true. IndexedAttribute returns current index and attribute. Must be called only after Next returns true. IndexedLabel returns current index and attribute. Must be called only after Next returns true. Deprecated: Use IndexedAttribute instead. Label returns current KeyValue. Must be called only after Next returns true. Deprecated: Use Attribute instead. Len returns a number of attributes in the iterated set. Next moves the iterator to the next position. Returns false if there are no more attributes. 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 (*Set).Iter() Iterator func Encoder.Encode(iterator 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. Bool creates a KeyValue instance with a BOOL Value. If creating both a key and value at the same time, use the provided convenience function instead -- Bool(name, value). BoolSlice creates a KeyValue instance with a BOOLSLICE Value. If creating both a key and value at the same time, use the provided convenience function instead -- BoolSlice(name, value). Defined returns true for non-empty keys. Float64 creates a KeyValue instance with a FLOAT64 Value. If creating both a key and value at the same time, use the provided convenience function instead -- Float64(name, value). Float64Slice creates a KeyValue instance with a FLOAT64SLICE Value. If creating both a key and value at the same time, use the provided convenience function instead -- Float64(name, value). Int creates a KeyValue instance with an INT64 Value. If creating both a key and value at the same time, use the provided convenience function instead -- Int(name, value). Int64 creates a KeyValue instance with an INT64 Value. If creating both a key and value at the same time, use the provided convenience function instead -- Int64(name, value). Int64Slice creates a KeyValue instance with an INT64SLICE Value. If creating both a key and value at the same time, use the provided convenience function instead -- Int64Slice(name, value). IntSlice creates a KeyValue instance with an INT64SLICE Value. If creating both a key and value at the same time, use the provided convenience function instead -- IntSlice(name, value). String creates a KeyValue instance with a STRING Value. If creating both a key and value at the same time, use the provided convenience function instead -- String(name, value). StringSlice creates a KeyValue instance with a STRINGSLICE Value. If creating both a key and value at the same time, use the provided convenience function instead -- StringSlice(name, value). func NewAllowKeysFilter(keys ...Key) Filter func NewDenyKeysFilter(keys ...Key) Filter func (*Set).HasValue(k Key) bool func (*Set).Value(k Key) (Value, bool)
KeyValue holds a key and value pair. Key Key Value Value Valid returns if kv is a valid OpenTelemetry attribute. func Bool(k string, v bool) KeyValue func BoolSlice(k string, v []bool) KeyValue func Float64(k string, v float64) KeyValue func Float64Slice(k string, v []float64) KeyValue func Int(k string, v int) KeyValue func Int64(k string, v int64) KeyValue func Int64Slice(k string, v []int64) KeyValue func IntSlice(k string, v []int) 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 StringSlice(k string, v []string) KeyValue func (*Iterator).Attribute() KeyValue func (*Iterator).IndexedAttribute() (int, KeyValue) func (*Iterator).IndexedLabel() (int, KeyValue) func (*Iterator).Label() KeyValue func (*Iterator).ToSlice() []KeyValue func Key.Bool(v bool) KeyValue func Key.BoolSlice(v []bool) KeyValue func Key.Float64(v float64) KeyValue func Key.Float64Slice(v []float64) KeyValue func Key.Int(v int) KeyValue func Key.Int64(v int64) KeyValue func Key.Int64Slice(v []int64) KeyValue func Key.IntSlice(v []int) KeyValue func Key.String(v string) KeyValue func Key.StringSlice(v []string) KeyValue func (*MergeIterator).Attribute() KeyValue func (*MergeIterator).Label() KeyValue func (*Set).Filter(re Filter) (Set, []KeyValue) func (*Set).Get(idx int) (KeyValue, bool) func (*Set).ToSlice() []KeyValue func go.opentelemetry.io/otel/trace.(*EventConfig).Attributes() []KeyValue func go.opentelemetry.io/otel/trace.(*SpanConfig).Attributes() []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/trace.LinkFromContext(ctx context.Context, attrs ...KeyValue) trace.Link func go.opentelemetry.io/otel/trace.WithAttributes(attributes ...KeyValue) trace.SpanStartEventOption func go.opentelemetry.io/otel/trace.WithInstrumentationAttributes(attr ...KeyValue) trace.TracerOption func go.opentelemetry.io/otel/trace.Span.SetAttributes(kv ...KeyValue)
MergeIterator supports iterating over two sets of attributes while eliminating duplicate values from the combined set. The first iterator value takes precedence. Attribute returns the current value after Next() returns true. Label returns the current value after Next() returns true. Deprecated: Use Attribute instead. Next returns true if there is another attribute available. func NewMergeIterator(s1, s2 *Set) MergeIterator
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. Encoded returns the encoded form of this set, according to encoder. 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 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. 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 attributes in this set. Len returns the number of attributes in this set. MarshalJSON returns the JSON encoding of the Set. MarshalLog is the marshaling function used by the logging system to represent this exporter. ToSlice returns the set of attributes belonging to this set, sorted, where keys appear no more than once. Value returns the value of a specified key in this set. *Set : 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 go.opentelemetry.io/otel/trace.(*TracerConfig).InstrumentationAttributes() Set func NewMergeIterator(s1, s2 *Set) MergeIterator 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. *Sortable : 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. ( Type) String() string Type : fmt.Stringer func Value.Type() Type const BOOL const BOOLSLICE const FLOAT64 const FLOAT64SLICE const INT64 const INT64SLICE const INVALID const STRING const STRINGSLICE
Value represents the value part in key-value pairs. AsBool returns the bool value. Make sure that the Value's type is BOOL. AsBoolSlice returns the []bool value. Make sure that the Value's type is BOOLSLICE. AsFloat64 returns the float64 value. Make sure that the Value's type is FLOAT64. AsFloat64Slice returns the []float64 value. Make sure that the Value's type is FLOAT64SLICE. AsInt64 returns the int64 value. Make sure that the Value's type is INT64. AsInt64Slice returns the []int64 value. Make sure that the Value's type is INT64SLICE. AsInterface returns Value's data as interface{}. AsString returns the string value. Make sure that the Value's type is STRING. AsStringSlice returns the []string value. Make sure that the Value's type is STRINGSLICE. Emit returns a string representation of Value's data. MarshalJSON returns the JSON encoding of the Value. Type returns a type of the Value. Value : encoding/json.Marshaler func BoolSliceValue(v []bool) Value func BoolValue(v bool) Value func Float64SliceValue(v []float64) Value func Float64Value(v float64) Value func Int64SliceValue(v []int64) Value func Int64Value(v int64) Value func IntSliceValue(v []int) Value func IntValue(v int) Value func StringSliceValue(v []string) Value func StringValue(v string) Value func (*Set).Value(k Key) (Value, bool)
Package-Level Functions (total 38, in which 31 are exported)
Bool creates a KeyValue with a BOOL Value type.
BoolSlice creates a KeyValue with a BOOLSLICE Value type.
BoolSliceValue creates a BOOLSLICE Value.
BoolValue creates a BOOL Value.
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.
EmptySet returns a reference to a Set with no elements. This is a convenience provided for optimized calling utility.
Float64 creates a KeyValue with a FLOAT64 Value type.
Float64Slice creates a KeyValue with a FLOAT64SLICE Value type.
Float64SliceValue creates a FLOAT64SLICE Value.
Float64Value creates a FLOAT64 Value.
Int creates a KeyValue with an INT64 Value type.
Int64 creates a KeyValue with an INT64 Value type.
Int64Slice creates a KeyValue with an INT64SLICE Value type.
Int64SliceValue creates an INT64SLICE Value.
Int64Value creates an INT64 Value.
IntSlice creates a KeyValue with an INT64SLICE Value type.
IntSliceValue creates an INTSLICE Value.
IntValue creates an INT64 Value.
NewAllowKeysFilter returns a Filter that only allows attributes with one of the provided keys. If keys is empty a deny-all filter is returned.
NewDenyKeysFilter returns a Filter that only allows attributes that do not have one of the provided keys. If keys is empty an allow-all filter is returned.
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.
NewMergeIterator returns a MergeIterator for merging two attribute 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 attribute keys from the return value. Excluded keys are returned as a slice of attribute 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 attributes, by attribute.EncoderID. This value should not be copied after its first use. The second []KeyValue return value is a list of attributes that were excluded by the Filter (if non-nil).
String creates a KeyValue with a STRING Value type.
Stringer creates a new key-value pair with a passed name and a string value generated by the passed Stringer interface.
StringSlice creates a KeyValue with a STRINGSLICE Value type.
StringSliceValue creates a STRINGSLICE Value.
StringValue creates a STRING Value.
Package-Level Variables (total 8, none are exported)
Package-Level Constants (total 11, in which 9 are exported)
BOOL is a boolean Type Value.
BOOLSLICE is a slice of booleans Type Value.
FLOAT64 is a 64-bit floating point Type Value.
FLOAT64SLICE is a slice of 64-bit floating point numbers Type Value.
INT64 is a 64-bit signed integral Type Value.
INT64SLICE is a slice of 64-bit signed integral numbers Type Value.
INVALID is used for a Value with no value set.
STRING is a string Type Value.
STRINGSLICE is a slice of strings Type Value.