Class AttributesProcessor

java.lang.Object
io.opentelemetry.sdk.metrics.internal.view.AttributesProcessor
Direct Known Subclasses:
AdviceAttributesProcessor, AttributesProcessor.AppendingAttributesProcessor, AttributesProcessor.AttributeKeyFilteringProcessor, AttributesProcessor.BaggageAppendingAttributesProcessor, AttributesProcessor.JoinedAttributesProcessor, NoopAttributesProcessor

@Immutable public abstract class AttributesProcessor extends Object
An AttributesProcessor is used to define the actual set of attributes that will be used in a Metric vs. the inbound set of attributes from a measurement.

This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.

  • Constructor Details

    • AttributesProcessor

      AttributesProcessor()
  • Method Details

    • process

      public abstract Attributes process(Attributes incoming, Context context)
      Manipulates a set of attributes, returning the desired set.
      Parameters:
      incoming - Attributes associated with an incoming measurement.
      context - The context associated with the measurement.
    • usesContext

      public abstract boolean usesContext()
      If true, this ensures the `Context` argument of the attributes processor is always accurate. This will prevents bound instruments from pre-locking their metric-attributes and defer until context is available.
    • then

      Joins this attribute processor with another that operates after this one.
    • noop

      public static AttributesProcessor noop()
      No-op version of attributes processor, returns what it gets.
    • filterByKeyName

      public static AttributesProcessor filterByKeyName(Predicate<String> nameFilter)
      Creates a processor which filters down attributes from a measurement.
      Parameters:
      nameFilter - a filter for which attribute keys to preserve.
    • appendBaggageByKeyName

      public static AttributesProcessor appendBaggageByKeyName(Predicate<String> nameFilter)
      Creates a processor which appends values from Baggage.

      These attributes will not override those attributes provided by instrumentation.

      Parameters:
      nameFilter - a filter for which baggage keys to select.
    • append

      public static AttributesProcessor append(Attributes attributes)
      Creates a processor which appends (exactly) the given attributes.

      These attributes will not override those attributes provided by instrumentation.

      Parameters:
      attributes - Attributes to append to measurements.
    • setIncludes

      public static Predicate<String> setIncludes(Set<String> set)
      Creates a Predicate which tests if the set includes the input.