From 9b5d68fd1b9c2ce054fb92ffc6e4ce915b3acabd Mon Sep 17 00:00:00 2001 From: Thomas Pierce Date: Mon, 26 Feb 2024 18:56:41 +0000 Subject: [PATCH] Make spotless work In this commit, we are making spotless work, as I found out that spotless is not being run in the upstream for benchmark-overhead. To achive this, I've added a license file to `scripts` and updated build.gradle.kts to reference it. Then I ran spotlessApply to bring the code up to expectations. In future commits, we will automatically run spotless to ensure code is up to standards on every commit. --- performance-tests/build.gradle.kts | 2 +- .../java/io/opentelemetry/OverheadTests.java | 21 ++++++++++++++----- .../opentelemetry/util/NamingConventions.java | 8 +++++-- scripts/spotless.license.java | 5 +++++ 4 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 scripts/spotless.license.java diff --git a/performance-tests/build.gradle.kts b/performance-tests/build.gradle.kts index a761e83f1..5df08b71d 100644 --- a/performance-tests/build.gradle.kts +++ b/performance-tests/build.gradle.kts @@ -6,7 +6,7 @@ plugins { spotless { java { googleJavaFormat() - licenseHeaderFile(rootProject.file("../buildscripts/spotless.license.java"), "(package|import|public)") + licenseHeaderFile(rootProject.file("../scripts/spotless.license.java"), "(package|import|public)") target("src/**/*.java") } } diff --git a/performance-tests/src/test/java/io/opentelemetry/OverheadTests.java b/performance-tests/src/test/java/io/opentelemetry/OverheadTests.java index b69a6d708..0ee5cbda0 100644 --- a/performance-tests/src/test/java/io/opentelemetry/OverheadTests.java +++ b/performance-tests/src/test/java/io/opentelemetry/OverheadTests.java @@ -123,16 +123,27 @@ private void startRecording(Agent agent, GenericContainer petclinic) throws E petclinic.execInContainer(command); } - private void doWarmupPhase(TestConfig testConfig, GenericContainer petclinic) throws IOException, InterruptedException { - System.out.println("Performing startup warming phase for " + testConfig.getWarmupSeconds() + " seconds..."); + private void doWarmupPhase(TestConfig testConfig, GenericContainer petclinic) + throws IOException, InterruptedException { + System.out.println( + "Performing startup warming phase for " + testConfig.getWarmupSeconds() + " seconds..."); // excluding the JFR recording from the warmup causes strange inconsistencies in the results System.out.println("Starting disposable JFR warmup recording..."); - String[] startCommand = {"jcmd", "1", "JFR.start", "settings=/app/overhead.jfc", "dumponexit=true", "name=warmup", "filename=warmup.jfr"}; + String[] startCommand = { + "jcmd", + "1", + "JFR.start", + "settings=/app/overhead.jfc", + "dumponexit=true", + "name=warmup", + "filename=warmup.jfr" + }; petclinic.execInContainer(startCommand); - long deadline = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(testConfig.getWarmupSeconds()); - while(System.currentTimeMillis() < deadline) { + long deadline = + System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(testConfig.getWarmupSeconds()); + while (System.currentTimeMillis() < deadline) { GenericContainer k6 = new GenericContainer<>(DockerImageName.parse("loadimpact/k6")) .withNetwork(NETWORK) diff --git a/performance-tests/src/test/java/io/opentelemetry/util/NamingConventions.java b/performance-tests/src/test/java/io/opentelemetry/util/NamingConventions.java index 6caf28dfe..903105b43 100644 --- a/performance-tests/src/test/java/io/opentelemetry/util/NamingConventions.java +++ b/performance-tests/src/test/java/io/opentelemetry/util/NamingConventions.java @@ -11,12 +11,16 @@ public class NamingConventions { public final NamingConvention container = new NamingConvention("/results"); public final NamingConvention local = new NamingConvention("."); - /** @return Root path for the local naming convention (where results are output) */ + /** + * @return Root path for the local naming convention (where results are output) + */ public String localResults() { return local.root(); } - /** @return Root path for the container naming convention (where results are output) */ + /** + * @return Root path for the container naming convention (where results are output) + */ public String containerResults() { return container.root(); } diff --git a/scripts/spotless.license.java b/scripts/spotless.license.java new file mode 100644 index 000000000..b504712ee --- /dev/null +++ b/scripts/spotless.license.java @@ -0,0 +1,5 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ +