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 class
Implementation that can handle attributes of arbitrary size by storing filter status in aBitSet
.private static class
Implementation that relies on the source having less thanFilteredAttributes.SmallFilteredAttributes.BITS_PER_INTEGER
attributes, and storing entry filter status in the bits of an integer. -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
FilteredAttributes
(Object[] sourceData, int hashcode, int size) -
Method Summary
Modifier and TypeMethodDescriptionMap
<AttributeKey<?>, Object> asMap()
Returns a read-only view of thisAttributes
as aMap
.private static Attributes
(package private) static Attributes
create
(Attributes source, Set<AttributeKey<?>> includedKeys) Create aFilteredAttributes
instance.boolean
void
forEach
(BiConsumer<? super AttributeKey<?>, ? super Object> consumer) 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
hashCode()
(package private) abstract boolean
includeIndexInOutput
(int sourceIndex) boolean
isEmpty()
Whether there are any attributes contained in this.private static <T> void
putInBuilder
(AttributesBuilder builder, AttributeKey<T> key, T value) int
size()
The number of attributes contained in this.Returns a newAttributesBuilder
instance 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 aFilteredAttributes
instance.- 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:Attributes
Returns the value for the givenAttributeKey
, ornull
if not found.- Specified by:
get
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
-
size
public int size()Description copied from interface:Attributes
The number of attributes contained in this.- Specified by:
size
in interfaceAttributes
-
isEmpty
public boolean isEmpty()Description copied from interface:Attributes
Whether there are any attributes contained in this.- Specified by:
isEmpty
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
-
putInBuilder
-
equals
-
hashCode
public int hashCode() -
toString
-
includeIndexInOutput
abstract boolean includeIndexInOutput(int sourceIndex)
-