Skip to content

Commit

Permalink
Remove deprecated methods from instrumentation-api and library instru…
Browse files Browse the repository at this point in the history
…mentations (#5575)
  • Loading branch information
Mateusz Rzeszutek authored Mar 15, 2022
1 parent 98759f4 commit b0d5fc6
Show file tree
Hide file tree
Showing 25 changed files with 155 additions and 714 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

package io.opentelemetry.instrumentation.api.config;

import static java.util.Collections.emptyList;
import static java.util.Collections.emptyMap;
import static java.util.Objects.requireNonNull;

import com.google.auto.value.AutoValue;
Expand Down Expand Up @@ -92,18 +90,6 @@ public String getString(String name, String defaultValue) {
return getRawProperty(name, defaultValue);
}

/**
* Returns a boolean-valued configuration property or {@code null} if a property with name {@code
* name} has not been configured.
*
* @deprecated Use the {@link #getBoolean(String, boolean)} variant instead.
*/
@Deprecated
@Nullable
public Boolean getBoolean(String name) {
return getTypedProperty(name, ConfigValueParsers::parseBoolean);
}

/**
* Returns a boolean-valued configuration property or {@code defaultValue} if a property with name
* {@code name} has not been configured.
Expand All @@ -112,101 +98,33 @@ public boolean getBoolean(String name, boolean defaultValue) {
return safeGetTypedProperty(name, ConfigValueParsers::parseBoolean, defaultValue);
}

/**
* Returns a integer-valued configuration property or {@code null} if a property with name {@code
* name} has not been configured.
*
* @throws ConfigParsingException if the property is not a valid integer.
* @deprecated Use the {@link #getInt(String, int)} variant instead.
*/
@Deprecated
@Nullable
public Integer getInt(String name) {
return getTypedProperty(name, ConfigValueParsers::parseInt);
}

/**
* Returns a integer-valued configuration property or {@code defaultValue} if a property with name
* {@code name} has not been configured or when parsing has failed. This is the safe variant of
* {@link #getInt(String)}.
* {@code name} has not been configured or when parsing has failed.
*/
public int getInt(String name, int defaultValue) {
return safeGetTypedProperty(name, ConfigValueParsers::parseInt, defaultValue);
}

/**
* Returns a long-valued configuration property or {@code null} if a property with name {@code
* name} has not been configured.
*
* @throws ConfigParsingException if the property is not a valid long.
* @deprecated Use the {@link #getLong(String, long)} variant instead.
*/
@Deprecated
@Nullable
public Long getLong(String name) {
return getTypedProperty(name, ConfigValueParsers::parseLong);
}

/**
* Returns a long-valued configuration property or {@code defaultValue} if a property with name
* {@code name} has not been configured or when parsing has failed. This is the safe variant of
* {@link #getLong(String)}.
* {@code name} has not been configured or when parsing has failed.
*/
public long getLong(String name, long defaultValue) {
return safeGetTypedProperty(name, ConfigValueParsers::parseLong, defaultValue);
}

/**
* Returns a double-valued configuration property or {@code null} if a property with name {@code
* name} has not been configured.
*
* @throws ConfigParsingException if the property is not a valid long.
* @deprecated Use the {@link #getDouble(String, double)} variant instead.
*/
@Deprecated
@Nullable
public Double getDouble(String name) {
return getTypedProperty(name, ConfigValueParsers::parseDouble);
}

/**
* Returns a double-valued configuration property or {@code defaultValue} if a property with name
* {@code name} has not been configured or when parsing has failed. This is the safe variant of
* {@link #getDouble(String)}.
* {@code name} has not been configured or when parsing has failed.
*/
public double getDouble(String name, double defaultValue) {
return safeGetTypedProperty(name, ConfigValueParsers::parseDouble, defaultValue);
}

/**
* Returns a duration-valued configuration property or {@code null} if a property with name {@code
* name} has not been configured.
*
* <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.
*
* @throws ConfigParsingException if the property is not a valid long.
* @deprecated Use the {@link #getDuration(String, Duration)} variant instead.
*/
@Deprecated
@Nullable
public Duration getDuration(String name) {
return getTypedProperty(name, ConfigValueParsers::parseDuration);
}

/**
* Returns a duration-valued configuration property or {@code defaultValue} if a property with
* name {@code name} has not been configured or when parsing has failed. This is the safe variant
* of {@link #getDuration(String)}.
* name {@code name} has not been configured or when parsing has failed.
*
* <p>Durations can be of the form "{number}{unit}", where unit is one of:
*
Expand All @@ -224,19 +142,6 @@ public Duration getDuration(String name, Duration defaultValue) {
return safeGetTypedProperty(name, ConfigValueParsers::parseDuration, defaultValue);
}

/**
* Returns a list-valued configuration property or an empty list if a property with name {@code
* name} has not been configured. The format of the original value must be comma-separated, e.g.
* {@code one,two,three}.
*
* @deprecated Use the {@link #getList(String, List)} variant instead.
*/
@Deprecated
public List<String> getList(String name) {
List<String> list = getTypedProperty(name, ConfigValueParsers::parseList);
return list == null ? emptyList() : list;
}

/**
* Returns a list-valued configuration property or {@code defaultValue} if a property with name
* {@code name} has not been configured. The format of the original value must be comma-separated,
Expand All @@ -246,26 +151,11 @@ public List<String> getList(String name, List<String> defaultValue) {
return safeGetTypedProperty(name, ConfigValueParsers::parseList, defaultValue);
}

/**
* Returns a map-valued configuration property or an empty map if a property with name {@code
* name} has not been configured. The format of the original value must be comma-separated for
* each key, with an '=' separating the key and value, e.g. {@code
* key=value,anotherKey=anotherValue}.
*
* @throws ConfigParsingException if the property is not a valid long.
* @deprecated Use the {@link #getMap(String, Map)} variant instead.
*/
@Deprecated
public Map<String, String> getMap(String name) {
Map<String, String> map = getTypedProperty(name, ConfigValueParsers::parseMap);
return map == null ? emptyMap() : map;
}

/**
* Returns a map-valued configuration property or {@code defaultValue} if a property with name
* {@code name} has not been configured or when parsing has failed. This is the safe variant of
* {@link #getMap(String)}. The format of the original value must be comma-separated for each key,
* with an '=' separating the key and value, e.g. {@code key=value,anotherKey=anotherValue}.
* {@code name} has not been configured or when parsing has failed. The format of the original
* value must be comma-separated for each key, with an '=' separating the key and value, e.g.
* {@code key=value,anotherKey=anotherValue}.
*/
public Map<String, String> getMap(String name, Map<String, String> defaultValue) {
return safeGetTypedProperty(name, ConfigValueParsers::parseMap, defaultValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@

package io.opentelemetry.instrumentation.api.config;

public class ConfigParsingException extends RuntimeException {
class ConfigParsingException extends RuntimeException {
private static final long serialVersionUID = 1L;

public ConfigParsingException(String message) {
ConfigParsingException(String message) {
super(message);
}

public ConfigParsingException(String message, Throwable cause) {
super(message, cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,50 +31,18 @@ public interface AttributesExtractor<REQUEST, RESPONSE> {
* Extracts attributes from the {@link Context} and the {@link REQUEST} into the {@link
* AttributesBuilder} at the beginning of a request.
*/
default void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) {
onStart(attributes, request);
}

/**
* Extracts attributes from the {@link REQUEST} into the {@link AttributesBuilder} at the
* beginning of a request.
*
* @deprecated Use {@link #onStart(AttributesBuilder, Context, Object)} instead.
*/
@Deprecated
default void onStart(AttributesBuilder attributes, REQUEST request) {
throw new UnsupportedOperationException(
"This method variant is deprecated and will be removed in the next minor release.");
}
void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request);

/**
* Extracts attributes from the {@link Context}, the {@link REQUEST} and either {@link RESPONSE}
* or {@code error} into the {@link AttributesBuilder} at the end of a request.
*/
default void onEnd(
void onEnd(
AttributesBuilder attributes,
Context context,
REQUEST request,
@Nullable RESPONSE response,
@Nullable Throwable error) {
onEnd(attributes, request, response, error);
}

/**
* Extracts attributes from the {@link REQUEST} and either {@link RESPONSE} or {@code error} into
* the {@link AttributesBuilder} at the end of a request.
*
* @deprecated Use {@link #onEnd(AttributesBuilder, Context, Object, Object, Throwable)} instead.
*/
@Deprecated
default void onEnd(
AttributesBuilder attributes,
REQUEST request,
@Nullable RESPONSE response,
@Nullable Throwable error) {
throw new UnsupportedOperationException(
"This method variant is deprecated and will be removed in the next minor release.");
}
@Nullable Throwable error);

/**
* Sets the {@code value} with the given {@code key} to the {@link AttributesBuilder} if {@code
Expand Down

This file was deleted.

Loading

0 comments on commit b0d5fc6

Please sign in to comment.