All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.opentelemetry.sdk.metrics.internal.view.AdviceAttributesProcessor Maven / Gradle / Ivy

There is a newer version: 1.44.1
Show newest version
/*
 * Copyright The OpenTelemetry Authors
 * SPDX-License-Identifier: Apache-2.0
 */

package io.opentelemetry.sdk.metrics.internal.view;

import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

final class AdviceAttributesProcessor extends AttributesProcessor {

  private final Set> attributeKeys;

  AdviceAttributesProcessor(List> adviceAttributeKeys) {
    this.attributeKeys = new HashSet<>(adviceAttributeKeys);
  }

  @Override
  public Attributes process(Attributes incoming, Context context) {
    AttributesBuilder builder = incoming.toBuilder();
    builder.removeIf(key -> !attributeKeys.contains(key));
    return builder.build();
  }

  @Override
  public boolean usesContext() {
    return false;
  }

  @Override
  public String toString() {
    return "AdviceAttributesProcessor{attributeKeys=" + attributeKeys + '}';
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy