Skip to content

Commit 141a99b

Browse files
update upstream 2.10.0 (#455)
* chore: Update upstream OpenTelemetry agent version and related depend... ... encies Made with ❤️️ by updatecli * remove obsolete code * update span stacktrace + test feature works * remove obsolete code * update agent auto-config * remove obsolete test * fix another test * post-review changes --------- Co-authored-by: elastic-observability-automation[bot] <180520183+elastic-observability-automation[bot]@users.noreply.github.com>
1 parent 63fd491 commit 141a99b

15 files changed

+203
-595
lines changed

common/build.gradle.kts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ dependencies {
1212
compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi")
1313
implementation(libs.bundles.semconv)
1414

15-
compileOnly(libs.contribSpanStacktrace)
16-
testImplementation(libs.contribSpanStacktrace)
17-
1815
testImplementation("io.opentelemetry:opentelemetry-sdk")
1916
testImplementation("io.opentelemetry:opentelemetry-sdk-testing")
2017
testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure")

common/src/main/java/co/elastic/otel/common/SpanValue.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ Its size is the number of dense SpanValues plus one (for the Map at index 0).
7474
*/
7575

7676
private static final Class<?> SDK_SPAN_CLASS = getSdkSpanClass();
77-
private static final Class<?> CONTRIB_MUTABLE_SPAN_CLASS = getContribMutableSpanClass();
7877

7978
private static final SpanValueStorageProvider storageProvider = SpanValueStorageProvider.get();
8079

@@ -261,7 +260,7 @@ private static SpanValueStorage getStorage(Object span, boolean initialize) {
261260
return storageProvider.get(unwrapped, initialize);
262261
}
263262

264-
/** Provides the underlying {@link SdkSpan} instance in case the given span is wrapped. */
263+
/** Provides the underlying {@code SdkSpan} instance in case the given span is wrapped. */
265264
private static Span unwrap(Object span) {
266265
if (span.getClass() == SDK_SPAN_CLASS) {
267266
if (!((Span) span).getSpanContext().isValid()) {
@@ -272,9 +271,6 @@ private static Span unwrap(Object span) {
272271
if (span instanceof MutableSpan) {
273272
return unwrap(((MutableSpan) span).getOriginalSpan());
274273
}
275-
if (CONTRIB_MUTABLE_SPAN_CLASS != null && CONTRIB_MUTABLE_SPAN_CLASS.isInstance(span)) {
276-
return unwrap(ContribMutableSpanAccessor.getOriginalSpan(span));
277-
}
278274
if (span instanceof Span && !((Span) span).getSpanContext().isValid()) {
279275
throw new IllegalArgumentException("SpanValues don't work with invalid spans!");
280276
}
@@ -298,10 +294,4 @@ private static Class<?> getContribMutableSpanClass() {
298294
return null;
299295
}
300296
}
301-
302-
private static class ContribMutableSpanAccessor {
303-
public static ReadableSpan getOriginalSpan(Object span) {
304-
return ((io.opentelemetry.contrib.stacktrace.internal.MutableSpan) span).getOriginalSpan();
305-
}
306-
}
307297
}

common/src/test/java/co/elastic/otel/common/ChainingSpanProcessorAutoConfigurationTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,10 @@ protected boolean requiresStart() {
106106

107107
List<SpanProcessor> spanProcessors = OtelReflectionUtils.getSpanProcessors(otel);
108108
assertThat(spanProcessors)
109-
.containsExactlyInAnyOrder(
110-
chainingProcessor.get(), SpanProcessor.composite() // NOOP-processor
111-
);
109+
.hasSize(2)
110+
.anySatisfy(proc -> assertThat(proc).isEqualTo(chainingProcessor.get()))
111+
// NOOP-processor
112+
.anySatisfy(proc -> assertThat(proc).isEqualTo(SpanProcessor.composite()));
112113

113114
SpanProcessor terminal = chainingProcessor.get().next;
114115
assertThat(terminal).isInstanceOf(MutableCompositeSpanProcessor.class);

common/src/test/java/co/elastic/otel/common/SpanValueTest.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,7 @@ public static Stream<Arguments> testArgs() {
118118
"MutableSpan, sparse SpanValue",
119119
ValueAccess.create(
120120
SpanValue.<String>createSparse(),
121-
MutableSpan.makeMutable((ReadableSpan) newSpan())))),
122-
Arguments.of(
123-
Named.of(
124-
"Contrib MutableSpan, sparse SpanValue",
125-
ValueAccess.create(
126-
SpanValue.<String>createSparse(),
127-
io.opentelemetry.contrib.stacktrace.internal.MutableSpan.makeMutable(
128-
(ReadableSpan) newSpan())))));
121+
MutableSpan.makeMutable((ReadableSpan) newSpan())))));
129122
}
130123

131124
@ParameterizedTest

custom/src/main/java/co/elastic/otel/ElasticAgentListener.java

Lines changed: 0 additions & 41 deletions
This file was deleted.

custom/src/main/java/co/elastic/otel/ElasticAutoConfigurationCustomizerProvider.java

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,63 @@ public class ElasticAutoConfigurationCustomizerProvider
3535
private static final String RUNTIME_EXPERIMENTAL_TELEMETRY =
3636
"otel.instrumentation.runtime-telemetry.emit-experimental-telemetry";
3737

38+
// must match value in io.opentelemetry.contrib.stacktrace.StackTraceAutoConfig
39+
private static final String STACKTRACE_OTEL_FILTER =
40+
"otel.java.experimental.span-stacktrace.filter";
41+
static final String STACKTRACE_OTEL_DURATION =
42+
"otel.java.experimental.span-stacktrace.min.duration";
43+
static final String STACKTRACE_LEGACY1_DURATION =
44+
"elastic.otel.java.span-stacktrace.min.duration";
45+
static final String STACKTRACE_LEGACY2_DURATION =
46+
"elastic.otel.java.span.stacktrace.min.duration";
47+
3848
@Override
3949
public void customize(AutoConfigurationCustomizer autoConfiguration) {
4050
autoConfiguration.addPropertiesCustomizer(
4151
ElasticAutoConfigurationCustomizerProvider::propertiesCustomizer);
4252
}
4353

4454
static Map<String, String> propertiesCustomizer(ConfigProperties configProperties) {
45-
Set<String> disabledResourceProviders =
46-
new HashSet<>(configProperties.getList(DISABLED_RESOURCE_PROVIDERS));
55+
Map<String, String> config = new HashMap<>();
4756

48-
// disable upstream distro name & version provider
49-
disabledResourceProviders.add(
50-
"io.opentelemetry.javaagent.tooling.DistroVersionResourceProvider");
57+
experimentalTelemetry(config, configProperties);
58+
resourceProviders(config, configProperties);
59+
spanStackTrace(config, configProperties);
5160

52-
Map<String, String> config = new HashMap<>();
61+
return config;
62+
}
5363

64+
private static void experimentalTelemetry(
65+
Map<String, String> config, ConfigProperties configProperties) {
5466
// enable experimental telemetry metrics by default if not explicitly disabled
5567
boolean experimentalTelemetry =
5668
configProperties.getBoolean(RUNTIME_EXPERIMENTAL_TELEMETRY, true);
5769
config.put(RUNTIME_EXPERIMENTAL_TELEMETRY, Boolean.toString(experimentalTelemetry));
70+
}
5871

72+
private static void resourceProviders(
73+
Map<String, String> config, ConfigProperties configProperties) {
74+
Set<String> disabledResourceProviders =
75+
new HashSet<>(configProperties.getList(DISABLED_RESOURCE_PROVIDERS));
76+
77+
// disable upstream distro name & version provider
78+
disabledResourceProviders.add(
79+
"io.opentelemetry.javaagent.tooling.DistroVersionResourceProvider");
5980
config.put(DISABLED_RESOURCE_PROVIDERS, String.join(",", disabledResourceProviders));
81+
}
6082

61-
return config;
83+
private static void spanStackTrace(
84+
Map<String, String> config, ConfigProperties configProperties) {
85+
86+
String value = configProperties.getString(STACKTRACE_OTEL_DURATION);
87+
if (value == null) {
88+
value = configProperties.getString(STACKTRACE_LEGACY1_DURATION);
89+
if (value == null) {
90+
value = configProperties.getString(STACKTRACE_LEGACY2_DURATION);
91+
}
92+
config.put(STACKTRACE_OTEL_DURATION, value);
93+
}
94+
95+
config.put(STACKTRACE_OTEL_FILTER, SpanStackTraceFilter.class.getName());
6296
}
6397
}

0 commit comments

Comments
 (0)