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

org.apache.rocketmq.shaded.io.opentelemetry.sdk.logs.LogLimitsBuilder Maven / Gradle / Ivy

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

package org.apache.rocketmq.shaded.io.opentelemetry.sdk.logs;

import org.apache.rocketmq.shaded.io.opentelemetry.api.internal.Utils;
import org.apache.rocketmq.shaded.io.opentelemetry.sdk.logs.data.LogData;

/** Builder for {@link LogLimits}. */
public final class LogLimitsBuilder {

  private static final int DEFAULT_LOG_MAX_NUM_ATTRIBUTES = 128;
  private static final int DEFAULT_LOG_MAX_ATTRIBUTE_LENGTH = Integer.MAX_VALUE;

  private int maxNumAttributes = DEFAULT_LOG_MAX_NUM_ATTRIBUTES;
  private int maxAttributeValueLength = DEFAULT_LOG_MAX_ATTRIBUTE_LENGTH;

  LogLimitsBuilder() {}

  /**
   * Sets the max number of attributes per {@link LogData}.
   *
   * @param maxNumberOfAttributes the max number of attributes per {@link LogData}. Must be
   *     positive.
   * @return this.
   * @throws IllegalArgumentException if {@code maxNumberOfAttributes} is not positive.
   */
  public LogLimitsBuilder setMaxNumberOfAttributes(int maxNumberOfAttributes) {
    Utils.checkArgument(maxNumberOfAttributes > 0, "maxNumberOfAttributes must be greater than 0");
    this.maxNumAttributes = maxNumberOfAttributes;
    return this;
  }

  /**
   * Sets the max number of characters for string attribute values. For string array attribute
   * values, applies to each entry individually.
   *
   * @param maxAttributeValueLength the max number of characters for attribute strings. Must not be
   *     negative.
   * @return this.
   * @throws IllegalArgumentException if {@code maxAttributeValueLength} is negative.
   */
  public LogLimitsBuilder setMaxAttributeValueLength(int maxAttributeValueLength) {
    Utils.checkArgument(
        maxAttributeValueLength > -1, "maxAttributeValueLength must be non-negative");
    this.maxAttributeValueLength = maxAttributeValueLength;
    return this;
  }

  /** Builds and returns a {@link LogLimits} with the values of this builder. */
  public LogLimits build() {
    return LogLimits.create(maxNumAttributes, maxAttributeValueLength);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy