Skip to content

Commit

Permalink
update upstream 2.10.0 (#455)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
1 parent 63fd491 commit 141a99b
Show file tree
Hide file tree
Showing 15 changed files with 203 additions and 595 deletions.
3 changes: 0 additions & 3 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ dependencies {
compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi")
implementation(libs.bundles.semconv)

compileOnly(libs.contribSpanStacktrace)
testImplementation(libs.contribSpanStacktrace)

testImplementation("io.opentelemetry:opentelemetry-sdk")
testImplementation("io.opentelemetry:opentelemetry-sdk-testing")
testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure")
Expand Down
12 changes: 1 addition & 11 deletions common/src/main/java/co/elastic/otel/common/SpanValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ Its size is the number of dense SpanValues plus one (for the Map at index 0).
*/

private static final Class<?> SDK_SPAN_CLASS = getSdkSpanClass();
private static final Class<?> CONTRIB_MUTABLE_SPAN_CLASS = getContribMutableSpanClass();

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

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

/** Provides the underlying {@link SdkSpan} instance in case the given span is wrapped. */
/** Provides the underlying {@code SdkSpan} instance in case the given span is wrapped. */
private static Span unwrap(Object span) {
if (span.getClass() == SDK_SPAN_CLASS) {
if (!((Span) span).getSpanContext().isValid()) {
Expand All @@ -272,9 +271,6 @@ private static Span unwrap(Object span) {
if (span instanceof MutableSpan) {
return unwrap(((MutableSpan) span).getOriginalSpan());
}
if (CONTRIB_MUTABLE_SPAN_CLASS != null && CONTRIB_MUTABLE_SPAN_CLASS.isInstance(span)) {
return unwrap(ContribMutableSpanAccessor.getOriginalSpan(span));
}
if (span instanceof Span && !((Span) span).getSpanContext().isValid()) {
throw new IllegalArgumentException("SpanValues don't work with invalid spans!");
}
Expand All @@ -298,10 +294,4 @@ private static Class<?> getContribMutableSpanClass() {
return null;
}
}

private static class ContribMutableSpanAccessor {
public static ReadableSpan getOriginalSpan(Object span) {
return ((io.opentelemetry.contrib.stacktrace.internal.MutableSpan) span).getOriginalSpan();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@ protected boolean requiresStart() {

List<SpanProcessor> spanProcessors = OtelReflectionUtils.getSpanProcessors(otel);
assertThat(spanProcessors)
.containsExactlyInAnyOrder(
chainingProcessor.get(), SpanProcessor.composite() // NOOP-processor
);
.hasSize(2)
.anySatisfy(proc -> assertThat(proc).isEqualTo(chainingProcessor.get()))
// NOOP-processor
.anySatisfy(proc -> assertThat(proc).isEqualTo(SpanProcessor.composite()));

SpanProcessor terminal = chainingProcessor.get().next;
assertThat(terminal).isInstanceOf(MutableCompositeSpanProcessor.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,7 @@ public static Stream<Arguments> testArgs() {
"MutableSpan, sparse SpanValue",
ValueAccess.create(
SpanValue.<String>createSparse(),
MutableSpan.makeMutable((ReadableSpan) newSpan())))),
Arguments.of(
Named.of(
"Contrib MutableSpan, sparse SpanValue",
ValueAccess.create(
SpanValue.<String>createSparse(),
io.opentelemetry.contrib.stacktrace.internal.MutableSpan.makeMutable(
(ReadableSpan) newSpan())))));
MutableSpan.makeMutable((ReadableSpan) newSpan())))));
}

@ParameterizedTest
Expand Down
41 changes: 0 additions & 41 deletions custom/src/main/java/co/elastic/otel/ElasticAgentListener.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,63 @@ public class ElasticAutoConfigurationCustomizerProvider
private static final String RUNTIME_EXPERIMENTAL_TELEMETRY =
"otel.instrumentation.runtime-telemetry.emit-experimental-telemetry";

// must match value in io.opentelemetry.contrib.stacktrace.StackTraceAutoConfig
private static final String STACKTRACE_OTEL_FILTER =
"otel.java.experimental.span-stacktrace.filter";
static final String STACKTRACE_OTEL_DURATION =
"otel.java.experimental.span-stacktrace.min.duration";
static final String STACKTRACE_LEGACY1_DURATION =
"elastic.otel.java.span-stacktrace.min.duration";
static final String STACKTRACE_LEGACY2_DURATION =
"elastic.otel.java.span.stacktrace.min.duration";

@Override
public void customize(AutoConfigurationCustomizer autoConfiguration) {
autoConfiguration.addPropertiesCustomizer(
ElasticAutoConfigurationCustomizerProvider::propertiesCustomizer);
}

static Map<String, String> propertiesCustomizer(ConfigProperties configProperties) {
Set<String> disabledResourceProviders =
new HashSet<>(configProperties.getList(DISABLED_RESOURCE_PROVIDERS));
Map<String, String> config = new HashMap<>();

// disable upstream distro name & version provider
disabledResourceProviders.add(
"io.opentelemetry.javaagent.tooling.DistroVersionResourceProvider");
experimentalTelemetry(config, configProperties);
resourceProviders(config, configProperties);
spanStackTrace(config, configProperties);

Map<String, String> config = new HashMap<>();
return config;
}

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

private static void resourceProviders(
Map<String, String> config, ConfigProperties configProperties) {
Set<String> disabledResourceProviders =
new HashSet<>(configProperties.getList(DISABLED_RESOURCE_PROVIDERS));

// disable upstream distro name & version provider
disabledResourceProviders.add(
"io.opentelemetry.javaagent.tooling.DistroVersionResourceProvider");
config.put(DISABLED_RESOURCE_PROVIDERS, String.join(",", disabledResourceProviders));
}

return config;
private static void spanStackTrace(
Map<String, String> config, ConfigProperties configProperties) {

String value = configProperties.getString(STACKTRACE_OTEL_DURATION);
if (value == null) {
value = configProperties.getString(STACKTRACE_LEGACY1_DURATION);
if (value == null) {
value = configProperties.getString(STACKTRACE_LEGACY2_DURATION);
}
config.put(STACKTRACE_OTEL_DURATION, value);
}

config.put(STACKTRACE_OTEL_FILTER, SpanStackTraceFilter.class.getName());
}
}
Loading

0 comments on commit 141a99b

Please sign in to comment.