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

io.opentelemetry.javaagent.bootstrap.internal.DeprecatedConfigProperties Maven / Gradle / Ivy

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

package io.opentelemetry.javaagent.bootstrap.internal;

import static java.util.Collections.emptyList;
import static java.util.logging.Level.WARNING;

import io.opentelemetry.instrumentation.api.incubator.config.internal.InstrumentationConfig;
import java.util.List;
import java.util.logging.Logger;

/**
 * This class is internal and is hence not for public use. Its APIs are unstable and can change at
 * any time.
 */
@SuppressWarnings("unused")
public final class DeprecatedConfigProperties {

  private static final Logger logger = Logger.getLogger(DeprecatedConfigProperties.class.getName());

  public static boolean getBoolean(
      InstrumentationConfig config,
      String deprecatedPropertyName,
      String newPropertyName,
      boolean defaultValue) {
    warnIfUsed(config, deprecatedPropertyName, newPropertyName);
    boolean value = config.getBoolean(deprecatedPropertyName, defaultValue);
    return config.getBoolean(newPropertyName, value);
  }

  public static List getList(
      InstrumentationConfig config, String deprecatedPropertyName, String newPropertyName) {
    warnIfUsed(config, deprecatedPropertyName, newPropertyName);
    List value = config.getList(deprecatedPropertyName, emptyList());
    return config.getList(newPropertyName, value);
  }

  private static void warnIfUsed(
      InstrumentationConfig config, String deprecatedPropertyName, String newPropertyName) {
    if (config.getString(deprecatedPropertyName) != null) {
      logger.log(
          WARNING,
          "Deprecated property \"{0}\" was used; use the \"{1}\" property instead",
          new Object[] {deprecatedPropertyName, newPropertyName});
    }
  }

  private DeprecatedConfigProperties() {}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy