Package io.opentelemetry.sdk.internal
Class AttributesMap
- All Implemented Interfaces:
Attributes
,Serializable
,Cloneable
,Map<AttributeKey<?>,
Object>
A map with a fixed capacity that drops attributes when the map gets full, and which truncates
string and array string attribute values to the
lengthLimit
.
This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,
V>, AbstractMap.SimpleImmutableEntry<K, V> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final long
private final int
private static final long
private int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionMap
<AttributeKey<?>, Object> asMap()
Returns a read-only view of thisAttributes
as aMap
.static AttributesMap
create
(long capacity, int lengthLimit) Create an instance.void
forEach
(BiConsumer<? super AttributeKey<?>, ? super Object> action) Iterates over all the key-value pairs of attributes contained by this instance.<T> T
get
(AttributeKey<T> key) Returns the value for the givenAttributeKey
, ornull
if not found.int
Get the total number of attributes added, including those dropped for capcity limits.Create an immutable copy of the attributes in this map.<T> void
put
(AttributeKey<T> key, T value) Add the attribute key value pair, applying capacity and length limits.Returns a newAttributesBuilder
instance populated with the data of thisAttributes
.toString()
Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, get, getOrDefault, isEmpty, keySet, merge, newHashMap, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
Methods inherited from class java.util.AbstractMap
equals, hashCode
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.opentelemetry.api.common.Attributes
isEmpty, size
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
capacity
private final long capacity -
lengthLimit
private final int lengthLimit -
totalAddedValues
private int totalAddedValues
-
-
Constructor Details
-
AttributesMap
private AttributesMap(long capacity, int lengthLimit)
-
-
Method Details
-
create
Create an instance.- Parameters:
capacity
- the max number of attribute entrieslengthLimit
- the maximum length of string attributes
-
put
Add the attribute key value pair, applying capacity and length limits. -
getTotalAddedValues
public int getTotalAddedValues()Get the total number of attributes added, including those dropped for capcity limits. -
get
Description copied from interface:Attributes
Returns the value for the givenAttributeKey
, ornull
if not found.- Specified by:
get
in interfaceAttributes
-
asMap
Description copied from interface:Attributes
Returns a read-only view of thisAttributes
as aMap
.- Specified by:
asMap
in interfaceAttributes
-
toBuilder
Description copied from interface:Attributes
Returns a newAttributesBuilder
instance populated with the data of thisAttributes
.- Specified by:
toBuilder
in interfaceAttributes
-
forEach
Description copied from interface:Attributes
Iterates over all the key-value pairs of attributes contained by this instance.- Specified by:
forEach
in interfaceAttributes
- Specified by:
forEach
in interfaceMap<AttributeKey<?>,
Object> - Overrides:
forEach
in classHashMap<AttributeKey<?>,
Object>
-
toString
- Overrides:
toString
in classAbstractMap<AttributeKey<?>,
Object>
-
immutableCopy
Create an immutable copy of the attributes in this map.
-