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

io.opentelemetry.contrib.metrics.micrometer.internal.instruments.AbstractInstrumentBuilder Maven / Gradle / Ivy

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

package io.opentelemetry.contrib.metrics.micrometer.internal.instruments;

import com.google.errorprone.annotations.CanIgnoreReturnValue;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.contrib.metrics.micrometer.internal.state.InstrumentState;
import io.opentelemetry.contrib.metrics.micrometer.internal.state.MeterSharedState;
import java.util.List;
import javax.annotation.Nullable;

abstract class AbstractInstrumentBuilder> {
  protected final MeterSharedState meterSharedState;
  protected final String name;
  @Nullable protected String description;
  @Nullable protected String unit;
  @Nullable protected List> attributes;
  @Nullable protected List explicitBucketBoundaries;

  protected AbstractInstrumentBuilder(MeterSharedState meterSharedState, String name) {
    this.meterSharedState = meterSharedState;
    this.name = name;
  }

  protected AbstractInstrumentBuilder(AbstractInstrumentBuilder parent) {
    this.meterSharedState = parent.meterSharedState;
    this.name = parent.name;
    this.description = parent.description;
    this.unit = parent.unit;
    this.attributes = parent.attributes;
    this.explicitBucketBoundaries = parent.explicitBucketBoundaries;
  }

  protected abstract BUILDER self();

  @CanIgnoreReturnValue
  public BUILDER setDescription(String description) {
    this.description = description;
    return self();
  }

  @CanIgnoreReturnValue
  public BUILDER setUnit(String unit) {
    this.unit = unit;
    return self();
  }

  @CanIgnoreReturnValue
  public BUILDER setAttributesAdvice(List> attributes) {
    this.attributes = attributes;
    return self();
  }

  @CanIgnoreReturnValue
  public BUILDER setExplicitBucketBoundaries(List explicitBucketBoundaries) {
    this.explicitBucketBoundaries = explicitBucketBoundaries;
    return self();
  }

  protected InstrumentState createInstrumentState() {
    return new InstrumentState(
        meterSharedState, name, description, unit, attributes, explicitBucketBoundaries);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy