Attributes class

A collection of attributes that are immutable and type-safe. Create with the OTelFactory methods.

Annotations
  • @immutable

Properties

hashCode → int
The hash code for this object.
no setteroverride
isEmpty → bool
Returns true if this attributes collection is empty.
no setter
keys → List<String>
Returns a list of all attribute keys. The returned list is unmodifiable.
no setter
length → int
Returns the number of attributes in this collection.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

copyWith(List<Attribute<Object>> other) → Attributes
Creates a new Attributes instance by adding or updating multiple attributes.
copyWithAttributes(Attributes other) → Attributes
Creates a new Attributes instance by combining with another Attributes instance. Attributes from the other instance will overwrite attributes with the same keys in this instance.
copyWithBoolAttribute(String name, bool value) → Attributes
Creates a new Attributes instance with a Boolean attribute added or updated.
copyWithBoolListAttribute(String name, List<bool> value) → Attributes
Creates a new Attributes instance with a Boolean List attribute added or updated.
copyWithDoubleAttribute(String name, double value) → Attributes
Creates a new Attributes instance with a Double attribute added or updated.
copyWithDoubleListAttribute(String name, List<double> value) → Attributes
Creates a new Attributes instance with a Double List attribute added or updated.
copyWithIntAttribute(String name, int value) → Attributes
Creates a new Attributes instance with an Integer attribute added or updated.
copyWithIntListAttribute(String name, List<int> value) → Attributes
Creates a new Attributes instance with an Integer List attribute added or updated.
copyWithout(String key) → Attributes
Creates a new Attributes instance with the specified attribute removed. If the key doesn't exist, returns this instance unchanged.
copyWithStringAttribute(String name, String value) → Attributes
Creates a new Attributes instance with a String attribute added or updated.
copyWithStringListAttribute(String name, List<String> value) → Attributes
Creates a new Attributes instance with a String List attribute added or updated.
getBool(String name) → bool?
Gets a Boolean attribute value by key. Returns null if the key doesn't exist or if the value is not a Boolean.
getBoolList(String name) → List<bool>?
Gets a Boolean List attribute value by key. Returns null if the key doesn't exist or if the value is not a Boolean List.
getDouble(String name) → double?
Gets a Double attribute value by key. Returns null if the key doesn't exist or if the value is not a Double.
getDoubleList(String name) → List<double>?
Gets a Double List attribute value by key. Returns null if the key doesn't exist or if the value is not a Double List.
getInt(String name) → int?
Gets an Integer attribute value by key. Returns null if the key doesn't exist or if the value is not an Integer.
getIntList(String name) → List<int>?
Gets an Integer List attribute value by key. Returns null if the key doesn't exist or if the value is not an Integer List.
getString(String name) → String?
Gets a String attribute value by key. Returns null if the key doesn't exist or if the value is not a String.
getStringList(String name) → List<String>?
Gets a String List attribute value by key. Returns null if the key doesn't exist or if the value is not a String List.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() → Map<String, dynamic>
Converts the attributes to a JSON-serializable map. This is useful for logging or debugging.
toList() → List<Attribute<Object>>
Returns all attributes as a read-only List.
toMap() → Map<String, Attribute<Object>>
Returns all attributes as a read-only map.
toString() → String
A string representation of this object.
override

Operators

operator ==(Object other) → bool
The equality operator.
override

Static Methods

fromJson(Map<String, dynamic> json) → Attributes
Creates an Attributes instance from a JSON map. This is a utility method for deserialization from logs or exports.
of(Map<String, Object> map) → Attributes
Creates an Attributes instance from a map of key-value pairs. Uses the appropriate factory method (OTelFactory or OTelAPIFactory) based on initialization state.