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

io.opentelemetry.sdk.trace.samplers.ImmutableSamplingResult 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.trace.samplers;

import com.google.auto.value.AutoValue;
import io.opentelemetry.api.common.Attributes;
import javax.annotation.concurrent.Immutable;

@Immutable
@AutoValue
abstract class ImmutableSamplingResult implements SamplingResult {

  static final SamplingResult EMPTY_RECORDED_AND_SAMPLED_SAMPLING_RESULT =
      ImmutableSamplingResult.createWithoutAttributes(SamplingDecision.RECORD_AND_SAMPLE);

  static final SamplingResult EMPTY_NOT_SAMPLED_OR_RECORDED_SAMPLING_RESULT =
      ImmutableSamplingResult.createWithoutAttributes(SamplingDecision.DROP);

  static final SamplingResult EMPTY_RECORDED_SAMPLING_RESULT =
      ImmutableSamplingResult.createWithoutAttributes(SamplingDecision.RECORD_ONLY);

  static SamplingResult createSamplingResult(SamplingDecision decision, Attributes attributes) {
    return new AutoValue_ImmutableSamplingResult(decision, attributes);
  }

  private static SamplingResult createWithoutAttributes(SamplingDecision decision) {
    return new AutoValue_ImmutableSamplingResult(decision, Attributes.empty());
  }

  @Override
  public abstract SamplingDecision getDecision();

  @Override
  public abstract Attributes getAttributes();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy