Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy ConfigProperties, ConfigurationException to opentelemetry-sdk-co… #5500

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion docs/apidiffs/current_vs_latest/opentelemetry-sdk-common.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,32 @@
Comparing source compatibility of against
No changes.
+++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.config.ConfigProperties (not serializable)
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
+++ NEW SUPERCLASS: java.lang.Object
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.lang.Boolean getBoolean(java.lang.String)
+++ NEW ANNOTATION: javax.annotation.Nullable
+++ NEW METHOD: PUBLIC(+) boolean getBoolean(java.lang.String, boolean)
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.lang.Double getDouble(java.lang.String)
+++ NEW ANNOTATION: javax.annotation.Nullable
+++ NEW METHOD: PUBLIC(+) double getDouble(java.lang.String, double)
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.time.Duration getDuration(java.lang.String)
+++ NEW ANNOTATION: javax.annotation.Nullable
+++ NEW METHOD: PUBLIC(+) java.time.Duration getDuration(java.lang.String, java.time.Duration)
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.lang.Integer getInt(java.lang.String)
+++ NEW ANNOTATION: javax.annotation.Nullable
+++ NEW METHOD: PUBLIC(+) int getInt(java.lang.String, int)
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.util.List getList(java.lang.String)
+++ NEW METHOD: PUBLIC(+) java.util.List getList(java.lang.String, java.util.List)
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.lang.Long getLong(java.lang.String)
+++ NEW ANNOTATION: javax.annotation.Nullable
+++ NEW METHOD: PUBLIC(+) long getLong(java.lang.String, long)
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.util.Map getMap(java.lang.String)
+++ NEW METHOD: PUBLIC(+) java.util.Map getMap(java.lang.String, java.util.Map)
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.lang.String getString(java.lang.String)
+++ NEW ANNOTATION: javax.annotation.Nullable
+++ NEW METHOD: PUBLIC(+) java.lang.String getString(java.lang.String, java.lang.String)
+++ NEW CLASS: PUBLIC(+) FINAL(+) io.opentelemetry.sdk.common.config.ConfigurationException (compatible)
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
+++ NEW INTERFACE: java.io.Serializable
+++ NEW SUPERCLASS: java.lang.RuntimeException
+++ NEW CONSTRUCTOR: PUBLIC(+) ConfigurationException(java.lang.String)
+++ NEW CONSTRUCTOR: PUBLIC(+) ConfigurationException(java.lang.String, java.lang.Throwable)
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
Comparing source compatibility of against
No changes.
=== UNCHANGED CLASS: PUBLIC FINAL io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException (compatible)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW ANNOTATION: java.lang.Deprecated
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporter;
import io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporterBuilder;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
import io.opentelemetry.sdk.autoconfigure.spi.logs.ConfigurableLogRecordExporterProvider;
import io.opentelemetry.sdk.common.config.ConfigurationException;
import io.opentelemetry.sdk.logs.export.LogRecordExporter;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporter;
import io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporterBuilder;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
import io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider;
import io.opentelemetry.sdk.common.config.ConfigurationException;
import io.opentelemetry.sdk.metrics.export.MetricExporter;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter;
import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
import io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider;
import io.opentelemetry.sdk.common.config.ConfigurationException;
import io.opentelemetry.sdk.trace.export.SpanExporter;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogRecordExporterBuilder;
import io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporter;
import io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporterBuilder;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
import io.opentelemetry.sdk.common.config.ConfigurationException;
import io.opentelemetry.sdk.logs.export.LogRecordExporter;
import java.io.IOException;
import java.nio.file.Files;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporterBuilder;
import io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporter;
import io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporterBuilder;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
import io.opentelemetry.sdk.common.config.ConfigurationException;
import io.opentelemetry.sdk.metrics.export.MetricExporter;
import java.io.IOException;
import java.nio.file.Files;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporterBuilder;
import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter;
import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
import io.opentelemetry.sdk.common.config.ConfigurationException;
import io.opentelemetry.sdk.trace.export.SpanExporter;
import java.io.IOException;
import java.nio.file.Files;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import io.opentelemetry.exporter.internal.retry.RetryPolicy;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
import io.opentelemetry.sdk.common.config.ConfigurationException;
import io.opentelemetry.sdk.metrics.Aggregation;
import io.opentelemetry.sdk.metrics.InstrumentType;
import io.opentelemetry.sdk.metrics.data.AggregationTemporality;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import com.google.common.collect.ImmutableMap;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
import io.opentelemetry.sdk.common.config.ConfigurationException;
import io.opentelemetry.sdk.metrics.Aggregation;
import io.opentelemetry.sdk.metrics.InstrumentType;
import io.opentelemetry.sdk.metrics.data.AggregationTemporality;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,203 +5,82 @@

package io.opentelemetry.sdk.autoconfigure.spi;

import static io.opentelemetry.api.internal.ConfigUtil.defaultIfNull;

import java.time.Duration;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;

/** Properties used for auto-configuration of the OpenTelemetry SDK components. */
public interface ConfigProperties {

/**
* Returns a string-valued configuration property.
*
* @return null if the property has not been configured.
* @throws ConfigurationException if the property is not a valid string.
*/
public interface ConfigProperties extends io.opentelemetry.sdk.common.config.ConfigProperties {

@Override
@Nullable
String getString(String name);

/**
* Returns a string-valued configuration property.
*
* @return a string-valued configuration property or {@code defaultValue} if a property with
* {@code name} has not been configured.
* @throws ConfigurationException if the property is not a valid string.
* @since 1.15.0
*/
@Override
default String getString(String name, String defaultValue) {
return defaultIfNull(getString(name), defaultValue);
return io.opentelemetry.sdk.common.config.ConfigProperties.super.getString(name, defaultValue);
}

/**
* Returns a boolean-valued configuration property. Implementations should use the same rules as
* {@link Boolean#parseBoolean(String)} for handling the values.
*
* @return null if the property has not been configured.
* @throws ConfigurationException if the property is not a valid boolean.
*/
@Override
@Nullable
Boolean getBoolean(String name);

/**
* Returns a boolean-valued configuration property.
*
* @return a Boolean-valued configuration property or {@code defaultValue} if a property with
* {@code name} has not been configured.
* @throws ConfigurationException if the property is not a valid string.
* @since 1.15.0
*/
@Override
default boolean getBoolean(String name, boolean defaultValue) {
return defaultIfNull(getBoolean(name), defaultValue);
return io.opentelemetry.sdk.common.config.ConfigProperties.super.getBoolean(name, defaultValue);
}

/**
* Returns an Integer-valued configuration property.
*
* @return null if the property has not been configured.
* @throws ConfigurationException if the property is not a valid integer.
*/
@Override
@Nullable
Integer getInt(String name);

/**
* Returns an Integer-valued configuration property.
*
* @return an Integer-valued configuration property or {@code defaultValue} if a property with
* {@code name} has not been configured.
* @throws ConfigurationException if the property is not a valid string.
* @since 1.15.0
*/
@Override
default int getInt(String name, int defaultValue) {
return defaultIfNull(getInt(name), defaultValue);
return io.opentelemetry.sdk.common.config.ConfigProperties.super.getInt(name, defaultValue);
}

/**
* Returns a Long-valued configuration property.
*
* @return null if the property has not been configured.
* @throws ConfigurationException if the property is not a valid long.
*/
@Override
@Nullable
Long getLong(String name);

/**
* Returns a Long-valued configuration property.
*
* @return a Long-valued configuration property or {@code defaultValue} if a property with {@code
* name} has not been configured.
* @throws ConfigurationException if the property is not a valid string.
* @since 1.15.0
*/
@Override
default long getLong(String name, long defaultValue) {
return defaultIfNull(getLong(name), defaultValue);
return io.opentelemetry.sdk.common.config.ConfigProperties.super.getLong(name, defaultValue);
}

/**
* Returns a double-valued configuration property.
*
* @return null if the property has not been configured.
* @throws ConfigurationException if the property is not a valid double.
*/
@Override
@Nullable
Double getDouble(String name);

/**
* Returns a double-valued configuration property.
*
* @return a Double-valued configuration property or {@code defaultValue} if a property with
* {@code name} has not been configured.
* @throws ConfigurationException if the property is not a valid string.
* @since 1.15.0
*/
@Override
default double getDouble(String name, double defaultValue) {
return defaultIfNull(getDouble(name), defaultValue);
return io.opentelemetry.sdk.common.config.ConfigProperties.super.getDouble(name, defaultValue);
}

/**
* Returns a duration property from the map, or {@code null} if it cannot be found or it has a
* wrong type.
*
* <p>Durations can be of the form "{number}{unit}", where unit is one of:
*
* <ul>
* <li>ms
* <li>s
* <li>m
* <li>h
* <li>d
* </ul>
*
* <p>If no unit is specified, milliseconds is the assumed duration unit.
*
* @param name The property name
* @return the {@link Duration} value of the property, {@code null} if the property cannot be
* found.
* @throws ConfigurationException for malformed duration strings.
*/
@Override
@Nullable
Duration getDuration(String name);

/**
* Returns a Duration value configuration property.
*
* @see ConfigProperties#getDuration(String name)
* @return a Double-valued configuration property or {@code defaultValue} if a property with name
* {@code name} has not been configured.
* @throws ConfigurationException if the property is not a valid string.
* @since 1.15.0
*/
@Override
default Duration getDuration(String name, Duration defaultValue) {
return defaultIfNull(getDuration(name), defaultValue);
return io.opentelemetry.sdk.common.config.ConfigProperties.super.getDuration(
name, defaultValue);
}

/**
* Returns a list-valued configuration property. The format of the original value must be
* comma-separated. Empty values will be removed.
*
* @return an empty list if the property has not been configured.
* @throws ConfigurationException if the property is not a valid comma-separated list.
*/
@Override
List<String> getList(String name);

/**
* Returns a List value configuration property.
*
* @see ConfigProperties#getList(String name)
* @return a List configuration property or {@code defaultValue} if a property with {@code name}
* has not been configured.
* @throws ConfigurationException if the property is not a valid string.
* @since 1.15.0
*/
@Override
default List<String> getList(String name, List<String> defaultValue) {
List<String> value = getList(name);
return value.isEmpty() ? defaultValue : value;
return io.opentelemetry.sdk.common.config.ConfigProperties.super.getList(name, defaultValue);
}

/**
* Returns a Map configuration property. The format of the original value must be comma-separated
* for each key, with an '=' separating the key and value. For instance, <code>
* service.name=Greatest Service,host.name=localhost</code> Empty values will be removed.
*
* @return an empty map if the property has not been configured.
* @throws ConfigurationException for malformed map strings.
*/
@Override
Map<String, String> getMap(String name);

/**
* Returns a Map value configuration property.
*
* @see ConfigProperties#getMap(String name)
* @return a Double-valued configuration property or {@code defaultValue} if a property with
* {@code name} has not been configured.
* @throws ConfigurationException if the property is not a valid string.
* @since 1.15.0
*/
@Override
default Map<String, String> getMap(String name, Map<String, String> defaultValue) {
Map<String, String> value = getMap(name);
return value.isEmpty() ? defaultValue : value;
return io.opentelemetry.sdk.common.config.ConfigProperties.super.getMap(name, defaultValue);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@

package io.opentelemetry.sdk.autoconfigure.spi;

/** An exception that is thrown if the user-provided configuration is invalid. */
/**
* An exception that is thrown if the user-provided configuration is invalid.
*
* @deprecated Use {@link io.opentelemetry.sdk.common.config.ConfigurationException}
*/
@Deprecated
public final class ConfigurationException extends RuntimeException {

private static final long serialVersionUID = 4717640118051490483L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import io.opentelemetry.api.internal.ConfigUtil;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
import io.opentelemetry.sdk.common.config.ConfigurationException;
import java.time.Duration;
import java.util.AbstractMap;
import java.util.Arrays;
Expand Down Expand Up @@ -262,7 +262,8 @@ private static TimeUnit getDurationUnit(String unitString) {
case "d":
return TimeUnit.DAYS;
default:
throw new ConfigurationException("Invalid duration string, found: " + unitString);
throw new io.opentelemetry.sdk.common.config.ConfigurationException(
"Invalid duration string, found: " + unitString);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import static org.assertj.core.api.Assertions.entry;

import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
import io.opentelemetry.sdk.common.config.ConfigurationException;
import java.time.Duration;
import java.util.Arrays;
import java.util.Collections;
Expand Down
Loading