Package io.opentelemetry.sdk.internal
Class AttributesMap
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<AttributeKey<?>,java.lang.Object>
-
- io.opentelemetry.sdk.internal.AttributesMap
-
- All Implemented Interfaces:
Attributes,java.io.Serializable,java.lang.Cloneable,java.util.Map<AttributeKey<?>,java.lang.Object>
public final class AttributesMap extends java.util.HashMap<AttributeKey<?>,java.lang.Object> implements Attributes
A map with a fixed capacity that drops attributes when the map gets full, and which truncates string and array string attribute values to thelengthLimit.This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private longcapacityprivate intlengthLimitprivate static longserialVersionUIDprivate inttotalAddedValues
-
Constructor Summary
Constructors Modifier Constructor Description privateAttributesMap(long capacity, int lengthLimit)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<AttributeKey<?>,java.lang.Object>asMap()Returns a read-only view of thisAttributesas aMap.static AttributesMapcreate(long capacity, int lengthLimit)Create an instance.voidforEach(java.util.function.BiConsumer<? super AttributeKey<?>,? super java.lang.Object> action)Iterates over all the key-value pairs of attributes contained by this instance.<T> Tget(AttributeKey<T> key)Returns the value for the givenAttributeKey, ornullif not found.intgetTotalAddedValues()Get the total number of attributes added, including those dropped for capcity limits.AttributesimmutableCopy()Create an immutable copy of the attributes in this map.<T> voidput(AttributeKey<T> key, T value)Add the attribute key value pair, applying capacity and length limits.AttributesBuildertoBuilder()Returns a newAttributesBuilderinstance populated with the data of thisAttributes.java.lang.StringtoString()-
Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
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 Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
capacity
private final long capacity
-
lengthLimit
private final int lengthLimit
-
totalAddedValues
private int totalAddedValues
-
-
Method Detail
-
create
public static AttributesMap create(long capacity, int lengthLimit)
Create an instance.- Parameters:
capacity- the max number of attribute entrieslengthLimit- the maximum length of string attributes
-
put
public <T> void put(AttributeKey<T> key, T value)
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
@Nullable public <T> T get(AttributeKey<T> key)
Description copied from interface:AttributesReturns the value for the givenAttributeKey, ornullif not found.- Specified by:
getin interfaceAttributes
-
asMap
public java.util.Map<AttributeKey<?>,java.lang.Object> asMap()
Description copied from interface:AttributesReturns a read-only view of thisAttributesas aMap.- Specified by:
asMapin interfaceAttributes
-
toBuilder
public AttributesBuilder toBuilder()
Description copied from interface:AttributesReturns a newAttributesBuilderinstance populated with the data of thisAttributes.- Specified by:
toBuilderin interfaceAttributes
-
forEach
public void forEach(java.util.function.BiConsumer<? super AttributeKey<?>,? super java.lang.Object> action)
Description copied from interface:AttributesIterates over all the key-value pairs of attributes contained by this instance.- Specified by:
forEachin interfaceAttributes- Specified by:
forEachin interfacejava.util.Map<AttributeKey<?>,java.lang.Object>- Overrides:
forEachin classjava.util.HashMap<AttributeKey<?>,java.lang.Object>
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.util.AbstractMap<AttributeKey<?>,java.lang.Object>
-
immutableCopy
public Attributes immutableCopy()
Create an immutable copy of the attributes in this map.
-
-