Skip to content

Commit d7d4915

Browse files
committed
revert inferred spans (flaky)
1 parent 9bc8664 commit d7d4915

File tree

7 files changed

+45
-135
lines changed

7 files changed

+45
-135
lines changed

inferred-spans/build.gradle.kts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,10 @@ description = "OpenTelemetry Java profiling based inferred spans module"
99
otelJava.moduleName.set("io.opentelemetry.contrib.inferredspans")
1010

1111
dependencies {
12-
implementation(project(":declarative-config-bridge"))
13-
1412
annotationProcessor("com.google.auto.service:auto-service")
1513
compileOnly("com.google.auto.service:auto-service-annotations")
1614
compileOnly("io.opentelemetry:opentelemetry-sdk")
1715
compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi")
18-
compileOnly("io.opentelemetry:opentelemetry-sdk-extension-incubator")
1916
compileOnly("io.opentelemetry.semconv:opentelemetry-semconv")
2017
implementation("com.lmax:disruptor")
2118
implementation("org.jctools:jctools-core")
@@ -28,7 +25,6 @@ dependencies {
2825
testImplementation("io.opentelemetry.semconv:opentelemetry-semconv")
2926
testImplementation("io.opentelemetry:opentelemetry-sdk")
3027
testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure")
31-
testImplementation("io.opentelemetry:opentelemetry-sdk-extension-incubator")
3228
testImplementation("io.opentelemetry:opentelemetry-sdk-testing")
3329
testImplementation("io.opentelemetry:opentelemetry-api-incubator")
3430
testImplementation("io.opentelemetry:opentelemetry-exporter-logging")

inferred-spans/src/main/java/io/opentelemetry/contrib/inferredspans/InferredSpansAutoConfig.java

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizer;
1212
import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizerProvider;
1313
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
14-
import io.opentelemetry.sdk.trace.SpanProcessor;
1514
import java.time.Duration;
1615
import java.util.Arrays;
1716
import java.util.List;
@@ -46,7 +45,29 @@ public void customize(AutoConfigurationCustomizer config) {
4645
config.addTracerProviderCustomizer(
4746
(providerBuilder, properties) -> {
4847
if (properties.getBoolean(ENABLED_OPTION, false)) {
49-
providerBuilder.addSpanProcessor(create(properties));
48+
InferredSpansProcessorBuilder builder = InferredSpansProcessor.builder();
49+
50+
PropertiesApplier applier = new PropertiesApplier(properties);
51+
52+
applier.applyBool(LOGGING_OPTION, builder::profilerLoggingEnabled);
53+
applier.applyBool(DIAGNOSTIC_FILES_OPTION, builder::backupDiagnosticFiles);
54+
applier.applyInt(SAFEMODE_OPTION, builder::asyncProfilerSafeMode);
55+
applier.applyBool(POSTPROCESSING_OPTION, builder::postProcessingEnabled);
56+
applier.applyDuration(SAMPLING_INTERVAL_OPTION, builder::samplingInterval);
57+
applier.applyDuration(MIN_DURATION_OPTION, builder::inferredSpansMinDuration);
58+
applier.applyWildcards(INCLUDED_CLASSES_OPTION, builder::includedClasses);
59+
applier.applyWildcards(EXCLUDED_CLASSES_OPTION, builder::excludedClasses);
60+
applier.applyDuration(INTERVAL_OPTION, builder::profilerInterval);
61+
applier.applyDuration(DURATION_OPTION, builder::profilingDuration);
62+
applier.applyString(LIB_DIRECTORY_OPTION, builder::profilerLibDirectory);
63+
64+
String parentOverrideHandlerName = properties.getString(PARENT_OVERRIDE_HANDLER_OPTION);
65+
if (parentOverrideHandlerName != null && !parentOverrideHandlerName.isEmpty()) {
66+
builder.parentOverrideHandler(
67+
constructParentOverrideHandler(parentOverrideHandlerName));
68+
}
69+
70+
providerBuilder.addSpanProcessor(builder.build());
5071
} else {
5172
log.finest(
5273
"Not enabling inferred spans processor because " + ENABLED_OPTION + " is not set");
@@ -55,31 +76,6 @@ public void customize(AutoConfigurationCustomizer config) {
5576
});
5677
}
5778

58-
static SpanProcessor create(ConfigProperties properties) {
59-
InferredSpansProcessorBuilder builder = InferredSpansProcessor.builder();
60-
61-
PropertiesApplier applier = new PropertiesApplier(properties);
62-
63-
applier.applyBool(LOGGING_OPTION, builder::profilerLoggingEnabled);
64-
applier.applyBool(DIAGNOSTIC_FILES_OPTION, builder::backupDiagnosticFiles);
65-
applier.applyInt(SAFEMODE_OPTION, builder::asyncProfilerSafeMode);
66-
applier.applyBool(POSTPROCESSING_OPTION, builder::postProcessingEnabled);
67-
applier.applyDuration(SAMPLING_INTERVAL_OPTION, builder::samplingInterval);
68-
applier.applyDuration(MIN_DURATION_OPTION, builder::inferredSpansMinDuration);
69-
applier.applyWildcards(INCLUDED_CLASSES_OPTION, builder::includedClasses);
70-
applier.applyWildcards(EXCLUDED_CLASSES_OPTION, builder::excludedClasses);
71-
applier.applyDuration(INTERVAL_OPTION, builder::profilerInterval);
72-
applier.applyDuration(DURATION_OPTION, builder::profilingDuration);
73-
applier.applyString(LIB_DIRECTORY_OPTION, builder::profilerLibDirectory);
74-
75-
String parentOverrideHandlerName = properties.getString(PARENT_OVERRIDE_HANDLER_OPTION);
76-
if (parentOverrideHandlerName != null && !parentOverrideHandlerName.isEmpty()) {
77-
builder.parentOverrideHandler(constructParentOverrideHandler(parentOverrideHandlerName));
78-
}
79-
80-
return builder.build();
81-
}
82-
8379
@SuppressWarnings("unchecked")
8480
private static BiConsumer<SpanBuilder, SpanContext> constructParentOverrideHandler(String name) {
8581
try {

inferred-spans/src/main/java/io/opentelemetry/contrib/inferredspans/InferredSpansComponentProvider.java

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

inferred-spans/src/main/java/io/opentelemetry/contrib/inferredspans/InferredSpansProcessor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ public class InferredSpansProcessor implements SpanProcessor {
4949
boolean startScheduledProfiling,
5050
@Nullable File activationEventsFile,
5151
@Nullable File jfrFile) {
52-
profiler =
53-
new SamplingProfiler(config, clock, this::getTracer, activationEventsFile, jfrFile, null);
52+
profiler = new SamplingProfiler(config, clock, this::getTracer, activationEventsFile, jfrFile);
5453
if (startScheduledProfiling) {
5554
profiler.start();
5655
}

inferred-spans/src/main/java/io/opentelemetry/contrib/inferredspans/internal/SamplingProfiler.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ public class SamplingProfiler implements Runnable {
149149
private final ProfilingActivationListener activationListener;
150150

151151
private final Supplier<Tracer> tracerProvider;
152-
@Nullable private final File tempDir;
153152

154153
private final AsyncProfiler profiler;
155154

@@ -169,11 +168,9 @@ public SamplingProfiler(
169168
SpanAnchoredClock nanoClock,
170169
Supplier<Tracer> tracerProvider,
171170
@Nullable File activationEventsFile,
172-
@Nullable File jfrFile,
173-
@Nullable File tempDir) {
171+
@Nullable File jfrFile) {
174172
this.config = config;
175173
this.tracerProvider = tracerProvider;
176-
this.tempDir = tempDir;
177174
this.scheduler =
178175
Executors.newSingleThreadScheduledExecutor(
179176
r -> {
@@ -253,13 +250,12 @@ boolean isProfilingActiveOnThread(Thread thread) {
253250

254251
private synchronized void createFilesIfRequired() throws IOException {
255252
if (jfrFile == null || !jfrFile.exists()) {
256-
jfrFile = File.createTempFile("otel-inferred-traces-", ".jfr", tempDir);
253+
jfrFile = File.createTempFile("otel-inferred-traces-", ".jfr");
257254
jfrFile.deleteOnExit();
258255
canDeleteJfrFile = true;
259256
}
260257
if (activationEventsFile == null || !activationEventsFile.exists()) {
261-
activationEventsFile =
262-
File.createTempFile("otel-inferred-activation-events-", ".bin", tempDir);
258+
activationEventsFile = File.createTempFile("otel-inferred-activation-events-", ".bin");
263259
activationEventsFile.deleteOnExit();
264260
canDeleteActivationEventsFile = true;
265261
}

inferred-spans/src/test/java/io/opentelemetry/contrib/inferredspans/InferredSpansCustomizerProviderTest.java

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

inferred-spans/src/test/java/io/opentelemetry/contrib/inferredspans/internal/SamplingProfilerTest.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
import java.util.stream.Stream;
3333
import org.assertj.core.api.Assertions;
3434
import org.junit.jupiter.api.AfterEach;
35+
import org.junit.jupiter.api.BeforeEach;
3536
import org.junit.jupiter.api.Test;
3637
import org.junit.jupiter.api.condition.DisabledForJreRange;
3738
import org.junit.jupiter.api.condition.DisabledOnOs;
3839
import org.junit.jupiter.api.condition.JRE;
3940
import org.junit.jupiter.api.condition.OS;
40-
import org.junit.jupiter.api.io.TempDir;
4141

4242
// async-profiler doesn't work on Windows
4343
@DisabledOnOs(OS.WINDOWS)
@@ -46,14 +46,19 @@ class SamplingProfilerTest {
4646

4747
private ProfilerTestSetup setup;
4848

49-
@TempDir private Path tempDir;
49+
@BeforeEach
50+
void setup() {
51+
// avoids any test failure to make other tests to fail
52+
getProfilerTempFiles().forEach(SamplingProfilerTest::silentDeleteFile);
53+
}
5054

5155
@AfterEach
5256
void tearDown() {
5357
if (setup != null) {
5458
setup.close();
5559
setup = null;
5660
}
61+
getProfilerTempFiles().forEach(SamplingProfilerTest::silentDeleteFile);
5762
}
5863

5964
@Test
@@ -112,8 +117,8 @@ void shouldNotDeleteProvidedFiles() throws Exception {
112117
defaultConfig = ProfilerTestSetup.extractProfilerImpl(profiler1).getConfig();
113118
}
114119

115-
Path tempFile1 = Files.createTempFile(tempDir, "otel-inferred-provided", "test.bin");
116-
Path tempFile2 = Files.createTempFile(tempDir, "otel-inferred-provided", "test.jfr");
120+
Path tempFile1 = Files.createTempFile("otel-inferred-provided", "test.bin");
121+
Path tempFile2 = Files.createTempFile("otel-inferred-provided", "test.jfr");
117122

118123
try (OpenTelemetrySdk sdk = OpenTelemetrySdk.builder().build()) {
119124

@@ -123,8 +128,7 @@ void shouldNotDeleteProvidedFiles() throws Exception {
123128
new FixedClock(),
124129
() -> sdk.getTracer("my-tracer"),
125130
tempFile1.toFile(),
126-
tempFile2.toFile(),
127-
tempDir.toFile());
131+
tempFile2.toFile());
128132

129133
otherProfiler.start();
130134
awaitProfilerStarted(otherProfiler);
@@ -337,4 +341,12 @@ private static void awaitProfilerStarted(SamplingProfiler profiler) {
337341
.timeout(Duration.ofSeconds(6))
338342
.until(() -> profiler.getProfilingSessions() > 1);
339343
}
344+
345+
private static void silentDeleteFile(Path f) {
346+
try {
347+
Files.delete(f);
348+
} catch (IOException e) {
349+
throw new IllegalStateException(e);
350+
}
351+
}
340352
}

0 commit comments

Comments
 (0)