Skip to content

Commit 59cb9ca

Browse files
author
Mateusz Rzeszutek
authored
Remove deprecated code (#6501)
* Remove deprecated code * unnecessary semicolon * fix distro and extension examples
1 parent edc5a6c commit 59cb9ca

File tree

40 files changed

+129
-1454
lines changed

40 files changed

+129
-1454
lines changed

examples/distro/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ customize that
1919

2020
* [DemoIdGenerator](custom/src/main/java/com/example/javaagent/DemoIdGenerator.java) - custom `IdGenerator`
2121
* [DemoPropagator](custom/src/main/java/com/example/javaagent/DemoPropagator.java) - custom `TextMapPropagator`
22-
* [DemoPropertySource](custom/src/main/java/com/example/javaagent/DemoPropertySource.java) - default configuration
2322
* [DemoSampler](custom/src/main/java/com/example/javaagent/DemoSampler.java) - custom `Sampler`
2423
* [DemoSpanProcessor](custom/src/main/java/com/example/javaagent/DemoSpanProcessor.java) - custom `SpanProcessor`
2524
* [DemoSpanExporter](custom/src/main/java/com/example/javaagent/DemoSpanExporter.java) - custom `SpanExporter`

examples/distro/custom/src/main/java/com/example/javaagent/DemoAutoConfigurationCustomizerProvider.java

+13-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import io.opentelemetry.sdk.trace.SdkTracerProviderBuilder;
1212
import io.opentelemetry.sdk.trace.SpanLimits;
1313
import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor;
14+
import java.util.HashMap;
15+
import java.util.Map;
1416

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

2830
@Override
2931
public void customize(AutoConfigurationCustomizer autoConfiguration) {
30-
autoConfiguration.addTracerProviderCustomizer(this::configureSdkTracerProvider);
32+
autoConfiguration
33+
.addTracerProviderCustomizer(this::configureSdkTracerProvider)
34+
.addPropertiesSupplier(this::getDefaultProperties);
3135
}
3236

3337
private SdkTracerProviderBuilder configureSdkTracerProvider(
@@ -39,4 +43,12 @@ private SdkTracerProviderBuilder configureSdkTracerProvider(
3943
.addSpanProcessor(new DemoSpanProcessor())
4044
.addSpanProcessor(SimpleSpanProcessor.create(new DemoSpanExporter()));
4145
}
46+
47+
private Map<String, String> getDefaultProperties() {
48+
Map<String, String> properties = new HashMap<>();
49+
properties.put("otel.exporter.otlp.endpoint", "http://backend:8080");
50+
properties.put("otel.exporter.otlp.insecure", "true");
51+
properties.put("otel.config.max.attrs", "16");
52+
return properties;
53+
}
4254
}

examples/distro/custom/src/main/java/com/example/javaagent/DemoPropertySource.java

-28
This file was deleted.

examples/distro/custom/src/main/resources/META-INF/services/io.opentelemetry.javaagent.extension.config.ConfigPropertySource

-1
This file was deleted.

examples/extension/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ For more information, see the `extendedAgent` task in [build.gradle](build.gradl
3232

3333
* Custom `IdGenerator`: [DemoIdGenerator](src/main/java/com/example/javaagent/DemoIdGenerator.java)
3434
* Custom `TextMapPropagator`: [DemoPropagator](src/main/java/com/example/javaagent/DemoPropagator.java)
35-
* New default configuration: [DemoPropertySource](src/main/java/com/example/javaagent/DemoPropertySource.java)
3635
* Custom `Sampler`: [DemoSampler](src/main/java/com/example/javaagent/DemoSampler.java)
3736
* Custom `SpanProcessor`: [DemoSpanProcessor](src/main/java/com/example/javaagent/DemoSpanProcessor.java)
3837
* Custom `SpanExporter`: [DemoSpanExporter](src/main/java/com/example/javaagent/DemoSpanExporter.java)

examples/extension/src/main/java/com/example/javaagent/DemoAutoConfigurationCustomizerProvider.java

+14-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import io.opentelemetry.sdk.trace.SdkTracerProviderBuilder;
1313
import io.opentelemetry.sdk.trace.SpanLimits;
1414
import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor;
15+
import java.util.HashMap;
16+
import java.util.Map;
1517

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

3032
@Override
3133
public void customize(AutoConfigurationCustomizer autoConfiguration) {
32-
autoConfiguration.addTracerProviderCustomizer(this::configureSdkTracerProvider);
34+
autoConfiguration
35+
.addTracerProviderCustomizer(this::configureSdkTracerProvider)
36+
.addPropertiesSupplier(this::getDefaultProperties);
3337
}
3438

3539
private SdkTracerProviderBuilder configureSdkTracerProvider(
@@ -41,4 +45,13 @@ private SdkTracerProviderBuilder configureSdkTracerProvider(
4145
.addSpanProcessor(new DemoSpanProcessor())
4246
.addSpanProcessor(SimpleSpanProcessor.create(new DemoSpanExporter()));
4347
}
48+
49+
private Map<String, String> getDefaultProperties() {
50+
Map<String, String> properties = new HashMap<>();
51+
properties.put("otel.exporter.otlp.endpoint", "http://backend:8080");
52+
properties.put("otel.exporter.otlp.insecure", "true");
53+
properties.put("otel.config.max.attrs", "16");
54+
properties.put("otel.traces.sampler", "demo");
55+
return properties;
56+
}
4457
}

examples/extension/src/main/java/com/example/javaagent/DemoPropertySource.java

-31
This file was deleted.

instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesExtractor.java

-17
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
package io.opentelemetry.instrumentation.api.instrumenter;
77

8-
import static java.util.Collections.emptyMap;
9-
108
import io.opentelemetry.api.common.AttributesBuilder;
119
import io.opentelemetry.context.Context;
1210
import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter;
@@ -33,21 +31,6 @@ public final class PeerServiceAttributesExtractor<REQUEST, RESPONSE>
3331
this.peerServiceMapping = peerServiceMapping;
3432
}
3533

36-
/**
37-
* Returns a new {@link PeerServiceAttributesExtractor} that will use the passed {@code
38-
* netAttributesExtractor} instance to determine the value of the {@code peer.service} attribute.
39-
*
40-
* @deprecated Use {@link #create(NetClientAttributesGetter, Map)} instead.
41-
*/
42-
@Deprecated
43-
public static <REQUEST, RESPONSE> PeerServiceAttributesExtractor<REQUEST, RESPONSE> create(
44-
NetClientAttributesGetter<REQUEST, RESPONSE> attributesGetter) {
45-
return create(
46-
attributesGetter,
47-
io.opentelemetry.instrumentation.api.config.Config.get()
48-
.getMap("otel.instrumentation.common.peer-service-mapping", emptyMap()));
49-
}
50-
5134
/**
5235
* Returns a new {@link PeerServiceAttributesExtractor} that will use the passed {@code
5336
* netAttributesExtractor} instance to determine the value of the {@code peer.service} attribute.

instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpCommonAttributesGetter.java

+1-75
Original file line numberDiff line numberDiff line change
@@ -29,88 +29,14 @@ public interface HttpCommonAttributesGetter<REQUEST, RESPONSE> {
2929

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

32-
/**
33-
* Extracts the {@code http.request_content_length} span attribute.
34-
*
35-
* <p>This is called from {@link Instrumenter#end(Context, Object, Object, Throwable)}, whether
36-
* {@code response} is {@code null} or not.
37-
*
38-
* @deprecated Request content length is now being calculated based on the request headers. This
39-
* method is deprecated and will be removed in the next release.
40-
*/
41-
@Deprecated
42-
@Nullable
43-
default Long requestContentLength(REQUEST request, @Nullable RESPONSE response) {
44-
throw new UnsupportedOperationException("This method is deprecated and will be removed");
45-
}
46-
47-
/**
48-
* Extracts the {@code http.request_content_length_uncompressed} span attribute.
49-
*
50-
* <p>This is called from {@link Instrumenter#end(Context, Object, Object, Throwable)}, whether
51-
* {@code response} is {@code null} or not.
52-
*
53-
* @deprecated This method is deprecated and will be removed in the next release.
54-
*/
55-
@Deprecated
56-
@Nullable
57-
default Long requestContentLengthUncompressed(REQUEST request, @Nullable RESPONSE response) {
58-
throw new UnsupportedOperationException("This method is deprecated and will be removed");
59-
}
60-
6132
/**
6233
* Extracts the {@code http.status_code} span attribute.
6334
*
6435
* <p>This is called from {@link Instrumenter#end(Context, Object, Object, Throwable)}, only when
6536
* {@code response} is non-{@code null}.
66-
*
67-
* @deprecated This method is deprecated and will be removed in the next release.
68-
*/
69-
@Deprecated
70-
@Nullable
71-
default Integer statusCode(REQUEST request, RESPONSE response) {
72-
throw new UnsupportedOperationException("This method is deprecated and will be removed");
73-
}
74-
75-
/**
76-
* Extracts the {@code http.status_code} span attribute.
77-
*
78-
* <p>This is called from {@link Instrumenter#end(Context, Object, Object, Throwable)}, only when
79-
* {@code response} is non-{@code null}.
80-
*/
81-
@Nullable
82-
default Integer statusCode(REQUEST request, RESPONSE response, @Nullable Throwable error) {
83-
return statusCode(request, response);
84-
}
85-
86-
/**
87-
* Extracts the {@code http.response_content_length} span attribute.
88-
*
89-
* <p>This is called from {@link Instrumenter#end(Context, Object, Object, Throwable)}, only when
90-
* {@code response} is non-{@code null}.
91-
*
92-
* @deprecated Request content length is now being calculated based on the request headers. This
93-
* method is deprecated and will be removed in the next release.
94-
*/
95-
@Deprecated
96-
@Nullable
97-
default Long responseContentLength(REQUEST request, RESPONSE response) {
98-
throw new UnsupportedOperationException("This method is deprecated and will be removed");
99-
}
100-
101-
/**
102-
* Extracts the {@code http.response_content_length_uncompressed} span attribute.
103-
*
104-
* <p>This is called from {@link Instrumenter#end(Context, Object, Object, Throwable)}, only when
105-
* {@code response} is non-{@code null}.
106-
*
107-
* @deprecated This method is deprecated and will be removed in the next release.
10837
*/
109-
@Deprecated
11038
@Nullable
111-
default Long responseContentLengthUncompressed(REQUEST request, RESPONSE response) {
112-
throw new UnsupportedOperationException("This method is deprecated and will be removed");
113-
}
39+
Integer statusCode(REQUEST request, RESPONSE response, @Nullable Throwable error);
11440

11541
/**
11642
* Extracts all values of header named {@code name} from the response, or an empty list if there

instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesGetter.java

+1-12
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,9 @@ public interface NetClientAttributesGetter<REQUEST, RESPONSE> {
2626
@Nullable
2727
Integer peerPort(REQUEST request, @Nullable RESPONSE response);
2828

29-
/**
30-
* Returns the peerIp.
31-
*
32-
* @deprecated implement {@link #sockPeerAddr(Object, Object)} instead.
33-
*/
34-
@Deprecated
35-
@Nullable
36-
default String peerIp(REQUEST request, @Nullable RESPONSE response) {
37-
return null;
38-
}
39-
4029
@Nullable
4130
default String sockPeerAddr(REQUEST request, @Nullable RESPONSE response) {
42-
return peerIp(request, response);
31+
return null;
4332
}
4433

4534
@Nullable

instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java

+2-30
Original file line numberDiff line numberDiff line change
@@ -20,37 +20,9 @@ public interface NetServerAttributesGetter<REQUEST> {
2020
@Nullable
2121
String transport(REQUEST request);
2222

23-
/**
24-
* Returns the peerPort.
25-
*
26-
* @deprecated implement {@link #sockPeerPort(Object)} instead.
27-
*/
28-
@Deprecated
2923
@Nullable
30-
default Integer peerPort(REQUEST request) {
31-
return null;
32-
}
24+
Integer sockPeerPort(REQUEST request);
3325

34-
/**
35-
* Returns the peerIp.
36-
*
37-
* @deprecated implement {@link #sockPeerAddr(Object)} instead.
38-
*/
39-
@Deprecated
4026
@Nullable
41-
default String peerIp(REQUEST request) {
42-
return null;
43-
}
44-
45-
@Nullable
46-
default Integer sockPeerPort(REQUEST request) {
47-
// TODO (trask) remove default after removing peerPort() method
48-
return peerPort(request);
49-
}
50-
51-
@Nullable
52-
default String sockPeerAddr(REQUEST request) {
53-
// TODO (trask) remove default after removing peerIp() method
54-
return peerIp(request);
55-
}
27+
String sockPeerAddr(REQUEST request);
5628
}

instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/util/SpanNames.java

-25
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@
55

66
package io.opentelemetry.instrumentation.api.util;
77

8-
import io.opentelemetry.instrumentation.api.instrumenter.code.CodeSpanNameExtractor;
98
import io.opentelemetry.instrumentation.api.internal.cache.Cache;
109
import java.lang.reflect.Method;
1110
import java.util.Map;
1211
import java.util.concurrent.ConcurrentHashMap;
13-
import javax.annotation.Nullable;
1412

1513
public final class SpanNames {
1614

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

27-
/**
28-
* This method is used to generate a span name based on a method. Anonymous classes are named
29-
* based on their parent.
30-
*
31-
* @deprecated Use {@link #fromMethod(Class, String)} instead.
32-
*/
33-
@Deprecated
34-
public static String fromMethod(Class<?> clazz, @Nullable Method method) {
35-
return fromMethod(clazz, method == null ? "<unknown>" : method.getName());
36-
}
37-
38-
/**
39-
* This method is used to generate a span name based on a method. Anonymous classes are named
40-
* based on their parent.
41-
*
42-
* @deprecated Use {@link ClassAndMethod#codeAttributesGetter()} and {@link CodeSpanNameExtractor}
43-
* instead.
44-
*/
45-
@Deprecated
46-
public static String fromMethod(ClassAndMethod classAndMethod) {
47-
return fromMethod(classAndMethod.declaringClass(), classAndMethod.methodName());
48-
}
49-
5025
/**
5126
* This method is used to generate a span name based on a method. Anonymous classes are named
5227
* based on their parent.

0 commit comments

Comments
 (0)