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

io.opentelemetry.contrib.awsxray.AttributePropagatingSpanProcessorBuilder Maven / Gradle / Ivy

/*
 * Copyright The OpenTelemetry Authors
 * SPDX-License-Identifier: Apache-2.0
 */

package io.opentelemetry.contrib.awsxray;

import static java.util.Objects.requireNonNull;

import com.google.errorprone.annotations.CanIgnoreReturnValue;
import io.opentelemetry.api.common.AttributeKey;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * AttributePropagatingSpanProcessorBuilder is used to construct a {@link
 * AttributePropagatingSpanProcessor}. If {@link #setSpanNamePropagationKey} or {@link
 * #setAttributesKeysToPropagate} are not invoked, the builder defaults to using specific {@link
 * AwsAttributeKeys} as propagation targets.
 */
public class AttributePropagatingSpanProcessorBuilder {

  private AttributeKey spanNamePropagationKey = AwsAttributeKeys.AWS_LOCAL_OPERATION;
  private List> attributesKeysToPropagate =
      Arrays.asList(AwsAttributeKeys.AWS_REMOTE_SERVICE, AwsAttributeKeys.AWS_REMOTE_OPERATION);

  public static AttributePropagatingSpanProcessorBuilder create() {
    return new AttributePropagatingSpanProcessorBuilder();
  }

  private AttributePropagatingSpanProcessorBuilder() {}

  @CanIgnoreReturnValue
  public AttributePropagatingSpanProcessorBuilder setSpanNamePropagationKey(
      AttributeKey spanNamePropagationKey) {
    requireNonNull(spanNamePropagationKey, "spanNamePropagationKey");
    this.spanNamePropagationKey = spanNamePropagationKey;
    return this;
  }

  @CanIgnoreReturnValue
  public AttributePropagatingSpanProcessorBuilder setAttributesKeysToPropagate(
      List> attributesKeysToPropagate) {
    requireNonNull(attributesKeysToPropagate, "attributesKeysToPropagate");
    this.attributesKeysToPropagate = Collections.unmodifiableList(attributesKeysToPropagate);
    return this;
  }

  public AttributePropagatingSpanProcessor build() {
    return AttributePropagatingSpanProcessor.create(
        spanNamePropagationKey, attributesKeysToPropagate);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy