Skip to content

Commit

Permalink
Remove deprecated code (open-telemetry#6501)
Browse files Browse the repository at this point in the history
* Remove deprecated code

* unnecessary semicolon

* fix distro and extension examples
  • Loading branch information
Mateusz Rzeszutek authored and LironKS committed Dec 4, 2022
1 parent 95357aa commit 5d6ad88
Show file tree
Hide file tree
Showing 40 changed files with 129 additions and 1,454 deletions.
1 change: 0 additions & 1 deletion examples/distro/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ customize that

* [DemoIdGenerator](custom/src/main/java/com/example/javaagent/DemoIdGenerator.java) - custom `IdGenerator`
* [DemoPropagator](custom/src/main/java/com/example/javaagent/DemoPropagator.java) - custom `TextMapPropagator`
* [DemoPropertySource](custom/src/main/java/com/example/javaagent/DemoPropertySource.java) - default configuration
* [DemoSampler](custom/src/main/java/com/example/javaagent/DemoSampler.java) - custom `Sampler`
* [DemoSpanProcessor](custom/src/main/java/com/example/javaagent/DemoSpanProcessor.java) - custom `SpanProcessor`
* [DemoSpanExporter](custom/src/main/java/com/example/javaagent/DemoSpanExporter.java) - custom `SpanExporter`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import io.opentelemetry.sdk.trace.SdkTracerProviderBuilder;
import io.opentelemetry.sdk.trace.SpanLimits;
import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor;
import java.util.HashMap;
import java.util.Map;

/**
* This is one of the main entry points for Instrumentation Agent's customizations. It allows
Expand All @@ -27,7 +29,9 @@ public class DemoAutoConfigurationCustomizerProvider

@Override
public void customize(AutoConfigurationCustomizer autoConfiguration) {
autoConfiguration.addTracerProviderCustomizer(this::configureSdkTracerProvider);
autoConfiguration
.addTracerProviderCustomizer(this::configureSdkTracerProvider)
.addPropertiesSupplier(this::getDefaultProperties);
}

private SdkTracerProviderBuilder configureSdkTracerProvider(
Expand All @@ -39,4 +43,12 @@ private SdkTracerProviderBuilder configureSdkTracerProvider(
.addSpanProcessor(new DemoSpanProcessor())
.addSpanProcessor(SimpleSpanProcessor.create(new DemoSpanExporter()));
}

private Map<String, String> getDefaultProperties() {
Map<String, String> properties = new HashMap<>();
properties.put("otel.exporter.otlp.endpoint", "http://backend:8080");
properties.put("otel.exporter.otlp.insecure", "true");
properties.put("otel.config.max.attrs", "16");
return properties;
}
}

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion examples/extension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ For more information, see the `extendedAgent` task in [build.gradle](build.gradl

* Custom `IdGenerator`: [DemoIdGenerator](src/main/java/com/example/javaagent/DemoIdGenerator.java)
* Custom `TextMapPropagator`: [DemoPropagator](src/main/java/com/example/javaagent/DemoPropagator.java)
* New default configuration: [DemoPropertySource](src/main/java/com/example/javaagent/DemoPropertySource.java)
* Custom `Sampler`: [DemoSampler](src/main/java/com/example/javaagent/DemoSampler.java)
* Custom `SpanProcessor`: [DemoSpanProcessor](src/main/java/com/example/javaagent/DemoSpanProcessor.java)
* Custom `SpanExporter`: [DemoSpanExporter](src/main/java/com/example/javaagent/DemoSpanExporter.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import io.opentelemetry.sdk.trace.SdkTracerProviderBuilder;
import io.opentelemetry.sdk.trace.SpanLimits;
import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor;
import java.util.HashMap;
import java.util.Map;

/**
* This is one of the main entry points for Instrumentation Agent's customizations. It allows
Expand All @@ -29,7 +31,9 @@ public class DemoAutoConfigurationCustomizerProvider

@Override
public void customize(AutoConfigurationCustomizer autoConfiguration) {
autoConfiguration.addTracerProviderCustomizer(this::configureSdkTracerProvider);
autoConfiguration
.addTracerProviderCustomizer(this::configureSdkTracerProvider)
.addPropertiesSupplier(this::getDefaultProperties);
}

private SdkTracerProviderBuilder configureSdkTracerProvider(
Expand All @@ -41,4 +45,13 @@ private SdkTracerProviderBuilder configureSdkTracerProvider(
.addSpanProcessor(new DemoSpanProcessor())
.addSpanProcessor(SimpleSpanProcessor.create(new DemoSpanExporter()));
}

private Map<String, String> getDefaultProperties() {
Map<String, String> properties = new HashMap<>();
properties.put("otel.exporter.otlp.endpoint", "http://backend:8080");
properties.put("otel.exporter.otlp.insecure", "true");
properties.put("otel.config.max.attrs", "16");
properties.put("otel.traces.sampler", "demo");
return properties;
}
}

This file was deleted.

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

package io.opentelemetry.instrumentation.api.instrumenter;

import static java.util.Collections.emptyMap;

import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter;
Expand All @@ -33,21 +31,6 @@ public final class PeerServiceAttributesExtractor<REQUEST, RESPONSE>
this.peerServiceMapping = peerServiceMapping;
}

/**
* Returns a new {@link PeerServiceAttributesExtractor} that will use the passed {@code
* netAttributesExtractor} instance to determine the value of the {@code peer.service} attribute.
*
* @deprecated Use {@link #create(NetClientAttributesGetter, Map)} instead.
*/
@Deprecated
public static <REQUEST, RESPONSE> PeerServiceAttributesExtractor<REQUEST, RESPONSE> create(
NetClientAttributesGetter<REQUEST, RESPONSE> attributesGetter) {
return create(
attributesGetter,
io.opentelemetry.instrumentation.api.config.Config.get()
.getMap("otel.instrumentation.common.peer-service-mapping", emptyMap()));
}

/**
* Returns a new {@link PeerServiceAttributesExtractor} that will use the passed {@code
* netAttributesExtractor} instance to determine the value of the {@code peer.service} attribute.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,88 +34,14 @@ default String requestHeaders(REQUEST request, @Nullable RESPONSE response) {

// Attributes which are not always available when the request is ready.

/**
* Extracts the {@code http.request_content_length} span attribute.
*
* <p>This is called from {@link Instrumenter#end(Context, Object, Object, Throwable)}, whether
* {@code response} is {@code null} or not.
*
* @deprecated Request content length is now being calculated based on the request headers. This
* method is deprecated and will be removed in the next release.
*/
@Deprecated
@Nullable
default Long requestContentLength(REQUEST request, @Nullable RESPONSE response) {
throw new UnsupportedOperationException("This method is deprecated and will be removed");
}

/**
* Extracts the {@code http.request_content_length_uncompressed} span attribute.
*
* <p>This is called from {@link Instrumenter#end(Context, Object, Object, Throwable)}, whether
* {@code response} is {@code null} or not.
*
* @deprecated This method is deprecated and will be removed in the next release.
*/
@Deprecated
@Nullable
default Long requestContentLengthUncompressed(REQUEST request, @Nullable RESPONSE response) {
throw new UnsupportedOperationException("This method is deprecated and will be removed");
}

/**
* Extracts the {@code http.status_code} span attribute.
*
* <p>This is called from {@link Instrumenter#end(Context, Object, Object, Throwable)}, only when
* {@code response} is non-{@code null}.
*
* @deprecated This method is deprecated and will be removed in the next release.
*/
@Deprecated
@Nullable
default Integer statusCode(REQUEST request, RESPONSE response) {
throw new UnsupportedOperationException("This method is deprecated and will be removed");
}

/**
* Extracts the {@code http.status_code} span attribute.
*
* <p>This is called from {@link Instrumenter#end(Context, Object, Object, Throwable)}, only when
* {@code response} is non-{@code null}.
*/
@Nullable
default Integer statusCode(REQUEST request, RESPONSE response, @Nullable Throwable error) {
return statusCode(request, response);
}

/**
* Extracts the {@code http.response_content_length} span attribute.
*
* <p>This is called from {@link Instrumenter#end(Context, Object, Object, Throwable)}, only when
* {@code response} is non-{@code null}.
*
* @deprecated Request content length is now being calculated based on the request headers. This
* method is deprecated and will be removed in the next release.
*/
@Deprecated
@Nullable
default Long responseContentLength(REQUEST request, RESPONSE response) {
throw new UnsupportedOperationException("This method is deprecated and will be removed");
}

/**
* Extracts the {@code http.response_content_length_uncompressed} span attribute.
*
* <p>This is called from {@link Instrumenter#end(Context, Object, Object, Throwable)}, only when
* {@code response} is non-{@code null}.
*
* @deprecated This method is deprecated and will be removed in the next release.
*/
@Deprecated
@Nullable
default Long responseContentLengthUncompressed(REQUEST request, RESPONSE response) {
throw new UnsupportedOperationException("This method is deprecated and will be removed");
}
Integer statusCode(REQUEST request, RESPONSE response, @Nullable Throwable error);

/**
* Extracts all values of header named {@code name} from the response, or an empty list if there
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,9 @@ public interface NetClientAttributesGetter<REQUEST, RESPONSE> {
@Nullable
Integer peerPort(REQUEST request, @Nullable RESPONSE response);

/**
* Returns the peerIp.
*
* @deprecated implement {@link #sockPeerAddr(Object, Object)} instead.
*/
@Deprecated
@Nullable
default String peerIp(REQUEST request, @Nullable RESPONSE response) {
return null;
}

@Nullable
default String sockPeerAddr(REQUEST request, @Nullable RESPONSE response) {
return peerIp(request, response);
return null;
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,9 @@ public interface NetServerAttributesGetter<REQUEST> {
@Nullable
String transport(REQUEST request);

/**
* Returns the peerPort.
*
* @deprecated implement {@link #sockPeerPort(Object)} instead.
*/
@Deprecated
@Nullable
default Integer peerPort(REQUEST request) {
return null;
}
Integer sockPeerPort(REQUEST request);

/**
* Returns the peerIp.
*
* @deprecated implement {@link #sockPeerAddr(Object)} instead.
*/
@Deprecated
@Nullable
default String peerIp(REQUEST request) {
return null;
}

@Nullable
default Integer sockPeerPort(REQUEST request) {
// TODO (trask) remove default after removing peerPort() method
return peerPort(request);
}

@Nullable
default String sockPeerAddr(REQUEST request) {
// TODO (trask) remove default after removing peerIp() method
return peerIp(request);
}
String sockPeerAddr(REQUEST request);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@

package io.opentelemetry.instrumentation.api.util;

import io.opentelemetry.instrumentation.api.instrumenter.code.CodeSpanNameExtractor;
import io.opentelemetry.instrumentation.api.internal.cache.Cache;
import java.lang.reflect.Method;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.Nullable;

public final class SpanNames {

Expand All @@ -24,29 +22,6 @@ public static String fromMethod(Method method) {
return fromMethod(method.getDeclaringClass(), method.getName());
}

/**
* This method is used to generate a span name based on a method. Anonymous classes are named
* based on their parent.
*
* @deprecated Use {@link #fromMethod(Class, String)} instead.
*/
@Deprecated
public static String fromMethod(Class<?> clazz, @Nullable Method method) {
return fromMethod(clazz, method == null ? "<unknown>" : method.getName());
}

/**
* This method is used to generate a span name based on a method. Anonymous classes are named
* based on their parent.
*
* @deprecated Use {@link ClassAndMethod#codeAttributesGetter()} and {@link CodeSpanNameExtractor}
* instead.
*/
@Deprecated
public static String fromMethod(ClassAndMethod classAndMethod) {
return fromMethod(classAndMethod.declaringClass(), classAndMethod.methodName());
}

/**
* This method is used to generate a span name based on a method. Anonymous classes are named
* based on their parent.
Expand Down
Loading

0 comments on commit 5d6ad88

Please sign in to comment.