Class FilteredAttributes
java.lang.Object
io.opentelemetry.sdk.metrics.internal.view.FilteredAttributes
- All Implemented Interfaces:
Attributes
- Direct Known Subclasses:
FilteredAttributes.RegularFilteredAttributes,FilteredAttributes.SmallFilteredAttributes
Filtered attributes is a filtered view of a
ImmutableKeyValuePairs backed Attributes instance. Rather than creating an entirely new attributes instance, it keeps track of
which source attributes are excluded while implementing the Attributes interface.
Notably, the equals(Object) and hashCode() depend on comparison against other FilteredAttributes
instances. This means that where FilteredAttributes is used for things like map keys, it
must be used for all keys in that map. You cannot mix Attributes implementations. This is
also true for the default attributes implementation.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classImplementation that can handle attributes of arbitrary size by storing filter status in aBitSet.private static classImplementation that relies on the source having less thanFilteredAttributes.SmallFilteredAttributes.BITS_PER_INTEGERattributes, and storing entry filter status in the bits of an integer. -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateFilteredAttributes(Object[] sourceData, int hashcode, int size) -
Method Summary
Modifier and TypeMethodDescriptionMap<AttributeKey<?>, Object> asMap()Returns a read-only view of thisAttributesas aMap.private static Attributes(package private) static Attributescreate(Attributes source, Set<AttributeKey<?>> includedKeys) Create aFilteredAttributesinstance.booleanvoidforEach(BiConsumer<? super AttributeKey<?>, ? super Object> consumer) 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.inthashCode()(package private) abstract booleanincludeIndexInOutput(int sourceIndex) booleanisEmpty()Whether there are any attributes contained in this.private static <T> voidputInBuilder(AttributesBuilder builder, AttributeKey<T> key, T value) intsize()The number of attributes contained in this.Returns a newAttributesBuilderinstance populated with the data of thisAttributes.toString()
-
Field Details
-
sourceData
-
hashcode
private final int hashcode -
size
private final int size
-
-
Constructor Details
-
FilteredAttributes
-
-
Method Details
-
create
Create aFilteredAttributesinstance.- Parameters:
source- the source attributes, which SHOULD be based on the standardImmutableKeyValuePairs. If not, the source will first be converted to the standard implementation.includedKeys- the set of attribute keys to include in the output.
-
convertToStandardImplementation
-
get
Description copied from interface:AttributesReturns the value for the givenAttributeKey, ornullif not found.- Specified by:
getin interfaceAttributes
-
forEach
Description copied from interface:AttributesIterates over all the key-value pairs of attributes contained by this instance.- Specified by:
forEachin interfaceAttributes
-
size
public int size()Description copied from interface:AttributesThe number of attributes contained in this.- Specified by:
sizein interfaceAttributes
-
isEmpty
public boolean isEmpty()Description copied from interface:AttributesWhether there are any attributes contained in this.- Specified by:
isEmptyin interfaceAttributes
-
asMap
Description copied from interface:AttributesReturns a read-only view of thisAttributesas aMap.- Specified by:
asMapin interfaceAttributes
-
toBuilder
Description copied from interface:AttributesReturns a newAttributesBuilderinstance populated with the data of thisAttributes.- Specified by:
toBuilderin interfaceAttributes
-
putInBuilder
-
equals
-
hashCode
public int hashCode() -
toString
-
includeIndexInOutput
abstract boolean includeIndexInOutput(int sourceIndex)
-