Skip to content

Commit

Permalink
Remove ConfigPropertiesAdatpter as it's no longer needed (#4888)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Rzeszutek authored Dec 13, 2021
1 parent ac5bca0 commit 93a3282
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 294 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.time.Duration;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -96,7 +95,10 @@ public String getString(String name, String 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);
Expand All @@ -115,7 +117,9 @@ public boolean getBoolean(String name, boolean defaultValue) {
* 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);
Expand All @@ -135,7 +139,9 @@ public int getInt(String name, int defaultValue) {
* 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);
Expand All @@ -155,7 +161,9 @@ public long getLong(String name, long defaultValue) {
* 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);
Expand Down Expand Up @@ -187,7 +195,9 @@ public double getDouble(String name, double defaultValue) {
* <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);
Expand Down Expand Up @@ -218,7 +228,10 @@ public Duration getDuration(String name, Duration 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;
Expand All @@ -240,7 +253,9 @@ public List<String> getList(String name, List<String> defaultValue) {
* 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;
Expand Down Expand Up @@ -305,16 +320,4 @@ public boolean isInstrumentationPropertyEnabled(
public boolean isAgentDebugEnabled() {
return getBoolean("otel.javaagent.debug", false);
}

/**
* Converts this config instance to Java {@link Properties}.
*
* @deprecated Use {@link #getAllProperties()} instead.
*/
@Deprecated
public Properties asJavaProperties() {
Properties properties = new Properties();
properties.putAll(getAllProperties());
return properties;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package io.opentelemetry.instrumentation.api.instrumenter;

import static java.util.Collections.emptyMap;

import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.instrumentation.api.config.Config;
import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor;
Expand All @@ -24,7 +26,7 @@
public final class PeerServiceAttributesExtractor<REQUEST, RESPONSE>
implements AttributesExtractor<REQUEST, RESPONSE> {
private static final Map<String, String> JAVAAGENT_PEER_SERVICE_MAPPING =
Config.get().getMap("otel.instrumentation.common.peer-service-mapping");
Config.get().getMap("otel.instrumentation.common.peer-service-mapping", emptyMap());

private final Map<String, String> peerServiceMapping;
private final NetClientAttributesExtractor<REQUEST, RESPONSE> netClientAttributesExtractor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ public static CapturedHttpHeaders client(Config config) {
// fall back to the experimental properties if the stable one isn't supplied
return CapturedHttpHeaders.create(
config.getList(
CLIENT_REQUEST_PROPERTY, config.getList(EXPERIMENTAL_CLIENT_REQUEST_PROPERTY)),
CLIENT_REQUEST_PROPERTY,
config.getList(EXPERIMENTAL_CLIENT_REQUEST_PROPERTY, emptyList())),
config.getList(
CLIENT_RESPONSE_PROPERTY, config.getList(EXPERIMENTAL_CLIENT_RESPONSE_PROPERTY)));
CLIENT_RESPONSE_PROPERTY,
config.getList(EXPERIMENTAL_CLIENT_RESPONSE_PROPERTY, emptyList())));
}

private static final String SERVER_REQUEST_PROPERTY =
Expand All @@ -77,9 +79,11 @@ public static CapturedHttpHeaders server(Config config) {
// fall back to the experimental properties if the stable one isn't supplied
return CapturedHttpHeaders.create(
config.getList(
SERVER_REQUEST_PROPERTY, config.getList(EXPERIMENTAL_SERVER_REQUEST_PROPERTY)),
SERVER_REQUEST_PROPERTY,
config.getList(EXPERIMENTAL_SERVER_REQUEST_PROPERTY, emptyList())),
config.getList(
SERVER_RESPONSE_PROPERTY, config.getList(EXPERIMENTAL_SERVER_RESPONSE_PROPERTY)));
SERVER_RESPONSE_PROPERTY,
config.getList(EXPERIMENTAL_SERVER_RESPONSE_PROPERTY, emptyList())));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@

package io.opentelemetry.instrumentation.api.tracer.net;

import static java.util.Collections.emptyMap;

import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.SpanBuilder;
import io.opentelemetry.instrumentation.api.config.Config;
import io.opentelemetry.instrumentation.api.tracer.AttributeSetter;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.Collections;
import java.util.Map;
import javax.annotation.Nullable;

Expand All @@ -28,12 +29,12 @@ public final class NetPeerAttributes {

public static final NetPeerAttributes INSTANCE =
new NetPeerAttributes(
Config.get().getMap("otel.instrumentation.common.peer-service-mapping"));
Config.get().getMap("otel.instrumentation.common.peer-service-mapping", emptyMap()));

private final Map<String, String> peerServiceMapping;

public NetPeerAttributes() {
this(Collections.emptyMap());
this(emptyMap());
}

public NetPeerAttributes(Map<String, String> peerServiceMapping) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package io.opentelemetry.javaagent.instrumentation.javaconcurrent;

import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.implementsInterface;
import static java.util.Collections.emptyList;
import static net.bytebuddy.matcher.ElementMatchers.any;
import static net.bytebuddy.matcher.ElementMatchers.named;

Expand Down Expand Up @@ -99,7 +100,7 @@ protected AbstractExecutorInstrumentation() {
"scala.concurrent.impl.ExecutionContextImpl",
};
Set<String> combined = new HashSet<>(Arrays.asList(includeExecutors));
combined.addAll(Config.get().getList(EXECUTORS_INCLUDE_PROPERTY_NAME));
combined.addAll(Config.get().getList(EXECUTORS_INCLUDE_PROPERTY_NAME, emptyList()));
this.includeExecutors = Collections.unmodifiableSet(combined);

String[] includePrefixes = {"slick.util.AsyncExecutor$"};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package io.opentelemetry.javaagent.instrumentation.servlet;

import static java.util.Collections.emptyList;

import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.instrumentation.api.config.Config;
Expand All @@ -20,7 +22,9 @@ public class ServletRequestParametersExtractor<REQUEST, RESPONSE>
implements AttributesExtractor<
ServletRequestContext<REQUEST>, ServletResponseContext<RESPONSE>> {
private static final List<String> CAPTURE_REQUEST_PARAMETERS =
Config.get().getList("otel.instrumentation.servlet.experimental.capture-request-parameters");
Config.get()
.getList(
"otel.instrumentation.servlet.experimental.capture-request-parameters", emptyList());

private static final ConcurrentMap<String, AttributeKey<List<String>>> parameterKeysCache =
new ConcurrentHashMap<>();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package io.opentelemetry.javaagent.tooling.ignore;

import static java.util.Collections.emptyList;

import com.google.auto.service.AutoService;
import io.opentelemetry.instrumentation.api.config.Config;
import io.opentelemetry.javaagent.extension.ignore.IgnoredTypesBuilder;
Expand All @@ -19,7 +21,7 @@ public class UserExcludedClassesConfigurer implements IgnoredTypesConfigurer {

@Override
public void configure(Config config, IgnoredTypesBuilder builder) {
List<String> excludedClasses = config.getList(EXCLUDED_CLASSES_CONFIG);
List<String> excludedClasses = config.getList(EXCLUDED_CLASSES_CONFIG, emptyList());
for (String excludedClass : excludedClasses) {
excludedClass = excludedClass.trim();
// remove the trailing *
Expand Down
Loading

0 comments on commit 93a3282

Please sign in to comment.