diff --git a/.editorconfig b/.editorconfig index 201ab30485ca..dbeb94bf3544 100644 --- a/.editorconfig +++ b/.editorconfig @@ -663,7 +663,7 @@ ij_groovy_while_brace_force = never ij_groovy_while_on_new_line = false ij_groovy_wrap_long_lines = false -[{*.kt, *.kts}] +[*.{kt,kts}] ij_continuation_indent_size = 2 ij_kotlin_align_in_columns_case_branch = false ij_kotlin_align_multiline_binary_operation = false @@ -761,3 +761,16 @@ ij_properties_spaces_around_key_value_delimiter = false [{*.yaml, *.yml}] ij_yaml_keep_indents_on_empty_lines = false ij_yaml_keep_line_breaks = true + +# ktlint overrides (mirrors otel.spotless-conventions.gradle.kts) +[*.{kt,kts}] +max_line_length = 160 +continuation_indent_size = 2 +ktlint_standard_no-wildcard-imports = disabled +ktlint_standard_package-name = disabled +ktlint_standard_max-line-length = disabled +ktlint_standard_trailing-comma-on-call-site = disabled +ktlint_standard_trailing-comma-on-declaration-site = disabled +ktlint_standard_wrapping = disabled +ktlint_standard_property-naming = disabled +ktlint_standard_function-literal = disabled diff --git a/.github/config/.rumdl.toml b/.github/config/.rumdl.toml new file mode 100644 index 000000000000..066c5b40f022 --- /dev/null +++ b/.github/config/.rumdl.toml @@ -0,0 +1,5 @@ +[MD013] +enabled = true +line-length = 120 +code-blocks = false +tables = false diff --git a/.github/config/.yamllint.yml b/.github/config/.yamllint.yml new file mode 100644 index 000000000000..5a46209b1345 --- /dev/null +++ b/.github/config/.yamllint.yml @@ -0,0 +1,6 @@ +extends: relaxed + +rules: + document-start: disable + line-length: disable + indentation: warning diff --git a/.github/config/flint.toml b/.github/config/flint.toml new file mode 100644 index 000000000000..7ad02e0cf316 --- /dev/null +++ b/.github/config/flint.toml @@ -0,0 +1,15 @@ +[settings] +exclude = [ + "gradlew", + "buildscripts/spotless.license.java", + "CHANGELOG.md", + "licenses/licenses.md", +] + +[checks.license-header] +text = """ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */""" +patterns = ["**/*.java", "**/*.kt"] diff --git a/.github/renovate.json5 b/.github/renovate.json5 index 05e0fd0c3693..767e76d5115a 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -1,6 +1,7 @@ { $schema: 'https://docs.renovatebot.com/renovate-schema.json', extends: [ + "github>grafana/flint#v0.20.4", 'config:best-practices', 'helpers:pinGitHubActionDigestsToSemver', ':semanticCommits', diff --git a/.github/workflows/build-daily.yml b/.github/workflows/build-daily.yml index 9ce52ac4a0e2..4bc6bc15e2d1 100644 --- a/.github/workflows/build-daily.yml +++ b/.github/workflows/build-daily.yml @@ -25,11 +25,8 @@ jobs: muzzle: uses: ./.github/workflows/reusable-muzzle.yml - link-check: - uses: ./.github/workflows/reusable-link-check.yml - - markdown-lint-check: - uses: ./.github/workflows/reusable-markdown-lint-check.yml + lint: + uses: ./.github/workflows/reusable-lint-check.yml publish-snapshots: environment: protected diff --git a/.github/workflows/build-pull-request.yml b/.github/workflows/build-pull-request.yml index ac1046e09f3d..40296874aacc 100644 --- a/.github/workflows/build-pull-request.yml +++ b/.github/workflows/build-pull-request.yml @@ -40,15 +40,11 @@ jobs: with: cache-read-only: true - # this is not a required check to avoid blocking pull requests if external links break - markdown-check: + lint: # release branches are excluded because the README.md javaagent download link has to be updated # on release branches before the release download has been published if: "!startsWith(github.ref_name, 'release/') && !startsWith(github.base_ref, 'release/')" - uses: ./.github/workflows/reusable-link-check.yml - - markdown-lint-check: - uses: ./.github/workflows/reusable-markdown-lint-check.yml + uses: ./.github/workflows/reusable-lint-check.yml required-status-check: # test-latest-deps is not included in the required status checks @@ -63,7 +59,7 @@ jobs: needs: - common - muzzle - - markdown-lint-check + - lint runs-on: ubuntu-latest if: always() steps: @@ -73,7 +69,7 @@ jobs: !startsWith(github.base_ref, 'release/') && ( needs.muzzle.result != 'success' || - needs.markdown-lint-check.result != 'success' + needs.lint.result != 'success' ) ) run: exit 1 # fail diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 47261f932dc4..2d3f32b3e928 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,14 +34,8 @@ jobs: if: "!startsWith(github.ref_name, 'release/')" uses: ./.github/workflows/reusable-muzzle.yml - link-check: - # release branches are excluded to avoid unnecessary maintenance if external links break - # (and also because the README.md javaagent download link has to be updated on release branches - # before the release download has been published) + lint: + # release branches are excluded because the README.md javaagent download link has to be updated + # on release branches before the release download has been published if: "!startsWith(github.ref_name, 'release/')" - uses: ./.github/workflows/reusable-link-check.yml - - markdown-lint-check: - # release branches are excluded - if: "!startsWith(github.ref_name, 'release/')" - uses: ./.github/workflows/reusable-markdown-lint-check.yml + uses: ./.github/workflows/reusable-lint-check.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000000..e00a67b4f02d --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,32 @@ +name: Lint + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + fetch-depth: 0 + + - name: Setup mise + uses: jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # v4.0.1 + with: + version: v2026.4.18 + sha256: 6ae2d5f0f23a2f2149bc5d9bf264fe0922a1da843f1903e453516c462b23cc1f + + - name: Lint + env: + GITHUB_TOKEN: ${{ github.token }} + GITHUB_HEAD_SHA: ${{ github.event.pull_request.head.sha }} + run: mise run lint diff --git a/.github/workflows/reusable-link-check.yml b/.github/workflows/reusable-lint-check.yml similarity index 76% rename from .github/workflows/reusable-link-check.yml rename to .github/workflows/reusable-lint-check.yml index 8ea87549c37b..1bfb111aa823 100644 --- a/.github/workflows/reusable-link-check.yml +++ b/.github/workflows/reusable-lint-check.yml @@ -1,4 +1,4 @@ -name: Reusable - Link check +name: Reusable - Lint check on: workflow_call: @@ -7,7 +7,7 @@ permissions: contents: read jobs: - link-check: + lint-check: runs-on: ubuntu-latest steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -16,16 +16,16 @@ jobs: - uses: jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # v4.0.1 - - name: Link check for pull requests + - name: Lint for pull requests if: github.event_name == 'pull_request' env: GITHUB_TOKEN: ${{ github.token }} GITHUB_HEAD_SHA: ${{ github.event.pull_request.head.sha }} PR_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }} - run: mise run lint:links + run: mise run lint - - name: Link check for pushes and scheduled workflows + - name: Lint for pushes and scheduled workflows if: github.event_name != 'pull_request' env: GITHUB_TOKEN: ${{ github.token }} - run: mise run lint:links --full + run: mise run lint diff --git a/.github/workflows/reusable-markdown-lint-check.yml b/.github/workflows/reusable-markdown-lint-check.yml deleted file mode 100644 index 5b0dec6dbe45..000000000000 --- a/.github/workflows/reusable-markdown-lint-check.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Reusable - Markdown lint check - -on: - workflow_call: - -permissions: - contents: read - -jobs: - markdown-lint-check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - - uses: jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # v4.0.1 - - - name: Run markdownlint - run: | - if ! mise run lint:markdown; then - echo "markdownlint failed. To auto-fix many issues locally, run:" - echo " mise run lint:markdown --fix" - exit 1 - fi diff --git a/.markdownlint.yaml b/.markdownlint.yaml deleted file mode 100644 index 513be90ec949..000000000000 --- a/.markdownlint.yaml +++ /dev/null @@ -1,15 +0,0 @@ -# See https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md -# and https://github.com/DavidAnson/markdownlint-cli2 - -ul-style: false -line-length: false -no-duplicate-heading: - siblings_only: true -ol-prefix: - style: ordered -no-inline-html: false -fenced-code-language: false -no-trailing-punctuation: - punctuation: ".,;:" # allowing exclamation points and question marks at end of sentences -MD059: false # disable link text should be descriptive check -MD041: false # files with YAML frontmatter don't start with a heading diff --git a/.mise/tasks/lint/markdown.sh b/.mise/tasks/lint/markdown.sh deleted file mode 100755 index c7d41aa63e47..000000000000 --- a/.mise/tasks/lint/markdown.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash -#MISE description="Lint markdown files" -#USAGE flag "--fix" help="Automatically fix issues" - -set -e - -if [ "${usage_fix:-false}" = "true" ]; then - markdownlint-cli2 --fix "**/*.md" "#**/build" "#CHANGELOG.md" "#licenses/licenses.md" -else - markdownlint-cli2 "**/*.md" "#**/build" "#CHANGELOG.md" "#licenses/licenses.md" -fi diff --git a/benchmark-overhead-jmh/build.gradle.kts b/benchmark-overhead-jmh/build.gradle.kts index ca2cfe60b172..223de802591a 100644 --- a/benchmark-overhead-jmh/build.gradle.kts +++ b/benchmark-overhead-jmh/build.gradle.kts @@ -40,7 +40,10 @@ tasks { // -Pjmh.startFlightRecording=settings=profile.jfc,delay=50s,duration=50s,filename=output.jfr // since each iteration is 10 seconds, the flight recording produced will approximately cover the // (post-warmup) benchmarking iterations - val jmhStartFlightRecording = gradle.startParameter.projectProperties.get("jmh.startFlightRecording") + val jmhStartFlightRecording = + gradle.startParameter.projectProperties.get( + "jmh.startFlightRecording", + ) named("jmh") { val shadowTask = project(":javaagent").tasks.named("shadowJar").get() @@ -48,15 +51,16 @@ tasks { // note: without an exporter, toSpanData() won't even be called // (which is good for benchmarking the instrumentation itself) - val args = mutableListOf( - "-javaagent:${shadowTask.archiveFile.get()}", - "-Dotel.traces.exporter=none", - "-Dotel.metrics.exporter=none", - "-Dotel.logs.exporter=none", - // avoid instrumenting HttpURLConnection for now since it is used to make the requests - // and this benchmark is focused on servlet overhead for now - "-Dotel.instrumentation.http-url-connection.enabled=false", - ) + val args = + mutableListOf( + "-javaagent:${shadowTask.archiveFile.get()}", + "-Dotel.traces.exporter=none", + "-Dotel.metrics.exporter=none", + "-Dotel.logs.exporter=none", + // avoid instrumenting HttpURLConnection for now since it is used to make the requests + // and this benchmark is focused on servlet overhead for now + "-Dotel.instrumentation.http-url-connection.enabled=false", + ) if (jmhStartFlightRecording != null) { args.addAll( listOf( diff --git a/benchmark-overhead/build.gradle.kts b/benchmark-overhead/build.gradle.kts index 13ccbe86c496..7b1bc9c5f324 100644 --- a/benchmark-overhead/build.gradle.kts +++ b/benchmark-overhead/build.gradle.kts @@ -6,7 +6,10 @@ plugins { spotless { java { googleJavaFormat() - licenseHeaderFile(rootProject.file("../buildscripts/spotless.license.java"), "(package|import|public)") + licenseHeaderFile( + rootProject.file("../buildscripts/spotless.license.java"), + "(package|import|public)", + ) target("src/**/*.java") } } diff --git a/benchmark-overhead/settings.gradle.kts b/benchmark-overhead/settings.gradle.kts index 6abaef4a2ec0..0618406a5ebc 100644 --- a/benchmark-overhead/settings.gradle.kts +++ b/benchmark-overhead/settings.gradle.kts @@ -1 +1 @@ -rootProject.name = "opentelemetry-agent-overhead-test" \ No newline at end of file +rootProject.name = "opentelemetry-agent-overhead-test" diff --git a/benchmark-overhead/src/test/java/io/opentelemetry/OverheadTests.java b/benchmark-overhead/src/test/java/io/opentelemetry/OverheadTests.java index 4c8cfc58d417..685d9017e5c1 100644 --- a/benchmark-overhead/src/test/java/io/opentelemetry/OverheadTests.java +++ b/benchmark-overhead/src/test/java/io/opentelemetry/OverheadTests.java @@ -5,9 +5,8 @@ package io.opentelemetry; -import static java.util.concurrent.TimeUnit.SECONDS; import static java.util.concurrent.TimeUnit.MILLISECONDS; - +import static java.util.concurrent.TimeUnit.SECONDS; import static org.assertj.core.api.Assertions.fail; import static org.junit.jupiter.api.DynamicTest.dynamicTest; @@ -29,7 +28,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.concurrent.TimeUnit; import java.util.stream.Stream; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; @@ -145,15 +143,15 @@ private void doWarmupPhase(TestConfig testConfig, GenericContainer petclinic) }; petclinic.execInContainer(startCommand); - long deadline = - System.currentTimeMillis() + SECONDS.toMillis(testConfig.getWarmupSeconds()); + long deadline = System.currentTimeMillis() + SECONDS.toMillis(testConfig.getWarmupSeconds()); while (System.currentTimeMillis() < deadline) { GenericContainer k6 = new GenericContainer<>(DockerImageName.parse("grafana/k6")) .withNetwork(NETWORK) .withCopyFileToContainer(MountableFile.forHostPath("./k6"), "/app") .withCommand("run", "-u", "5", "-i", "200", "/app/basic.js") - .withStartupCheckStrategy(new OneShotStartupCheckStrategy().withTimeout(Duration.ofMinutes(5))); + .withStartupCheckStrategy( + new OneShotStartupCheckStrategy().withTimeout(Duration.ofMinutes(5))); k6.start(); } diff --git a/benchmark-overhead/src/test/java/io/opentelemetry/agents/LatestAgentSnapshotResolver.java b/benchmark-overhead/src/test/java/io/opentelemetry/agents/LatestAgentSnapshotResolver.java index c695e48cdaae..362f7f8b9df0 100644 --- a/benchmark-overhead/src/test/java/io/opentelemetry/agents/LatestAgentSnapshotResolver.java +++ b/benchmark-overhead/src/test/java/io/opentelemetry/agents/LatestAgentSnapshotResolver.java @@ -22,7 +22,9 @@ Optional resolve() throws IOException { Path localJavaagentPath = findLocalJavaagentJar(); if (localJavaagentPath == null || !Files.exists(localJavaagentPath)) { - throw new IOException("Local javaagent JAR not found. Please run './gradlew :javaagent:assemble' from the project root first."); + throw new IOException( + "Local javaagent JAR not found. Please run './gradlew :javaagent:assemble' from the" + + " project root first."); } logger.info("Using local javaagent JAR: {}", localJavaagentPath); @@ -66,13 +68,16 @@ private Path findJavaagentJarInDirectory(Path directory) { try { return Files.list(directory) - .filter(path -> { - String filename = path.getFileName().toString(); - // Look for the main jar: opentelemetry-javaagent-VERSION.jar (no additional suffixes) - return filename.startsWith("opentelemetry-javaagent-") && - filename.endsWith(".jar") && - !filename.matches(".*-[a-z]+\\.jar"); // excludes anything with -word.jar pattern - }) + .filter( + path -> { + String filename = path.getFileName().toString(); + // Look for the main jar: opentelemetry-javaagent-VERSION.jar (no additional + // suffixes) + return filename.startsWith("opentelemetry-javaagent-") + && filename.endsWith(".jar") + && !filename.matches( + ".*-[a-z]+\\.jar"); // excludes anything with -word.jar pattern + }) .findFirst() .orElse(null); } catch (IOException e) { @@ -81,4 +86,3 @@ private Path findJavaagentJarInDirectory(Path directory) { } } } - diff --git a/benchmark-overhead/src/test/java/io/opentelemetry/results/CsvPersister.java b/benchmark-overhead/src/test/java/io/opentelemetry/results/CsvPersister.java index 1a79d463af37..b3902ecddc70 100644 --- a/benchmark-overhead/src/test/java/io/opentelemetry/results/CsvPersister.java +++ b/benchmark-overhead/src/test/java/io/opentelemetry/results/CsvPersister.java @@ -5,8 +5,8 @@ package io.opentelemetry.results; -import static java.util.stream.Collectors.toList; import static java.util.concurrent.TimeUnit.NANOSECONDS; +import static java.util.stream.Collectors.toList; import java.io.IOException; import java.nio.file.Files; diff --git a/benchmark-overhead/src/test/java/io/opentelemetry/results/ResultsCollector.java b/benchmark-overhead/src/test/java/io/opentelemetry/results/ResultsCollector.java index a2fc28fcfd5b..f9a1445467a4 100644 --- a/benchmark-overhead/src/test/java/io/opentelemetry/results/ResultsCollector.java +++ b/benchmark-overhead/src/test/java/io/opentelemetry/results/ResultsCollector.java @@ -6,6 +6,7 @@ package io.opentelemetry.results; import static java.util.stream.Collectors.toList; + import com.jayway.jsonpath.JsonPath; import io.opentelemetry.agents.Agent; import io.opentelemetry.config.TestConfig; @@ -29,9 +30,7 @@ public ResultsCollector(NamingConvention namingConvention, Map run } public List collect(TestConfig config) { - return config.getAgents().stream() - .map(a -> readAgentResults(a, config)) - .collect(toList()); + return config.getAgents().stream().map(a -> readAgentResults(a, config)).collect(toList()); } private AppPerfResults readAgentResults(Agent agent, TestConfig config) { diff --git a/biome.json b/biome.json new file mode 100644 index 000000000000..4e68cbc7f6a5 --- /dev/null +++ b/biome.json @@ -0,0 +1,6 @@ +{ + "formatter": { + "indentStyle": "space", + "indentWidth": 2 + } +} diff --git a/bom-alpha/build.gradle.kts b/bom-alpha/build.gradle.kts index 4eb6acede733..24279003b4e0 100644 --- a/bom-alpha/build.gradle.kts +++ b/bom-alpha/build.gradle.kts @@ -16,10 +16,17 @@ dependencies { api(platform(project(":bom"))) // Get the semconv version from :dependencyManagement - val semconvConstraint = project.project(project(":dependencyManagement").path).configurations["api"].allDependencyConstraints - .find { it.group.equals("io.opentelemetry.semconv") - && it.name.equals("opentelemetry-semconv-incubating") } - ?: throw Exception("semconv constraint not found") + val semconvConstraint = + project + .project( + project(":dependencyManagement").path, + ).configurations["api"] + .allDependencyConstraints + .find { + it.group.equals("io.opentelemetry.semconv") && + it.name.equals("opentelemetry-semconv-incubating") + } + ?: throw Exception("semconv constraint not found") val semconvAlphaVersion = semconvConstraint.version ?: throw Exception("missing version") otelBom.addExtra(semconvConstraint.group, "opentelemetry-semconv-incubating", semconvAlphaVersion) } diff --git a/bom/build.gradle.kts b/bom/build.gradle.kts index b8745c9a1676..70fa4813bbfd 100644 --- a/bom/build.gradle.kts +++ b/bom/build.gradle.kts @@ -14,10 +14,17 @@ dependencies { api(platform("io.opentelemetry:opentelemetry-bom")) // Get the semconv version from :dependencyManagement - val semconvConstraint = project.project(project(":dependencyManagement").path).configurations["api"].allDependencyConstraints - .find { it.group.equals("io.opentelemetry.semconv") - && it.name.equals("opentelemetry-semconv") } - ?: throw Exception("semconv constraint not found") + val semconvConstraint = + project + .project( + project(":dependencyManagement").path, + ).configurations["api"] + .allDependencyConstraints + .find { + it.group.equals("io.opentelemetry.semconv") && + it.name.equals("opentelemetry-semconv") + } + ?: throw Exception("semconv constraint not found") val semconvVersion = semconvConstraint.version ?: throw Exception("missing version") otelBom.addExtra(semconvConstraint.group, semconvConstraint.name, semconvVersion) } diff --git a/build.gradle.kts b/build.gradle.kts index 25b51451a22c..21070585a49d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -133,11 +133,12 @@ tasks { description = "Generate .fossa.yml configuration file" // Capture the project paths at configuration time to avoid serializing Gradle script objects - val projectPaths = rootProject.subprojects - .sortedBy { it.findProperty("archivesName") as String? } - .filter { !it.name.startsWith("bom") } - .filter { it.plugins.hasPlugin("maven-publish") } - .map { it.path } + val projectPaths = + rootProject.subprojects + .sortedBy { it.findProperty("archivesName") as String? } + .filter { !it.name.startsWith("bom") } + .filter { it.plugins.hasPlugin("maven-publish") } + .map { it.path } val outputFile = layout.projectDirectory.file(".fossa.yml") outputs.file(outputFile) @@ -179,7 +180,8 @@ tasks { dependsOn(generateReleaseBundle) val bundleFile = generateReleaseBundle.flatMap { it.archiveFile } doFirst { - val username = System.getenv("SONATYPE_USER") ?: throw GradleException("Sonatype user not set") + val username = + System.getenv("SONATYPE_USER") ?: throw GradleException("Sonatype user not set") val password = System.getenv("SONATYPE_KEY") ?: throw GradleException("Sonatype key not set") val token = Base64.getEncoder().encodeToString("$username:$password".toByteArray()) @@ -189,20 +191,29 @@ tasks { val bundle = bundleFile.get().asFile val httpClient = OkHttpClient() - val request = okhttp3.Request.Builder() - .url("https://central.sonatype.com/api/v1/publisher/upload$query") - .post( - okhttp3.MultipartBody.Builder().addFormDataPart( - "bundle", - bundle.name, - bundle.asRequestBody("application/zip".toMediaType()) - ).build() - ) - .header("authorization", "Bearer $token") - .build() + val request = + okhttp3.Request + .Builder() + .url("https://central.sonatype.com/api/v1/publisher/upload$query") + .post( + okhttp3.MultipartBody + .Builder() + .addFormDataPart( + "bundle", + bundle.name, + bundle.asRequestBody("application/zip".toMediaType()), + ).build(), + ).header("authorization", "Bearer $token") + .build() httpClient.newCall(request).execute().use { response -> - if (response.code != 201) throw GradleException("Unexpected response status ${response.code} while uploading the release bundle") + if (response.code != + 201 + ) { + throw GradleException( + "Unexpected response status ${response.code} while uploading the release bundle", + ) + } println("Uploaded deployment ${response.body.string()}") } } diff --git a/conventions/build.gradle.kts b/conventions/build.gradle.kts index 5793d82091d8..f9b33c533337 100644 --- a/conventions/build.gradle.kts +++ b/conventions/build.gradle.kts @@ -9,26 +9,28 @@ spotless { googleJavaFormat() licenseHeaderFile( rootProject.file("../buildscripts/spotless.license.java"), - "(package|import|public)" + "(package|import|public)", ) target("src/**/*.java") } kotlinGradle { // not sure why it's not using the indent settings from .editorconfig - ktlint().editorConfigOverride(mapOf( - "indent_size" to "2", - "continuation_indent_size" to "2", - "max_line_length" to "160", - "ktlint_standard_no-wildcard-imports" to "disabled", - // ktlint does not break up long lines, it just fails on them - "ktlint_standard_max-line-length" to "disabled", - // ktlint makes it *very* hard to locate where this actually happened - "ktlint_standard_trailing-comma-on-call-site" to "disabled", - // depends on ktlint_standard_wrapping - "ktlint_standard_trailing-comma-on-declaration-site" to "disabled", - // also very hard to find out where this happens - "ktlint_standard_wrapping" to "disabled" - )) + ktlint().editorConfigOverride( + mapOf( + "indent_size" to "2", + "continuation_indent_size" to "2", + "max_line_length" to "160", + "ktlint_standard_no-wildcard-imports" to "disabled", + // ktlint does not break up long lines, it just fails on them + "ktlint_standard_max-line-length" to "disabled", + // ktlint makes it *very* hard to locate where this actually happened + "ktlint_standard_trailing-comma-on-call-site" to "disabled", + // depends on ktlint_standard_wrapping + "ktlint_standard_trailing-comma-on-declaration-site" to "disabled", + // also very hard to find out where this happens + "ktlint_standard_wrapping" to "disabled", + ), + ) target("**/*.gradle.kts") } } diff --git a/conventions/src/main/kotlin/io.opentelemetry.instrumentation.base.gradle.kts b/conventions/src/main/kotlin/io.opentelemetry.instrumentation.base.gradle.kts index 5b1233a080a1..2ac5cb683ed6 100644 --- a/conventions/src/main/kotlin/io.opentelemetry.instrumentation.base.gradle.kts +++ b/conventions/src/main/kotlin/io.opentelemetry.instrumentation.base.gradle.kts @@ -1,4 +1,4 @@ -/** Common setup for manual instrumentation of libraries and javaagent instrumentation. */ +// Common setup for manual instrumentation of libraries and javaagent instrumentation. import io.opentelemetry.instrumentation.gradle.OtelPropsExtension @@ -35,18 +35,18 @@ val otelProps = the() abstract class TestLatestDepsRule : ComponentMetadataRule { override fun execute(context: ComponentMetadataContext) { val version = context.details.id.version - if (version.contains("-alpha", true) - || version.contains("-beta", true) - || version.contains("-rc", true) - || version.contains(".rc", true) - || version.contains("-m", true) // e.g. spring milestones are published to grails repo - || version.contains(".m", true) // e.g. lettuce - || version.contains(".alpha", true) // e.g. netty - || version.contains(".beta", true) // e.g. hibernate - || version.contains(".cr", true) // e.g. hibernate - || version.endsWith("-nf-execution") // graphql - || GIT_SHA_PATTERN.matches(version) // graphql - || DATETIME_PATTERN.matches(version) // graphql + if (version.contains("-alpha", true) || + version.contains("-beta", true) || + version.contains("-rc", true) || + version.contains(".rc", true) || + version.contains("-m", true) || // e.g. spring milestones are published to grails repo + version.contains(".m", true) || // e.g. lettuce + version.contains(".alpha", true) || // e.g. netty + version.contains(".beta", true) || // e.g. hibernate + version.contains(".cr", true) || // e.g. hibernate + version.endsWith("-nf-execution") || // graphql + GIT_SHA_PATTERN.matches(version) || // graphql + DATETIME_PATTERN.matches(version) // graphql ) { context.details.status = "milestone" } @@ -136,7 +136,8 @@ if (otelProps.testLatestDeps) { // fixes to release branches. // This is only needed for modules where base version and latest dep tests use a different // source directory. - var latestDepCompileTaskNames = arrayOf("compileLatestDepTestJava", "compileLatestDepTestGroovy", "compileLatestDepTestScala") + var latestDepCompileTaskNames = + arrayOf("compileLatestDepTestJava", "compileLatestDepTestGroovy", "compileLatestDepTestScala") for (compileTaskName in latestDepCompileTaskNames) { if (tasks.names.contains(compileTaskName)) { tasks.named(compileTaskName).configure { @@ -154,7 +155,10 @@ tasks { inputs.property("instrumentation.name", name) inputs.property("instrumentation.version", version) - val propertiesDir = layout.buildDirectory.dir("generated/instrumentationVersion/META-INF/io/opentelemetry/instrumentation/") + val propertiesDir = + layout.buildDirectory.dir( + "generated/instrumentationVersion/META-INF/io/opentelemetry/instrumentation/", + ) outputs.dir(propertiesDir) doLast { @@ -164,15 +168,19 @@ tasks { } fun computeInstrumentationName(): String { - val name = when (projectDir.name) { - "javaagent", "library", "library-autoconfigure" -> projectDir.parentFile.name - else -> project.name - } + val name = + when (projectDir.name) { + "javaagent", "library", "library-autoconfigure" -> projectDir.parentFile.name + else -> project.name + } return "io.opentelemetry.$name" } sourceSets { main { - output.dir("build/generated/instrumentationVersion", "builtBy" to "generateInstrumentationVersionFile") + output.dir( + "build/generated/instrumentationVersion", + "builtBy" to "generateInstrumentationVersionFile", + ) } } diff --git a/conventions/src/main/kotlin/io.opentelemetry.instrumentation.javaagent-instrumentation.gradle.kts b/conventions/src/main/kotlin/io.opentelemetry.instrumentation.javaagent-instrumentation.gradle.kts index e70130463405..c04ffb8089c8 100644 --- a/conventions/src/main/kotlin/io.opentelemetry.instrumentation.javaagent-instrumentation.gradle.kts +++ b/conventions/src/main/kotlin/io.opentelemetry.instrumentation.javaagent-instrumentation.gradle.kts @@ -6,8 +6,14 @@ plugins { dependencies { add("muzzleBootstrap", "io.opentelemetry.instrumentation:opentelemetry-instrumentation-api") - add("muzzleBootstrap", "io.opentelemetry.instrumentation:opentelemetry-instrumentation-api-incubator") - add("muzzleBootstrap", "io.opentelemetry.instrumentation:opentelemetry-instrumentation-annotations-support") + add( + "muzzleBootstrap", + "io.opentelemetry.instrumentation:opentelemetry-instrumentation-api-incubator", + ) + add( + "muzzleBootstrap", + "io.opentelemetry.instrumentation:opentelemetry-instrumentation-annotations-support", + ) add("muzzleTooling", "io.opentelemetry.javaagent:opentelemetry-javaagent-extension-api") add("muzzleTooling", "io.opentelemetry.javaagent:opentelemetry-javaagent-tooling") diff --git a/conventions/src/main/kotlin/io.opentelemetry.instrumentation.javaagent-shadowing.gradle.kts b/conventions/src/main/kotlin/io.opentelemetry.instrumentation.javaagent-shadowing.gradle.kts index f658edd1dea6..6d46f4963f20 100644 --- a/conventions/src/main/kotlin/io.opentelemetry.instrumentation.javaagent-shadowing.gradle.kts +++ b/conventions/src/main/kotlin/io.opentelemetry.instrumentation.javaagent-shadowing.gradle.kts @@ -27,7 +27,10 @@ tasks.withType().configureEach { if (project.findProperty("disableShadowRelocate") != "true") { // prevents conflict with library instrumentation, since these classes live in the bootstrap class loader - relocate("io.opentelemetry.instrumentation", "io.opentelemetry.javaagent.shaded.instrumentation") { + relocate( + "io.opentelemetry.instrumentation", + "io.opentelemetry.javaagent.shaded.instrumentation", + ) { // Exclude resource providers since they live in the agent class loader exclude("io.opentelemetry.instrumentation.resources.*") exclude("io.opentelemetry.instrumentation.spring.resources.*") @@ -35,20 +38,35 @@ tasks.withType().configureEach { // relocate(OpenTelemetry API) since these classes live in the bootstrap class loader relocate("io.opentelemetry.api", "io.opentelemetry.javaagent.shaded.io.opentelemetry.api") - relocate("io.opentelemetry.semconv", "io.opentelemetry.javaagent.shaded.io.opentelemetry.semconv") - relocate("io.opentelemetry.context", "io.opentelemetry.javaagent.shaded.io.opentelemetry.context") + relocate( + "io.opentelemetry.semconv", + "io.opentelemetry.javaagent.shaded.io.opentelemetry.semconv", + ) + relocate( + "io.opentelemetry.context", + "io.opentelemetry.javaagent.shaded.io.opentelemetry.context", + ) relocate("io.opentelemetry.common", "io.opentelemetry.javaagent.shaded.io.opentelemetry.common") } // relocate(the OpenTelemetry extensions that are used by instrumentation modules) // these extensions live in the AgentClassLoader, and are injected into the user's class loader // by the instrumentation modules that use them - relocate("io.opentelemetry.contrib.awsxray", "io.opentelemetry.javaagent.shaded.io.opentelemetry.contrib.awsxray") - relocate("io.opentelemetry.extension.kotlin", "io.opentelemetry.javaagent.shaded.io.opentelemetry.extension.kotlin") + relocate( + "io.opentelemetry.contrib.awsxray", + "io.opentelemetry.javaagent.shaded.io.opentelemetry.contrib.awsxray", + ) + relocate( + "io.opentelemetry.extension.kotlin", + "io.opentelemetry.javaagent.shaded.io.opentelemetry.extension.kotlin", + ) // this is for instrumentation of opentelemetry-api and opentelemetry-instrumentation-api relocate("application.io.opentelemetry", "io.opentelemetry") - relocate("application.io.opentelemetry.instrumentation.api", "io.opentelemetry.instrumentation.api") + relocate( + "application.io.opentelemetry.instrumentation.api", + "io.opentelemetry.instrumentation.api", + ) // this is for instrumentation on java.util.logging (since java.util.logging itself is shaded above) relocate("application.java.util.logging", "java.util.logging") diff --git a/conventions/src/main/kotlin/io.opentelemetry.instrumentation.javaagent-testing.gradle.kts b/conventions/src/main/kotlin/io.opentelemetry.instrumentation.javaagent-testing.gradle.kts index 33e42a9787b5..41b699239ee0 100644 --- a/conventions/src/main/kotlin/io.opentelemetry.instrumentation.javaagent-testing.gradle.kts +++ b/conventions/src/main/kotlin/io.opentelemetry.instrumentation.javaagent-testing.gradle.kts @@ -8,13 +8,17 @@ plugins { id("io.opentelemetry.instrumentation.javaagent-shadowing") } -val failOnContextLeakProperty = providers.gradleProperty("failOnContextLeak") - .map { it != "false" } - .orElse(true) - -val testIndyProperty = providers.gradleProperty("testIndy") - .map { it == "true" } - .orElse(false) +val failOnContextLeakProperty = + providers + .gradleProperty("failOnContextLeak") + .map { it != "false" } + .orElse(true) + +val testIndyProperty = + providers + .gradleProperty("testIndy") + .map { it == "true" } + .orElse(false) val otelProps = the() @@ -79,52 +83,50 @@ class JavaagentTestArgumentsProvider( @InputFile @PathSensitive(PathSensitivity.RELATIVE) val agentShadowJar: File, - @InputFile @PathSensitive(PathSensitivity.RELATIVE) val shadowJar: File, - @get:Input val failOnContextLeak: Boolean, - @get:Input val testIndy: Boolean, - @get:Input val denyUnsafe: Boolean, ) : CommandLineArgumentProvider { override fun asArguments(): Iterable { - val list = mutableListOf( - "-Dotel.javaagent.debug=true", - "-javaagent:${agentShadowJar.absolutePath}", - // make the path to the javaagent available to tests - "-Dotel.javaagent.testing.javaagent-jar-path=${agentShadowJar.absolutePath}", - "-Dotel.javaagent.experimental.initializer.jar=${shadowJar.absolutePath}", - "-Dotel.javaagent.testing.additional-library-ignores.enabled=false", - "-Dotel.javaagent.testing.fail-on-context-leak=$failOnContextLeak", - // prevent sporadic gradle deadlocks, see SafeLogger for more details - "-Dotel.javaagent.testing.transform-safe-logging.enabled=true", - // Reduce noise in assertion messages since we don't need to verify this in most tests. We check - // in smoke tests instead. - "-Dotel.javaagent.add-thread-details=false", - "-Dotel.javaagent.experimental.indy=$testIndy", - // suppress repeated logging of "No metric data to export - skipping export." - // since PeriodicMetricReader is configured with a short interval - "-Dio.opentelemetry.javaagent.slf4j.simpleLogger.log.io.opentelemetry.sdk.metrics.export.PeriodicMetricReader=INFO", - // suppress a couple of verbose ClassNotFoundException stack traces logged at debug level - "-Dio.opentelemetry.javaagent.slf4j.simpleLogger.log.io.grpc.internal.ServerImplBuilder=INFO", - "-Dio.opentelemetry.javaagent.slf4j.simpleLogger.log.io.grpc.internal.ManagedChannelImplBuilder=INFO", - "-Dio.opentelemetry.javaagent.slf4j.simpleLogger.log.io.perfmark.PerfMark=INFO", - "-Dio.opentelemetry.javaagent.slf4j.simpleLogger.log.io.grpc.Context=INFO", - "-Dotel.java.experimental.span-attributes.copy-from-baggage.include=test-baggage-key-1,test-baggage-key-2", - "-Dotel.instrumentation.common.peer-service-mapping=127.0.0.1=test-peer-service,localhost=test-peer-service,192.0.2.1=test-peer-service" - ) - if (denyUnsafe) { - list += listOf( - "-Dsun.misc.unsafe.memory.access=deny", - "-Dotel.javaagent.testing.deny-unsafe=true", - "-Dio.netty.noUnsafe=true" + val list = + mutableListOf( + "-Dotel.javaagent.debug=true", + "-javaagent:${agentShadowJar.absolutePath}", + // make the path to the javaagent available to tests + "-Dotel.javaagent.testing.javaagent-jar-path=${agentShadowJar.absolutePath}", + "-Dotel.javaagent.experimental.initializer.jar=${shadowJar.absolutePath}", + "-Dotel.javaagent.testing.additional-library-ignores.enabled=false", + "-Dotel.javaagent.testing.fail-on-context-leak=$failOnContextLeak", + // prevent sporadic gradle deadlocks, see SafeLogger for more details + "-Dotel.javaagent.testing.transform-safe-logging.enabled=true", + // Reduce noise in assertion messages since we don't need to verify this in most tests. We check + // in smoke tests instead. + "-Dotel.javaagent.add-thread-details=false", + "-Dotel.javaagent.experimental.indy=$testIndy", + // suppress repeated logging of "No metric data to export - skipping export." + // since PeriodicMetricReader is configured with a short interval + "-Dio.opentelemetry.javaagent.slf4j.simpleLogger.log.io.opentelemetry.sdk.metrics.export.PeriodicMetricReader=INFO", + // suppress a couple of verbose ClassNotFoundException stack traces logged at debug level + "-Dio.opentelemetry.javaagent.slf4j.simpleLogger.log.io.grpc.internal.ServerImplBuilder=INFO", + "-Dio.opentelemetry.javaagent.slf4j.simpleLogger.log.io.grpc.internal.ManagedChannelImplBuilder=INFO", + "-Dio.opentelemetry.javaagent.slf4j.simpleLogger.log.io.perfmark.PerfMark=INFO", + "-Dio.opentelemetry.javaagent.slf4j.simpleLogger.log.io.grpc.Context=INFO", + "-Dotel.java.experimental.span-attributes.copy-from-baggage.include=test-baggage-key-1,test-baggage-key-2", + "-Dotel.instrumentation.common.peer-service-mapping=127.0.0.1=test-peer-service,localhost=test-peer-service,192.0.2.1=test-peer-service", ) + if (denyUnsafe) { + list += + listOf( + "-Dsun.misc.unsafe.memory.access=deny", + "-Dotel.javaagent.testing.deny-unsafe=true", + "-Dio.netty.noUnsafe=true", + ) } return list } @@ -150,38 +152,49 @@ afterEvaluate { shadowJar.archiveFile.get().asFile, failOnContextLeakOverride, testIndyEnabled, - otelProps.denyUnsafe - ) + otelProps.denyUnsafe, + ), ) // We do fine-grained filtering of the classpath of this codebase's sources since Gradle's // configurations will include transitive dependencies as well, which tests do often need. - val mainResourcesDir = project.layout.buildDirectory.dir("resources/main").get().asFile.absoluteFile - val mainClassesDir = project.layout.buildDirectory.dir("classes/java/main").get().asFile.absoluteFile - - classpath = classpath.filter { - if (it.absoluteFile == mainResourcesDir || it.absoluteFile == mainClassesDir) { - // The sources are packaged into the testing jar, so we need to exclude them from the test - // classpath, which automatically inherits them, to ensure our shaded versions are used. - return@filter false - } + val mainResourcesDir = + project.layout.buildDirectory + .dir( + "resources/main", + ).get() + .asFile.absoluteFile + val mainClassesDir = + project.layout.buildDirectory + .dir( + "classes/java/main", + ).get() + .asFile.absoluteFile + + classpath = + classpath.filter { + if (it.absoluteFile == mainResourcesDir || it.absoluteFile == mainClassesDir) { + // The sources are packaged into the testing jar, so we need to exclude them from the test + // classpath, which automatically inherits them, to ensure our shaded versions are used. + return@filter false + } - // TODO: Better not to have this naming constraint, we can likely use plugin identification - // instead. + // TODO: Better not to have this naming constraint, we can likely use plugin identification + // instead. - val lib = it.absoluteFile - if (lib.name.startsWith("opentelemetry-javaagent-")) { - // These dependencies are packaged into the testing jar, so we need to exclude them from the test - // classpath, which automatically inherits them, to ensure our shaded versions are used. - return@filter false - } - if (lib.name.startsWith("opentelemetry-") && lib.name.contains("-autoconfigure-")) { - // These dependencies should not be on the test classpath, because they will auto-instrument - // the library and the tests could pass even if the javaagent instrumentation fails to apply - return@filter false + val lib = it.absoluteFile + if (lib.name.startsWith("opentelemetry-javaagent-")) { + // These dependencies are packaged into the testing jar, so we need to exclude them from the test + // classpath, which automatically inherits them, to ensure our shaded versions are used. + return@filter false + } + if (lib.name.startsWith("opentelemetry-") && lib.name.contains("-autoconfigure-")) { + // These dependencies should not be on the test classpath, because they will auto-instrument + // the library and the tests could pass even if the javaagent instrumentation fails to apply + return@filter false + } + return@filter true } - return@filter true - } } } diff --git a/conventions/src/main/kotlin/io/opentelemetry/instrumentation/gradle/OtelBomExtension.kt b/conventions/src/main/kotlin/io/opentelemetry/instrumentation/gradle/OtelBomExtension.kt index 861e4754ab4c..4e4a1ff7c733 100644 --- a/conventions/src/main/kotlin/io/opentelemetry/instrumentation/gradle/OtelBomExtension.kt +++ b/conventions/src/main/kotlin/io/opentelemetry/instrumentation/gradle/OtelBomExtension.kt @@ -13,7 +13,11 @@ abstract class OtelBomExtension { abstract val projectFilter: Property> val additionalDependencies: MutableSet = hashSetOf() - fun addExtra(groupId: String, artifactId: String, version: String) { + fun addExtra( + groupId: String, + artifactId: String, + version: String + ) { this.additionalDependencies.add(groupId + ":" + artifactId + ":" + version) } } diff --git a/conventions/src/main/kotlin/io/opentelemetry/instrumentation/gradle/OtelPropsExtension.kt b/conventions/src/main/kotlin/io/opentelemetry/instrumentation/gradle/OtelPropsExtension.kt index 7511ce1ea6eb..b1e7eef2a39e 100644 --- a/conventions/src/main/kotlin/io/opentelemetry/instrumentation/gradle/OtelPropsExtension.kt +++ b/conventions/src/main/kotlin/io/opentelemetry/instrumentation/gradle/OtelPropsExtension.kt @@ -8,7 +8,9 @@ package io.opentelemetry.instrumentation.gradle import org.gradle.api.JavaVersion import org.gradle.api.Project -open class OtelPropsExtension(private val project: Project) { +open class OtelPropsExtension( + private val project: Project +) { val testLatestDeps: Boolean get() = project.findProperty("testLatestDeps") == "true" @@ -29,4 +31,4 @@ open class OtelPropsExtension(private val project: Project) { val enableStrictContext: Boolean get() = project.findProperty("enableStrictContext")?.toString()?.toBoolean() ?: true -} \ No newline at end of file +} diff --git a/conventions/src/main/kotlin/io/opentelemetry/instrumentation/gradle/StaticImportFormatter.kt b/conventions/src/main/kotlin/io/opentelemetry/instrumentation/gradle/StaticImportFormatter.kt index ee42674f0ef1..dbda406c0117 100644 --- a/conventions/src/main/kotlin/io/opentelemetry/instrumentation/gradle/StaticImportFormatter.kt +++ b/conventions/src/main/kotlin/io/opentelemetry/instrumentation/gradle/StaticImportFormatter.kt @@ -14,8 +14,9 @@ import java.io.Serializable * into unqualified references and adds the corresponding static import. Runs before * googleJavaFormat so that imports are sorted and any newly-unused regular imports are removed. */ -class StaticImportFormatter : FormatterFunc.NeedsFile, Serializable { - +class StaticImportFormatter : + FormatterFunc.NeedsFile, + Serializable { private data class Rule( val className: String, val pkg: String, @@ -25,72 +26,76 @@ class StaticImportFormatter : FormatterFunc.NeedsFile, Serializable { val contentExcludePattern: String? = null, ) : Serializable - override fun applyWithFile(input: String, source: File): String { - val rules = listOf( - Rule("Objects", "java.util.Objects", "requireNonNull"), - Rule( - "ElementMatchers", - "net.bytebuddy.matcher.ElementMatchers", - "[a-z][a-zA-Z0-9]*", - ), - Rule( - "AgentElementMatchers", - "io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers", - "[a-z][a-zA-Z0-9]*", - ), - Rule("TimeUnit", "java.util.concurrent.TimeUnit", "[A-Z][A-Z_0-9]*"), - Rule( - "StandardCharsets", - "java.nio.charset.StandardCharsets", - "[A-Z][A-Z_0-9]*", - ), - Rule( - "Arrays", - "java.util.Arrays", - "asList", - // AbstractAssert defines asList(), so the static import would be ambiguous in subclasses. - contentExcludePattern = "extends AbstractAssert", - ), - Rule( - "Collections", - "java.util.Collections", - "singleton[a-zA-Z0-9]*|empty[a-zA-Z0-9]*", - ), - Rule( - "ArgumentMatchers", - "org.mockito.ArgumentMatchers", - "[a-z][a-zA-Z0-9]*", - ), - Rule( - "Mockito", - "org.mockito.Mockito", - "mock|mockStatic|spy|when|verify|verifyNoInteractions|verifyNoMoreInteractions|doAnswer|doReturn|doThrow|lenient|never|times|atLeastOnce|withSettings", - ), - Rule("Assertions", "org.assertj.core.api.Assertions", "assertThat"), - Rule( - "OpenTelemetryAssertions", - "io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions", - "[a-z][a-zA-Z0-9]*", - ), - Rule( - "SemconvStability", - "io.opentelemetry.instrumentation.api.internal.SemconvStability", - "emit[a-zA-Z0-9]*", - ), - Rule( - "SqlDialect", - "io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlDialect", - "DOUBLE_QUOTES_ARE_[A-Z_]+" - ), - Rule("Collectors", "java.util.stream.Collectors", "[a-z][a-zA-Z0-9]*"), - Rule( - "AttributeKey", - "io.opentelemetry.api.common.AttributeKey", - "stringKey|longKey|booleanKey|doubleKey|stringArrayKey|longArrayKey|booleanArrayKey|doubleArrayKey", - lineExcludePattern = "= AttributeKey.", - filePattern = "Test\\.java$" - ), - ) + override fun applyWithFile( + input: String, + source: File + ): String { + val rules = + listOf( + Rule("Objects", "java.util.Objects", "requireNonNull"), + Rule( + "ElementMatchers", + "net.bytebuddy.matcher.ElementMatchers", + "[a-z][a-zA-Z0-9]*", + ), + Rule( + "AgentElementMatchers", + "io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers", + "[a-z][a-zA-Z0-9]*", + ), + Rule("TimeUnit", "java.util.concurrent.TimeUnit", "[A-Z][A-Z_0-9]*"), + Rule( + "StandardCharsets", + "java.nio.charset.StandardCharsets", + "[A-Z][A-Z_0-9]*", + ), + Rule( + "Arrays", + "java.util.Arrays", + "asList", + // AbstractAssert defines asList(), so the static import would be ambiguous in subclasses. + contentExcludePattern = "extends AbstractAssert", + ), + Rule( + "Collections", + "java.util.Collections", + "singleton[a-zA-Z0-9]*|empty[a-zA-Z0-9]*", + ), + Rule( + "ArgumentMatchers", + "org.mockito.ArgumentMatchers", + "[a-z][a-zA-Z0-9]*", + ), + Rule( + "Mockito", + "org.mockito.Mockito", + "mock|mockStatic|spy|when|verify|verifyNoInteractions|verifyNoMoreInteractions|doAnswer|doReturn|doThrow|lenient|never|times|atLeastOnce|withSettings", + ), + Rule("Assertions", "org.assertj.core.api.Assertions", "assertThat"), + Rule( + "OpenTelemetryAssertions", + "io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions", + "[a-z][a-zA-Z0-9]*", + ), + Rule( + "SemconvStability", + "io.opentelemetry.instrumentation.api.internal.SemconvStability", + "emit[a-zA-Z0-9]*", + ), + Rule( + "SqlDialect", + "io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlDialect", + "DOUBLE_QUOTES_ARE_[A-Z_]+" + ), + Rule("Collectors", "java.util.stream.Collectors", "[a-z][a-zA-Z0-9]*"), + Rule( + "AttributeKey", + "io.opentelemetry.api.common.AttributeKey", + "stringKey|longKey|booleanKey|doubleKey|stringArrayKey|longArrayKey|booleanArrayKey|doubleArrayKey", + lineExcludePattern = "= AttributeKey.", + filePattern = "Test\\.java$" + ), + ) var content = input val importsToAdd = mutableSetOf() @@ -104,10 +109,11 @@ class StaticImportFormatter : FormatterFunc.NeedsFile, Serializable { if (lines[i].trimStart().startsWith("import ")) continue if (rule.lineExcludePattern != null && (maxOf(0, i - 3)..i).joinToString(" ") { j -> lines[j].trim() }.contains(rule.lineExcludePattern) - ) continue + ) { + continue + } for (match in regex.findAll(lines[i])) { importsToAdd.add("import static ${rule.pkg}.${match.groupValues[1]};") - } lines[i] = regex.replace(lines[i], "$1") } @@ -130,7 +136,7 @@ class StaticImportFormatter : FormatterFunc.NeedsFile, Serializable { Triple(m.groupValues[2], m.groupValues[1], "[A-Z][A-Z_0-9]*") } for ((className, pkg, memberPattern) in semconvRules) { - val regex = Regex("\\b${className}\\.(${memberPattern})\\b") + val regex = Regex("\\b${className}\\.($memberPattern)\\b") val lines = content.lines().toMutableList() var inBlockComment = false for (i in lines.indices) { @@ -142,7 +148,7 @@ class StaticImportFormatter : FormatterFunc.NeedsFile, Serializable { } if (trimmed.startsWith("import ")) continue for (match in regex.findAll(lines[i])) { - importsToAdd.add("import static ${pkg}.${match.groupValues[1]};") + importsToAdd.add("import static $pkg.${match.groupValues[1]};") } lines[i] = regex.replace(lines[i], "$1") } @@ -189,7 +195,7 @@ class StaticImportFormatter : FormatterFunc.NeedsFile, Serializable { } if (trimmed.startsWith("import ")) continue for (match in regex.findAll(lines[i])) { - importsToAdd.add("import ${outerPkg}.${match.groupValues[1]};") + importsToAdd.add("import $outerPkg.${match.groupValues[1]};") } lines[i] = regex.replace(lines[i], "$1.$2") } diff --git a/conventions/src/main/kotlin/otel.bom-conventions.gradle.kts b/conventions/src/main/kotlin/otel.bom-conventions.gradle.kts index 22ea123789a6..c3671aacf428 100644 --- a/conventions/src/main/kotlin/otel.bom-conventions.gradle.kts +++ b/conventions/src/main/kotlin/otel.bom-conventions.gradle.kts @@ -18,11 +18,12 @@ val otelBom = extensions.create("otelBom") afterEvaluate { otelBom.projectFilter.finalizeValue() - val bomProjects = rootProject.subprojects - .sortedBy { it.findProperty("archivesName") as String? } - .filter { !it.name.startsWith("bom") } - .filter(otelBom.projectFilter.get()::test) - .filter { it.plugins.hasPlugin("maven-publish") } + val bomProjects = + rootProject.subprojects + .sortedBy { it.findProperty("archivesName") as String? } + .filter { !it.name.startsWith("bom") } + .filter(otelBom.projectFilter.get()::test) + .filter { it.plugins.hasPlugin("maven-publish") } bomProjects.forEach { project -> dependencies { @@ -42,10 +43,11 @@ afterEvaluate { // this applies version numbers to the SDK bom and SDK alpha bom which are dependencies of the instrumentation boms evaluationDependsOn(":dependencyManagement") -val dependencyManagementConf = configurations.create("dependencyManagement") { - isCanBeConsumed = false - isCanBeResolved = false -} +val dependencyManagementConf = + configurations.create("dependencyManagement") { + isCanBeConsumed = false + isCanBeResolved = false + } afterEvaluate { configurations.configureEach { if (isCanBeResolved && !isCanBeConsumed) { diff --git a/conventions/src/main/kotlin/otel.errorprone-conventions.gradle.kts b/conventions/src/main/kotlin/otel.errorprone-conventions.gradle.kts index fc19a602d4b9..4c9adacf5a77 100644 --- a/conventions/src/main/kotlin/otel.errorprone-conventions.gradle.kts +++ b/conventions/src/main/kotlin/otel.errorprone-conventions.gradle.kts @@ -153,7 +153,9 @@ tasks { // Allow underscore in test-type method names disable("MemberName") } - if ((project.path.endsWith("testing") || name.contains("Test")) && !project.name.equals("custom-checks")) { + if ((project.path.endsWith("testing") || name.contains("Test")) && + !project.name.equals("custom-checks") + ) { // This check causes too many failures, ignore the ones in tests disable("OtelCanIgnoreReturnValueSuggester") disable("OtelInternalJavadoc") diff --git a/conventions/src/main/kotlin/otel.japicmp-conventions.gradle.kts b/conventions/src/main/kotlin/otel.japicmp-conventions.gradle.kts index 8fdfae89172d..716f400dd2bb 100644 --- a/conventions/src/main/kotlin/otel.japicmp-conventions.gradle.kts +++ b/conventions/src/main/kotlin/otel.japicmp-conventions.gradle.kts @@ -18,8 +18,16 @@ val latestReleasedVersion: String by lazy { val temp: Configuration = configurations.create("tempConfig") temp.resolutionStrategy.cacheDynamicVersionsFor(0, TimeUnit.SECONDS) // pick the bom, since we don't use dependency substitution on it. - dependencies.add(temp.name, "io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom:latest.release") - val moduleVersion = configurations["tempConfig"].resolvedConfiguration.firstLevelModuleDependencies.elementAt(0).moduleVersion + dependencies.add( + temp.name, + "io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom:latest.release", + ) + val moduleVersion = + configurations["tempConfig"] + .resolvedConfiguration.firstLevelModuleDependencies + .elementAt( + 0, + ).moduleVersion configurations.remove(temp) logger.info("Discovered latest release version: $moduleVersion") @@ -37,12 +45,14 @@ fun findArtifact(version: String): File { // Maven coordinates as the project, which Gradle would not allow otherwise. group = "virtual_group" val depJar = "${base.archivesName.get()}-$version.jar" - val configuration: Configuration = configurations.detachedConfiguration( - dependencies.create(depModule) - ) - return files(configuration.files).filter { - it.name.equals(depJar) - }.singleFile + val configuration: Configuration = + configurations.detachedConfiguration( + dependencies.create(depModule), + ) + return files(configuration.files) + .filter { + it.name.equals(depJar) + }.singleFile } finally { group = existingGroup } @@ -59,8 +69,9 @@ if (project.findProperty("otel.stable") == "true" && project.path != ":javaagent // the japicmp "new" version is either the user-specified one, or the locally built jar. val apiNewVersion: String? by project - val newArtifact = apiNewVersion?.let { findArtifact(it) } - ?: file(getByName("jar").archiveFile) + val newArtifact = + apiNewVersion?.let { findArtifact(it) } + ?: file(getByName("jar").archiveFile) newClasspath.from(files(newArtifact)) // only output changes, not everything @@ -77,7 +88,7 @@ if (project.findProperty("otel.stable") == "true" && project.path != ":javaagent // so publish the whole API. We do that by flipping this flag, and comparing the current against nothing. onlyModified.set(false) files() - } + }, ) // Reproduce defaults from https://github.com/melix/japicmp-gradle-plugin/blob/09f52739ef1fccda6b4310cf3f4b19dc97377024/src/main/java/me/champeau/gradle/japicmp/report/ViolationsGenerator.java#L130 @@ -97,8 +108,14 @@ if (project.findProperty("otel.stable") == "true" && project.path != ":javaagent packageExcludes.addAll("*.internal", "*.internal.*") val baseVersionString = if (apiBaseVersion == null) "latest" else baselineVersion txtOutputFile.set( - apiNewVersion?.let { file("$rootDir/docs/apidiffs/${apiNewVersion}_vs_$baselineVersion/${base.archivesName.get()}.txt") } - ?: file("$rootDir/docs/apidiffs/current_vs_$baseVersionString/${base.archivesName.get()}.txt") + apiNewVersion?.let { + file( + "$rootDir/docs/apidiffs/${apiNewVersion}_vs_$baselineVersion/${base.archivesName.get()}.txt", + ) + } + ?: file( + "$rootDir/docs/apidiffs/current_vs_$baseVersionString/${base.archivesName.get()}.txt", + ), ) } // have the check task depend on the api comparison task, to make it more likely it will get used. diff --git a/conventions/src/main/kotlin/otel.java-conventions.gradle.kts b/conventions/src/main/kotlin/otel.java-conventions.gradle.kts index 98227bdbcbb2..3c775036c55d 100644 --- a/conventions/src/main/kotlin/otel.java-conventions.gradle.kts +++ b/conventions/src/main/kotlin/otel.java-conventions.gradle.kts @@ -34,9 +34,14 @@ java { toolchain { languageVersion.set( otelJava.minJavaVersionSupported.map { - val defaultJavaVersion = otelJava.maxJavaVersionSupported.getOrElse(DEFAULT_JAVA_VERSION).majorVersion.toInt() + val defaultJavaVersion = + otelJava.maxJavaVersionSupported + .getOrElse( + DEFAULT_JAVA_VERSION, + ).majorVersion + .toInt() JavaLanguageVersion.of(Math.max(it.majorVersion.toInt(), defaultJavaVersion)) - } + }, ) } @@ -80,8 +85,8 @@ tasks.withType().configureEach { // We suppress the "deprecation" warning because --release 8 causes javac to warn on // importing deprecated classes (fixed in JDK 9+, see https://bugs.openjdk.org/browse/JDK-8032211). // We use a custom Error Prone check instead (OtelDeprecatedApiUsage). - "-Xlint:-deprecation" - ) + "-Xlint:-deprecation", + ), ) if (System.getProperty("dev") != "true") { // Fail build on any warning @@ -123,7 +128,12 @@ afterEvaluate { } } tasks.withType().configureEach { - if (javaCompiler.isPresent && javaCompiler.get().metadata.languageVersion.canCompileOrRun(21)) { + if (javaCompiler.isPresent && + javaCompiler + .get() + .metadata.languageVersion + .canCompileOrRun(21) + ) { // new warning in jdk21 options.compilerArgs.add("-Xlint:-this-escape") } @@ -131,10 +141,11 @@ afterEvaluate { } evaluationDependsOn(":dependencyManagement") -val dependencyManagementConf = configurations.create("dependencyManagement") { - isCanBeConsumed = false - isCanBeResolved = false -} +val dependencyManagementConf = + configurations.create("dependencyManagement") { + isCanBeConsumed = false + isCanBeResolved = false + } afterEvaluate { configurations.configureEach { if (isCanBeResolved && !isCanBeConsumed) { @@ -249,8 +260,9 @@ tasks { "Implementation-Title" to project.name, "Implementation-Version" to project.version, "Implementation-Vendor" to "OpenTelemetry", - "Implementation-URL" to "https://github.com/open-telemetry/opentelemetry-java-instrumentation", - "Automatic-Module-Name" to javaModuleName + "Implementation-URL" to + "https://github.com/open-telemetry/opentelemetry-java-instrumentation", + "Automatic-Module-Name" to javaModuleName, ) } } @@ -298,7 +310,9 @@ fun isJavaVersionAllowed(version: JavaVersion): Boolean { if (otelJava.minJavaVersionSupported.get().compareTo(version) > 0) { return false } - if (otelJava.maxJavaVersionForTests.isPresent && otelJava.maxJavaVersionForTests.get().compareTo(version) < 0) { + if (otelJava.maxJavaVersionForTests.isPresent && + otelJava.maxJavaVersionForTests.get().compareTo(version) < 0 + ) { return false } return true @@ -312,12 +326,18 @@ abstract class TestcontainersBuildService : BuildService().configureEach { useJUnitPlatform() @@ -326,10 +346,12 @@ tasks.withType().configureEach { val testJavaVersion = otelProps.testJavaVersion val useJ9 = otelProps.testJavaVM == "openj9" if (useJ9 && testJavaVersion != null && testJavaVersion.isJava8) { - jvmArgs("-Xjit:exclude={io/opentelemetry/testing/internal/io/netty/buffer/HeapByteBufUtil.*}," + + jvmArgs( + "-Xjit:exclude={io/opentelemetry/testing/internal/io/netty/buffer/HeapByteBufUtil.*}," + "exclude={io/opentelemetry/testing/internal/io/netty/buffer/UnpooledHeapByteBuf.*}," + "exclude={io/opentelemetry/testing/internal/io/netty/buffer/AbstractByteBuf.*}," + - "exclude={io/opentelemetry/testing/internal/io/netty/handler/codec/base64/Base64.*}") + "exclude={io/opentelemetry/testing/internal/io/netty/handler/codec/base64/Base64.*}", + ) } // There's no real harm in setting this for all tests even if any happen to not be using context @@ -337,7 +359,9 @@ tasks.withType().configureEach { jvmArgs("-Dio.opentelemetry.context.enableStrictContext=${otelProps.enableStrictContext}") // TODO: Have agent map unshaded to shaded. if (project.findProperty("disableShadowRelocate") != "true") { - jvmArgs("-Dio.opentelemetry.javaagent.shaded.io.opentelemetry.context.enableStrictContext=${otelProps.enableStrictContext}") + jvmArgs( + "-Dio.opentelemetry.javaagent.shaded.io.opentelemetry.context.enableStrictContext=${otelProps.enableStrictContext}", + ) } else { jvmArgs("-Dotel.instrumentation.opentelemetry-api.enabled=false") jvmArgs("-Dotel.instrumentation.opentelemetry-instrumentation-api.enabled=false") @@ -352,7 +376,10 @@ tasks.withType().configureEach { // - aws-sdk as we have tests that interact with AWS and need normal trustStore // - camel as we have tests that interact with AWS and need normal trustStore // - vaadin as tests need to be able to download nodejs when not cached in ~/.vaadin/ - if (project.name != "jaxrs-2.0-payara-testing" && !project.path.contains("vaadin") && project.description != "camel-2-20" && !project.path.contains("aws-sdk")) { + if (project.name != "jaxrs-2.0-payara-testing" && !project.path.contains("vaadin") && + project.description != "camel-2-20" && + !project.path.contains("aws-sdk") + ) { jvmArgumentProviders.add(KeystoreArgumentsProvider(trustStore)) } @@ -365,7 +392,7 @@ tasks.withType().configureEach { develocity.testRetry { // You can see tests that were retried by this mechanism in the collected test reports and build scans. - maxRetries.set(maxTestRetries); + maxRetries.set(maxTestRetries) } reports { @@ -381,12 +408,13 @@ tasks.withType().configureEach { class KeystoreArgumentsProvider( @InputFile @PathSensitive(PathSensitivity.RELATIVE) - val trustStore: File + val trustStore: File, ) : CommandLineArgumentProvider { - override fun asArguments(): Iterable = listOf( - "-Djavax.net.ssl.trustStore=${trustStore.absolutePath}", - "-Djavax.net.ssl.trustStorePassword=testing" - ) + override fun asArguments(): Iterable = + listOf( + "-Djavax.net.ssl.trustStore=${trustStore.absolutePath}", + "-Djavax.net.ssl.trustStorePassword=testing", + ) } afterEvaluate { @@ -398,18 +426,22 @@ afterEvaluate { javaToolchains.launcherFor { languageVersion.set(JavaLanguageVersion.of(testJavaVersion.majorVersion)) implementation.set(if (useJ9) JvmImplementation.J9 else JvmImplementation.VENDOR_SPECIFIC) - } + }, ) isEnabled = isEnabled && isJavaVersionAllowed(testJavaVersion) } else { // We default to testing with Java 11 for most tests, but some tests don't support it, where we change // the default test task's version so commands like `./gradlew check` can test all projects regardless // of Java version. - if (!isJavaVersionAllowed(DEFAULT_JAVA_VERSION) && otelJava.maxJavaVersionForTests.isPresent) { + if (!isJavaVersionAllowed(DEFAULT_JAVA_VERSION) && + otelJava.maxJavaVersionForTests.isPresent + ) { javaLauncher.set( javaToolchains.launcherFor { - languageVersion.set(JavaLanguageVersion.of(otelJava.maxJavaVersionForTests.get().majorVersion)) - } + languageVersion.set( + JavaLanguageVersion.of(otelJava.maxJavaVersionForTests.get().majorVersion), + ) + }, ) } } @@ -457,19 +489,43 @@ configurations.configureEach { // manage, we could consider having the io.opentelemetry.instrumentation add information about // what modules they add to reference generically. dependencySubstitution { - substitute(module("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api")).using(project(":instrumentation-api")) - substitute(module("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api-incubator")).using(project(":instrumentation-api-incubator")) - substitute(module("io.opentelemetry.instrumentation:opentelemetry-instrumentation-annotations")).using(project(":instrumentation-annotations")) - substitute(module("io.opentelemetry.instrumentation:opentelemetry-instrumentation-annotations-support")).using( - project(":instrumentation-annotations-support") + substitute( + module("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api"), + ).using(project(":instrumentation-api")) + substitute( + module("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api-incubator"), + ).using(project(":instrumentation-api-incubator")) + substitute( + module("io.opentelemetry.instrumentation:opentelemetry-instrumentation-annotations"), + ).using(project(":instrumentation-annotations")) + substitute( + module( + "io.opentelemetry.instrumentation:opentelemetry-instrumentation-annotations-support", + ), + ).using( + project(":instrumentation-annotations-support"), ) - substitute(module("io.opentelemetry.javaagent:opentelemetry-javaagent-bootstrap")).using(project(":javaagent-bootstrap")) - substitute(module("io.opentelemetry.javaagent:opentelemetry-javaagent-extension-api")).using(project(":javaagent-extension-api")) - substitute(module("io.opentelemetry.javaagent:opentelemetry-javaagent-tooling")).using(project(":javaagent-tooling")) - substitute(module("io.opentelemetry.javaagent:opentelemetry-agent-for-testing")).using(project(":testing:agent-for-testing")) - substitute(module("io.opentelemetry.javaagent:opentelemetry-testing-common")).using(project(":testing-common:with-shaded-dependencies")) - substitute(module("io.opentelemetry.javaagent:opentelemetry-muzzle")).using(project(":muzzle")) - substitute(module("io.opentelemetry.javaagent:opentelemetry-javaagent")).using(project(":javaagent")) + substitute( + module("io.opentelemetry.javaagent:opentelemetry-javaagent-bootstrap"), + ).using(project(":javaagent-bootstrap")) + substitute( + module("io.opentelemetry.javaagent:opentelemetry-javaagent-extension-api"), + ).using(project(":javaagent-extension-api")) + substitute( + module("io.opentelemetry.javaagent:opentelemetry-javaagent-tooling"), + ).using(project(":javaagent-tooling")) + substitute( + module("io.opentelemetry.javaagent:opentelemetry-agent-for-testing"), + ).using(project(":testing:agent-for-testing")) + substitute( + module("io.opentelemetry.javaagent:opentelemetry-testing-common"), + ).using(project(":testing-common:with-shaded-dependencies")) + substitute( + module("io.opentelemetry.javaagent:opentelemetry-muzzle"), + ).using(project(":muzzle")) + substitute( + module("io.opentelemetry.javaagent:opentelemetry-javaagent"), + ).using(project(":javaagent")) } // The above substitutions ensure dependencies managed by this BOM for external projects refer to this repo's projects here. diff --git a/conventions/src/main/kotlin/otel.jmh-conventions.gradle.kts b/conventions/src/main/kotlin/otel.jmh-conventions.gradle.kts index 16034e93a054..14ac5b59bf02 100644 --- a/conventions/src/main/kotlin/otel.jmh-conventions.gradle.kts +++ b/conventions/src/main/kotlin/otel.jmh-conventions.gradle.kts @@ -25,8 +25,16 @@ jmh { } jmhReport { - jmhResultPath = layout.buildDirectory.file("results/jmh/results.json").get().asFile.absolutePath - jmhReportOutput = layout.buildDirectory.file("results/jmh").get().asFile.absolutePath + jmhResultPath = + layout.buildDirectory + .file("results/jmh/results.json") + .get() + .asFile.absolutePath + jmhReportOutput = + layout.buildDirectory + .file("results/jmh") + .get() + .asFile.absolutePath } tasks { diff --git a/conventions/src/main/kotlin/otel.publish-conventions.gradle.kts b/conventions/src/main/kotlin/otel.publish-conventions.gradle.kts index 73011c444d55..325f72c04a1f 100644 --- a/conventions/src/main/kotlin/otel.publish-conventions.gradle.kts +++ b/conventions/src/main/kotlin/otel.publish-conventions.gradle.kts @@ -30,13 +30,16 @@ publishing { if (groupId != "io.opentelemetry.instrumentation" && groupId != "io.opentelemetry.javaagent" && - groupId != "io.opentelemetry.javaagent.instrumentation") { - throw GradleException("Unexpected groupId for this project or its parent ${project.parent}: $groupId") + groupId != "io.opentelemetry.javaagent.instrumentation" + ) { + throw GradleException( + "Unexpected groupId for this project or its parent ${project.parent}: $groupId", + ) } pom.description.set( project.description - ?: "Instrumentation of Java libraries using OpenTelemetry." + ?: "Instrumentation of Java libraries using OpenTelemetry.", ) } @@ -55,13 +58,19 @@ publishing { developer { id.set("opentelemetry") name.set("OpenTelemetry") - url.set("https://github.com/open-telemetry/opentelemetry-java-instrumentation/discussions") + url.set( + "https://github.com/open-telemetry/opentelemetry-java-instrumentation/discussions", + ) } } scm { - connection.set("scm:git:git@github.com:open-telemetry/opentelemetry-java-instrumentation.git") - developerConnection.set("scm:git:git@github.com:open-telemetry/opentelemetry-java-instrumentation.git") + connection.set( + "scm:git:git@github.com:open-telemetry/opentelemetry-java-instrumentation.git", + ) + developerConnection.set( + "scm:git:git@github.com:open-telemetry/opentelemetry-java-instrumentation.git", + ) url.set("git@github.com:open-telemetry/opentelemetry-java-instrumentation.git") } } @@ -76,7 +85,10 @@ publishing { } } -fun artifactPrefix(p: Project, archivesBaseName: String): String { +fun artifactPrefix( + p: Project, + archivesBaseName: String, +): String { if (archivesBaseName.startsWith("opentelemetry")) { return "" } diff --git a/conventions/src/main/kotlin/otel.spotless-conventions.gradle.kts b/conventions/src/main/kotlin/otel.spotless-conventions.gradle.kts index 750d410f3aca..19b1414cf7e5 100644 --- a/conventions/src/main/kotlin/otel.spotless-conventions.gradle.kts +++ b/conventions/src/main/kotlin/otel.spotless-conventions.gradle.kts @@ -10,7 +10,7 @@ spotless { googleJavaFormat() licenseHeaderFile( rootProject.file("buildscripts/spotless.license.java"), - "(package|import|public|// Includes work from:)" + "(package|import|public|// Includes work from:)", ) toggleOffOn() target("src/**/*.java") @@ -20,7 +20,7 @@ spotless { scalafmt() licenseHeaderFile( rootProject.file("buildscripts/spotless.license.java"), - "(package|import|public)" + "(package|import|public)", ) target("src/**/*.scala") } @@ -42,12 +42,12 @@ spotless { // depends on ktlint_standard_wrapping "ktlint_standard_trailing-comma-on-declaration-site" to "disabled", // also very hard to find out where this happens - "ktlint_standard_wrapping" to "disabled" - ) + "ktlint_standard_wrapping" to "disabled", + ), ) licenseHeaderFile( rootProject.file("buildscripts/spotless.license.java"), - "(package|import|class|// Includes work from:)" + "(package|import|class|// Includes work from:)", ) } } @@ -70,8 +70,8 @@ spotless { // we use variable names like v1_10Deps "ktlint_standard_property-naming" to "disabled", // prevent moving comment to next line in latestDepTestLibrary("xxx") { // see xxx module - "ktlint_standard_function-literal" to "disabled" - ) + "ktlint_standard_function-literal" to "disabled", + ), ) } } @@ -86,7 +86,7 @@ if (project == rootProject) { ".editorconfig", "gradle.properties", ".github/**/*.sh", - "examples/**/gradle.properties" + "examples/**/gradle.properties", ) leadingTabsToSpaces() trimTrailingWhitespace() diff --git a/custom-checks/src/main/java/io/opentelemetry/javaagent/customchecks/OtelCanIgnoreReturnValueSuggester.java b/custom-checks/src/main/java/io/opentelemetry/javaagent/customchecks/OtelCanIgnoreReturnValueSuggester.java index 111bdcfbde83..9f5009a75393 100644 --- a/custom-checks/src/main/java/io/opentelemetry/javaagent/customchecks/OtelCanIgnoreReturnValueSuggester.java +++ b/custom-checks/src/main/java/io/opentelemetry/javaagent/customchecks/OtelCanIgnoreReturnValueSuggester.java @@ -26,7 +26,8 @@ @AutoService(BugChecker.class) @BugPattern( summary = - "Methods with ignorable return values (including methods that always 'return this') should be annotated with @com.google.errorprone.annotations.CanIgnoreReturnValue", + "Methods with ignorable return values (including methods that always 'return this') should" + + " be annotated with @com.google.errorprone.annotations.CanIgnoreReturnValue", severity = BugPattern.SeverityLevel.WARNING) public class OtelCanIgnoreReturnValueSuggester extends BugChecker implements BugChecker.MethodTreeMatcher { diff --git a/custom-checks/src/main/java/io/opentelemetry/javaagent/customchecks/OtelPrivateConstructorForUtilityClass.java b/custom-checks/src/main/java/io/opentelemetry/javaagent/customchecks/OtelPrivateConstructorForUtilityClass.java index de6586ab36f5..317eb9f259f3 100644 --- a/custom-checks/src/main/java/io/opentelemetry/javaagent/customchecks/OtelPrivateConstructorForUtilityClass.java +++ b/custom-checks/src/main/java/io/opentelemetry/javaagent/customchecks/OtelPrivateConstructorForUtilityClass.java @@ -19,7 +19,9 @@ @AutoService(BugChecker.class) @BugPattern( summary = - "Classes which are not intended to be instantiated should be made non-instantiable with a private constructor. This includes utility classes (classes with only static members), and the main class.", + "Classes which are not intended to be instantiated should be made non-instantiable with a" + + " private constructor. This includes utility classes (classes with only static" + + " members), and the main class.", severity = WARNING) public class OtelPrivateConstructorForUtilityClass extends BugChecker implements BugChecker.ClassTreeMatcher { diff --git a/declarative-config-bridge/src/main/java/io/opentelemetry/instrumentation/config/bridge/DeclarativeConfigPropertiesBridgeBuilder.java b/declarative-config-bridge/src/main/java/io/opentelemetry/instrumentation/config/bridge/DeclarativeConfigPropertiesBridgeBuilder.java index 0841b2690f5e..74c0c4a7a30f 100644 --- a/declarative-config-bridge/src/main/java/io/opentelemetry/instrumentation/config/bridge/DeclarativeConfigPropertiesBridgeBuilder.java +++ b/declarative-config-bridge/src/main/java/io/opentelemetry/instrumentation/config/bridge/DeclarativeConfigPropertiesBridgeBuilder.java @@ -79,7 +79,9 @@ public ConfigProperties build(AutoConfiguredOpenTelemetrySdk autoConfiguredOpenT // Should never happen throw new IllegalStateException( - "AutoConfiguredOpenTelemetrySdk does not have ConfigProperties or DeclarativeConfigProperties. This is likely a programming error in opentelemetry-java"); + "AutoConfiguredOpenTelemetrySdk does not have ConfigProperties or" + + " DeclarativeConfigProperties. This is likely a programming error in" + + " opentelemetry-java"); } /** diff --git a/dependencyManagement/build.gradle.kts b/dependencyManagement/build.gradle.kts index fd57bc63a095..2f8049028dda 100644 --- a/dependencyManagement/build.gradle.kts +++ b/dependencyManagement/build.gradle.kts @@ -2,7 +2,11 @@ plugins { `java-platform` } -data class DependencySet(val group: String, val version: String, val modules: List) +data class DependencySet( + val group: String, + val version: String, + val modules: List, +) // this line is managed by .github/scripts/update-sdk-version.sh val otelSdkVersion = "1.61.0" @@ -23,17 +27,17 @@ val groovyVersion = "4.0.31" // that can be applied in the specific instrumentation gradle file, e.g. // configurations.testRuntimeClasspath.resolutionStrategy.force "com.google.guava:guava:19.0" -val DEPENDENCY_BOMS = listOf( - // for some reason boms show up as runtime dependencies in license and vulnerability scans - // even if they are only used by test dependencies, so not using junit bom since it is LGPL - - "com.fasterxml.jackson:jackson-bom:2.21.2", - "com.google.guava:guava-bom:33.6.0-jre", - "org.apache.groovy:groovy-bom:${groovyVersion}", - "io.opentelemetry:opentelemetry-bom:${otelSdkVersion}", - "io.opentelemetry:opentelemetry-bom-alpha:${otelSdkAlphaVersion}", - "org.testcontainers:testcontainers-bom:2.0.5" -) +val DEPENDENCY_BOMS = + listOf( + // for some reason boms show up as runtime dependencies in license and vulnerability scans + // even if they are only used by test dependencies, so not using junit bom since it is LGPL + "com.fasterxml.jackson:jackson-bom:2.21.2", + "com.google.guava:guava-bom:33.6.0-jre", + "org.apache.groovy:groovy-bom:$groovyVersion", + "io.opentelemetry:opentelemetry-bom:$otelSdkVersion", + "io.opentelemetry:opentelemetry-bom-alpha:$otelSdkAlphaVersion", + "org.testcontainers:testcontainers-bom:2.0.5", + ) val autoServiceVersion = "1.1.1" val autoValueVersion = "1.11.1" @@ -44,81 +48,82 @@ val jmhVersion = "1.37" val mockitoVersion = "4.11.0" val slf4jVersion = "2.0.17" val semConvVersion = "1.40.0" -val semConvAlphaVersion = semConvVersion.replaceFirst("(-rc.*)?$".toRegex(), "-alpha$1") +val semConvAlphaVersion = semConvVersion.replaceFirst("(-rc.*)?$".toRegex(), "-alpha$1") -val CORE_DEPENDENCIES = listOf( - "io.opentelemetry.semconv:opentelemetry-semconv:${semConvVersion}", - "io.opentelemetry.semconv:opentelemetry-semconv-incubating:${semConvAlphaVersion}", - "com.google.auto.service:auto-service:${autoServiceVersion}", - "com.google.auto.service:auto-service-annotations:${autoServiceVersion}", - "com.google.auto.value:auto-value:${autoValueVersion}", - "com.google.auto.value:auto-value-annotations:${autoValueVersion}", - "com.google.errorprone:error_prone_annotations:${errorProneVersion}", - "com.google.errorprone:error_prone_core:${errorProneVersion}", - "com.google.errorprone:error_prone_test_helpers:${errorProneVersion}", - // When updating, also update conventions/build.gradle.kts - "net.bytebuddy:byte-buddy:${byteBuddyVersion}", - "net.bytebuddy:byte-buddy-dep:${byteBuddyVersion}", - "net.bytebuddy:byte-buddy-agent:${byteBuddyVersion}", - "net.bytebuddy:byte-buddy-gradle-plugin:${byteBuddyVersion}", - "org.ow2.asm:asm:${asmVersion}", - "org.ow2.asm:asm-tree:${asmVersion}", - "org.ow2.asm:asm-util:${asmVersion}", - "org.openjdk.jmh:jmh-core:${jmhVersion}", - "org.openjdk.jmh:jmh-generator-bytecode:${jmhVersion}", - "org.mockito:mockito-core:${mockitoVersion}", - "org.mockito:mockito-junit-jupiter:${mockitoVersion}", - "org.mockito:mockito-inline:${mockitoVersion}", - "org.slf4j:slf4j-api:${slf4jVersion}", - "org.slf4j:slf4j-simple:${slf4jVersion}", - "org.slf4j:log4j-over-slf4j:${slf4jVersion}", - "org.slf4j:jcl-over-slf4j:${slf4jVersion}", - "org.slf4j:jul-to-slf4j:${slf4jVersion}" -) +val CORE_DEPENDENCIES = + listOf( + "io.opentelemetry.semconv:opentelemetry-semconv:$semConvVersion", + "io.opentelemetry.semconv:opentelemetry-semconv-incubating:$semConvAlphaVersion", + "com.google.auto.service:auto-service:$autoServiceVersion", + "com.google.auto.service:auto-service-annotations:$autoServiceVersion", + "com.google.auto.value:auto-value:$autoValueVersion", + "com.google.auto.value:auto-value-annotations:$autoValueVersion", + "com.google.errorprone:error_prone_annotations:$errorProneVersion", + "com.google.errorprone:error_prone_core:$errorProneVersion", + "com.google.errorprone:error_prone_test_helpers:$errorProneVersion", + // When updating, also update conventions/build.gradle.kts + "net.bytebuddy:byte-buddy:$byteBuddyVersion", + "net.bytebuddy:byte-buddy-dep:$byteBuddyVersion", + "net.bytebuddy:byte-buddy-agent:$byteBuddyVersion", + "net.bytebuddy:byte-buddy-gradle-plugin:$byteBuddyVersion", + "org.ow2.asm:asm:$asmVersion", + "org.ow2.asm:asm-tree:$asmVersion", + "org.ow2.asm:asm-util:$asmVersion", + "org.openjdk.jmh:jmh-core:$jmhVersion", + "org.openjdk.jmh:jmh-generator-bytecode:$jmhVersion", + "org.mockito:mockito-core:$mockitoVersion", + "org.mockito:mockito-junit-jupiter:$mockitoVersion", + "org.mockito:mockito-inline:$mockitoVersion", + "org.slf4j:slf4j-api:$slf4jVersion", + "org.slf4j:slf4j-simple:$slf4jVersion", + "org.slf4j:log4j-over-slf4j:$slf4jVersion", + "org.slf4j:jcl-over-slf4j:$slf4jVersion", + "org.slf4j:jul-to-slf4j:$slf4jVersion", + ) // See the comment above about why we keep this rather large list. // There are dependencies included here that appear to have no usages, but are maintained at // this top level to help consistently satisfy large numbers of transitive dependencies. -val DEPENDENCIES = listOf( - "org.junit.jupiter:junit-jupiter-api:5.14.3", - - "io.r2dbc:r2dbc-proxy:1.1.6.RELEASE", - "ch.qos.logback:logback-classic:1.3.16", // 1.4+ requires Java 11+ - "uk.org.webcompere:system-stubs-jupiter:2.0.3", - "com.uber.nullaway:nullaway:0.13.3", - "commons-beanutils:commons-beanutils:1.11.0", - "commons-cli:commons-cli:1.11.0", - "commons-codec:commons-codec:1.21.0", - "commons-collections:commons-collections:3.2.2", - "commons-digester:commons-digester:2.1", - "commons-fileupload:commons-fileupload:1.6.0", - "commons-io:commons-io:2.21.0", - "commons-lang:commons-lang:2.6", - "commons-logging:commons-logging:1.3.6", - "commons-validator:commons-validator:1.10.1", - "io.netty:netty:3.10.6.Final", - "io.opentelemetry.contrib:opentelemetry-azure-resources:${otelContribVersion}", - "io.opentelemetry.contrib:opentelemetry-aws-resources:${otelContribVersion}", - "io.opentelemetry.contrib:opentelemetry-aws-xray-propagator:${otelContribVersion}", - "io.opentelemetry.contrib:opentelemetry-gcp-resources:${otelContribVersion}", - "io.opentelemetry.contrib:opentelemetry-cloudfoundry-resources:${otelContribVersion}", - "io.opentelemetry.contrib:opentelemetry-baggage-processor:${otelContribVersion}", - "io.opentelemetry.contrib:opentelemetry-samplers:${otelContribVersion}", - "io.opentelemetry.proto:opentelemetry-proto:1.10.0-alpha", - "io.opentelemetry:opentelemetry-extension-annotations:1.18.0", // deprecated, no longer part of bom - "org.assertj:assertj-core:3.27.7", - "org.awaitility:awaitility:4.3.0", - "com.google.code.findbugs:annotations:3.0.1u2", - "com.google.code.findbugs:jsr305:3.0.2", - "org.apache.groovy:groovy:${groovyVersion}", - "org.apache.groovy:groovy-json:${groovyVersion}", - "org.codehaus.mojo:animal-sniffer-annotations:1.27", - "org.junit-pioneer:junit-pioneer:1.9.1", - "org.objenesis:objenesis:3.5", - "javax.validation:validation-api:2.0.1.Final", - "org.snakeyaml:snakeyaml-engine:2.10", - "org.elasticmq:elasticmq-rest-sqs_2.13:1.7.1" -) +val DEPENDENCIES = + listOf( + "org.junit.jupiter:junit-jupiter-api:5.14.3", + "io.r2dbc:r2dbc-proxy:1.1.6.RELEASE", + "ch.qos.logback:logback-classic:1.3.16", // 1.4+ requires Java 11+ + "uk.org.webcompere:system-stubs-jupiter:2.0.3", + "com.uber.nullaway:nullaway:0.13.3", + "commons-beanutils:commons-beanutils:1.11.0", + "commons-cli:commons-cli:1.11.0", + "commons-codec:commons-codec:1.21.0", + "commons-collections:commons-collections:3.2.2", + "commons-digester:commons-digester:2.1", + "commons-fileupload:commons-fileupload:1.6.0", + "commons-io:commons-io:2.21.0", + "commons-lang:commons-lang:2.6", + "commons-logging:commons-logging:1.3.6", + "commons-validator:commons-validator:1.10.1", + "io.netty:netty:3.10.6.Final", + "io.opentelemetry.contrib:opentelemetry-azure-resources:$otelContribVersion", + "io.opentelemetry.contrib:opentelemetry-aws-resources:$otelContribVersion", + "io.opentelemetry.contrib:opentelemetry-aws-xray-propagator:$otelContribVersion", + "io.opentelemetry.contrib:opentelemetry-gcp-resources:$otelContribVersion", + "io.opentelemetry.contrib:opentelemetry-cloudfoundry-resources:$otelContribVersion", + "io.opentelemetry.contrib:opentelemetry-baggage-processor:$otelContribVersion", + "io.opentelemetry.contrib:opentelemetry-samplers:$otelContribVersion", + "io.opentelemetry.proto:opentelemetry-proto:1.10.0-alpha", + "io.opentelemetry:opentelemetry-extension-annotations:1.18.0", // deprecated, no longer part of bom + "org.assertj:assertj-core:3.27.7", + "org.awaitility:awaitility:4.3.0", + "com.google.code.findbugs:annotations:3.0.1u2", + "com.google.code.findbugs:jsr305:3.0.2", + "org.apache.groovy:groovy:$groovyVersion", + "org.apache.groovy:groovy-json:$groovyVersion", + "org.codehaus.mojo:animal-sniffer-annotations:1.27", + "org.junit-pioneer:junit-pioneer:1.9.1", + "org.objenesis:objenesis:3.5", + "javax.validation:validation-api:2.0.1.Final", + "org.snakeyaml:snakeyaml-engine:2.10", + "org.elasticmq:elasticmq-rest-sqs_2.13:1.7.1", + ) javaPlatform { allowDependencies() diff --git a/docs/contributing/selectModules.kts b/docs/contributing/selectModules.kts index d0f299d42125..681a5fdf7cf3 100755 --- a/docs/contributing/selectModules.kts +++ b/docs/contributing/selectModules.kts @@ -1,6 +1,6 @@ #!/usr/bin/env kotlin -//install kotlin compiler: https://kotlinlang.org/docs/tutorials/command-line.html +// install kotlin compiler: https://kotlinlang.org/docs/tutorials/command-line.html import java.io.File val includeRegex = Regex("include\\(\"(.*?)\"\\)") @@ -12,20 +12,24 @@ main(args) fun main(args: Array) { if (args.isEmpty()) { - println("Usage: ./docs/contributing/selectModules.kts instrumentation/spring/spring-boot-autoconfigure/ ...") + println( + "Usage: ./docs/contributing/selectModules.kts instrumentation/spring/spring-boot-autoconfigure/ ...", + ) return } - (args.map { - moduleOfArg( - File(File(it).absolutePath), - "/" + it.trimStart('.', '/').trimEnd('/') - ) - } + listOf(":javaagent")) - .map { Module(it) } + ( + args.map { + moduleOfArg( + File(File(it).absolutePath), + "/" + it.trimStart('.', '/').trimEnd('/'), + ) + } + listOf(":javaagent") + ).map { Module(it) } .forEach(Module::addSelfAndChildren) - File("$root/conventions/src/main/kotlin").listFiles()!! + File("$root/conventions/src/main/kotlin") + .listFiles()!! .filter { it.name.endsWith(".kts") } .forEach { children(it).forEach(Module::addSelfAndChildren) @@ -34,21 +38,25 @@ fun main(args: Array) { println("removing modules except:\n${keepModules.map { it.name }.sorted().joinToString("\n")}") val target = File("$root/settings.gradle.kts") - val text = target.readText().lines().flatMap { line -> - includeRegex.matchEntire(line)?.let { it.groupValues[1] }?.let { module -> - if (Module(module) in keepModules) { - listOf(line) - } else { - emptyList() - } - } ?: listOf(line) - - - }.joinToString("\n") + val text = + target + .readText() + .lines() + .flatMap { line -> + includeRegex.matchEntire(line)?.let { it.groupValues[1] }?.let { module -> + if (Module(module) in keepModules) { + listOf(line) + } else { + emptyList() + } + } ?: listOf(line) + }.joinToString("\n") target.writeText(text) } -data class Module(val name: String) { +data class Module( + val name: String, +) { fun children(): List { val file = moduleFile() return children(file) @@ -65,7 +73,10 @@ data class Module(val name: String) { } } -fun moduleOfArg(file: File, name: String): String { +fun moduleOfArg( + file: File, + name: String, +): String { val settings = File(file, "settings.gradle.kts") return if (settings.exists()) { root = file.absolutePath @@ -75,9 +86,9 @@ fun moduleOfArg(file: File, name: String): String { } } -fun children(file: File) = file.readText().lines().flatMap { line -> - projectRegex.find(line)?.let { it.groupValues[1] }?.let { module -> - listOf(Module(module)) - } ?: emptyList() -} - +fun children(file: File) = + file.readText().lines().flatMap { line -> + projectRegex.find(line)?.let { it.groupValues[1] }?.let { module -> + listOf(Module(module)) + } ?: emptyList() + } diff --git a/examples/extension/build.gradle.kts b/examples/extension/build.gradle.kts index 64f568aa47eb..79a280761c52 100644 --- a/examples/extension/build.gradle.kts +++ b/examples/extension/build.gradle.kts @@ -22,18 +22,19 @@ plugins { group = "io.opentelemetry.example" version = "1.0" -val versions = mapOf( - // this line is managed by .github/scripts/update-sdk-version.sh - "opentelemetrySdk" to "1.61.0", - - // these lines are managed by .github/scripts/update-version.sh - "opentelemetryJavaagent" to "2.27.0-SNAPSHOT", - "opentelemetryJavaagentAlpha" to "2.27.0-alpha-SNAPSHOT" -) - -val deps = mapOf( - "autoservice" to "com.google.auto.service:auto-service:1.1.1" -) +val versions = + mapOf( + // this line is managed by .github/scripts/update-sdk-version.sh + "opentelemetrySdk" to "1.61.0", + // these lines are managed by .github/scripts/update-version.sh + "opentelemetryJavaagent" to "2.27.0-SNAPSHOT", + "opentelemetryJavaagentAlpha" to "2.27.0-alpha-SNAPSHOT", + ) + +val deps = + mapOf( + "autoservice" to "com.google.auto.service:auto-service:1.1.1", + ) repositories { mavenCentral() @@ -48,14 +49,17 @@ configurations { We create a separate gradle configuration to grab a published Otel instrumentation agent. We don't need the agent during development of this extension module. This agent is used only during integration test. - */ + */ create("otel") } spotless { java { googleJavaFormat() - licenseHeaderFile(rootProject.file("../../buildscripts/spotless.license.java"), "(package|import|public)") + licenseHeaderFile( + rootProject.file("../../buildscripts/spotless.license.java"), + "(package|import|public)", + ) target("src/**/*.java") } } @@ -64,8 +68,16 @@ dependencies { implementation(platform("io.opentelemetry:opentelemetry-bom:${versions["opentelemetrySdk"]}")) // these serve as a test of the instrumentation boms - implementation(platform("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom:${versions["opentelemetryJavaagent"]}")) - implementation(platform("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:${versions["opentelemetryJavaagentAlpha"]}")) + implementation( + platform( + "io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom:${versions["opentelemetryJavaagent"]}", + ), + ) + implementation( + platform( + "io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:${versions["opentelemetryJavaagentAlpha"]}", + ), + ) /* Interfaces and SPIs that we implement. We use `compileOnly` dependency because during @@ -76,7 +88,7 @@ dependencies { compileOnly("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api-incubator") compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-extension-api") - //Provides @AutoService annotation that makes registration of our SPI implementations much easier + // Provides @AutoService annotation that makes registration of our SPI implementations much easier deps.getValue("autoservice").let { compileOnly(it) annotationProcessor(it) @@ -99,7 +111,7 @@ dependencies { */ implementation("org.apache.commons:commons-lang3:3.20.0") - //All dependencies below are only for tests + // All dependencies below are only for tests testImplementation("org.testcontainers:testcontainers:2.0.5") testImplementation("com.fasterxml.jackson.core:jackson-databind:2.21.2") testImplementation("com.google.protobuf:protobuf-java-util:4.34.1") @@ -115,18 +127,33 @@ dependencies { testRuntimeOnly("ch.qos.logback:logback-classic:1.5.32") - //Otel Java instrumentation that we use and extend during integration tests - add("otel", "io.opentelemetry.javaagent:opentelemetry-javaagent:${versions["opentelemetryJavaagent"]}") - - //TODO remove when start using io.opentelemetry.instrumentation.javaagent-instrumentation plugin - add("codegen", "io.opentelemetry.javaagent:opentelemetry-javaagent-tooling:${versions["opentelemetryJavaagentAlpha"]}") - add("muzzleBootstrap", "io.opentelemetry.instrumentation:opentelemetry-instrumentation-annotations-support:${versions["opentelemetryJavaagentAlpha"]}") - add("muzzleTooling", "io.opentelemetry.javaagent:opentelemetry-javaagent-extension-api:${versions["opentelemetryJavaagentAlpha"]}") - add("muzzleTooling", "io.opentelemetry.javaagent:opentelemetry-javaagent-tooling:${versions["opentelemetryJavaagentAlpha"]}") + // Otel Java instrumentation that we use and extend during integration tests + add( + "otel", + "io.opentelemetry.javaagent:opentelemetry-javaagent:${versions["opentelemetryJavaagent"]}", + ) + + // TODO remove when start using io.opentelemetry.instrumentation.javaagent-instrumentation plugin + add( + "codegen", + "io.opentelemetry.javaagent:opentelemetry-javaagent-tooling:${versions["opentelemetryJavaagentAlpha"]}", + ) + add( + "muzzleBootstrap", + "io.opentelemetry.instrumentation:opentelemetry-instrumentation-annotations-support:${versions["opentelemetryJavaagentAlpha"]}", + ) + add( + "muzzleTooling", + "io.opentelemetry.javaagent:opentelemetry-javaagent-extension-api:${versions["opentelemetryJavaagentAlpha"]}", + ) + add( + "muzzleTooling", + "io.opentelemetry.javaagent:opentelemetry-javaagent-tooling:${versions["opentelemetryJavaagentAlpha"]}", + ) } -//Produces a copy of upstream javaagent with this extension jar included inside it -//The location of extension directory inside agent jar is hard-coded in the agent source code +// Produces a copy of upstream javaagent with this extension jar included inside it +// The location of extension directory inside agent jar is hard-coded in the agent source code val extendedAgent by tasks.registering(Jar::class) { dependsOn(configurations.named("otel")) archiveFileName.set("opentelemetry-javaagent.jar") @@ -135,12 +162,13 @@ val extendedAgent by tasks.registering(Jar::class) { into("extensions") } - //Preserve MANIFEST.MF file from the upstream javaagent + // Preserve MANIFEST.MF file from the upstream javaagent doFirst { manifest.from( - zipTree(configurations.named("otel").get().singleFile).matching { - include("META-INF/MANIFEST.MF") - }.singleFile + zipTree(configurations.named("otel").get().singleFile) + .matching { + include("META-INF/MANIFEST.MF") + }.singleFile, ) } } @@ -152,9 +180,29 @@ tasks { inputs.files(layout.files(named("shadowJar"))) inputs.files(layout.files(extendedAgent)) - systemProperty("io.opentelemetry.smoketest.agentPath", configurations.named("otel").get().singleFile.absolutePath) - systemProperty("io.opentelemetry.smoketest.extendedAgentPath", extendedAgent.get().archiveFile.get().asFile.absolutePath) - systemProperty("io.opentelemetry.smoketest.extensionPath", named("shadowJar").get().archiveFile.get().asFile.absolutePath) + systemProperty( + "io.opentelemetry.smoketest.agentPath", + configurations + .named("otel") + .get() + .singleFile.absolutePath, + ) + systemProperty( + "io.opentelemetry.smoketest.extendedAgentPath", + extendedAgent + .get() + .archiveFile + .get() + .asFile.absolutePath, + ) + systemProperty( + "io.opentelemetry.smoketest.extensionPath", + named("shadowJar") + .get() + .archiveFile + .get() + .asFile.absolutePath, + ) } compileJava { diff --git a/gradle-plugins/build.gradle.kts b/gradle-plugins/build.gradle.kts index 80c87f5f4d99..1dcd53191d97 100644 --- a/gradle-plugins/build.gradle.kts +++ b/gradle-plugins/build.gradle.kts @@ -31,13 +31,13 @@ val aetherVersion = "1.1.0" dependencies { implementation("com.google.guava:guava:33.6.0-jre") // we need to use byte buddy variant that does not shade asm - implementation("net.bytebuddy:byte-buddy-gradle-plugin:${byteBuddyVersion}") { + implementation("net.bytebuddy:byte-buddy-gradle-plugin:$byteBuddyVersion") { exclude(group = "net.bytebuddy", module = "byte-buddy") } - implementation("net.bytebuddy:byte-buddy-dep:${byteBuddyVersion}") + implementation("net.bytebuddy:byte-buddy-dep:$byteBuddyVersion") - implementation("org.eclipse.aether:aether-connector-basic:${aetherVersion}") - implementation("org.eclipse.aether:aether-transport-http:${aetherVersion}") + implementation("org.eclipse.aether:aether-connector-basic:$aetherVersion") + implementation("org.eclipse.aether:aether-transport-http:$aetherVersion") implementation("org.apache.maven:maven-aether-provider:3.3.9") implementation("com.gradleup.shadow:shadow-gradle-plugin:9.4.1") { @@ -79,12 +79,14 @@ gradlePlugin { plugins { get("io.opentelemetry.instrumentation.muzzle-generation").apply { displayName = "Muzzle safety net generation" - description = "https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/docs/contributing/muzzle.md" + description = + "https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/docs/contributing/muzzle.md" tags.set(listOf("opentelemetry", "instrumentation", "java")) } get("io.opentelemetry.instrumentation.muzzle-check").apply { displayName = "Checks instrumented libraries against muzzle safety net" - description = "https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/docs/contributing/muzzle.md" + description = + "https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/docs/contributing/muzzle.md" tags.set(listOf("opentelemetry", "instrumentation", "java")) } } @@ -141,13 +143,19 @@ afterEvaluate { developer { id.set("opentelemetry") name.set("OpenTelemetry") - url.set("https://github.com/open-telemetry/opentelemetry-java-instrumentation/discussions") + url.set( + "https://github.com/open-telemetry/opentelemetry-java-instrumentation/discussions", + ) } } scm { - connection.set("scm:git:git@github.com:open-telemetry/opentelemetry-java-instrumentation.git") - developerConnection.set("scm:git:git@github.com:open-telemetry/opentelemetry-java-instrumentation.git") + connection.set( + "scm:git:git@github.com:open-telemetry/opentelemetry-java-instrumentation.git", + ) + developerConnection.set( + "scm:git:git@github.com:open-telemetry/opentelemetry-java-instrumentation.git", + ) url.set("git@github.com:open-telemetry/opentelemetry-java-instrumentation.git") } } diff --git a/gradle-plugins/src/main/kotlin/io.opentelemetry.instrumentation.muzzle-check.gradle.kts b/gradle-plugins/src/main/kotlin/io.opentelemetry.instrumentation.muzzle-check.gradle.kts index 4eab207e9b79..6cf75097b57f 100644 --- a/gradle-plugins/src/main/kotlin/io.opentelemetry.instrumentation.muzzle-check.gradle.kts +++ b/gradle-plugins/src/main/kotlin/io.opentelemetry.instrumentation.muzzle-check.gradle.kts @@ -95,7 +95,10 @@ listOf(shadowModule, shadowMuzzleTooling, shadowMuzzleBootstrap).forEach { task if (project.findProperty("disableShadowRelocate") != "true") { // prevents conflict with library instrumentation, since these classes live in the bootstrap class loader - relocate("io.opentelemetry.instrumentation", "io.opentelemetry.javaagent.shaded.instrumentation") { + relocate( + "io.opentelemetry.instrumentation", + "io.opentelemetry.javaagent.shaded.instrumentation", + ) { // Exclude resource providers since they live in the agent class loader exclude("io.opentelemetry.instrumentation.resources.*") exclude("io.opentelemetry.instrumentation.spring.resources.*") @@ -103,20 +106,38 @@ listOf(shadowModule, shadowMuzzleTooling, shadowMuzzleBootstrap).forEach { task // relocate(OpenTelemetry API) since these classes live in the bootstrap class loader relocate("io.opentelemetry.api", "io.opentelemetry.javaagent.shaded.io.opentelemetry.api") - relocate("io.opentelemetry.semconv", "io.opentelemetry.javaagent.shaded.io.opentelemetry.semconv") - relocate("io.opentelemetry.context", "io.opentelemetry.javaagent.shaded.io.opentelemetry.context") - relocate("io.opentelemetry.common", "io.opentelemetry.javaagent.shaded.io.opentelemetry.common") + relocate( + "io.opentelemetry.semconv", + "io.opentelemetry.javaagent.shaded.io.opentelemetry.semconv", + ) + relocate( + "io.opentelemetry.context", + "io.opentelemetry.javaagent.shaded.io.opentelemetry.context", + ) + relocate( + "io.opentelemetry.common", + "io.opentelemetry.javaagent.shaded.io.opentelemetry.common", + ) } // relocate(the OpenTelemetry extensions that are used by instrumentation modules) // these extensions live in the AgentClassLoader, and are injected into the user's class loader // by the instrumentation modules that use them - relocate("io.opentelemetry.contrib.awsxray", "io.opentelemetry.javaagent.shaded.io.opentelemetry.contrib.awsxray") - relocate("io.opentelemetry.extension.kotlin", "io.opentelemetry.javaagent.shaded.io.opentelemetry.extension.kotlin") + relocate( + "io.opentelemetry.contrib.awsxray", + "io.opentelemetry.javaagent.shaded.io.opentelemetry.contrib.awsxray", + ) + relocate( + "io.opentelemetry.extension.kotlin", + "io.opentelemetry.javaagent.shaded.io.opentelemetry.extension.kotlin", + ) // this is for instrumentation of opentelemetry-api and opentelemetry-instrumentation-api relocate("application.io.opentelemetry", "io.opentelemetry") - relocate("application.io.opentelemetry.instrumentation.api", "io.opentelemetry.instrumentation.api") + relocate( + "application.io.opentelemetry.instrumentation.api", + "io.opentelemetry.instrumentation.api", + ) // this is for instrumentation on java.util.logging (since java.util.logging itself is shaded above) relocate("application.java.util.logging", "java.util.logging") @@ -140,31 +161,42 @@ tasks.register("printMuzzleReferences") { description = "Print references created by instrumentation muzzle" val muzzleShadowJarFile = shadowModule.flatMap { it.archiveFile } val muzzleToolingShadowJarFile = shadowMuzzleTooling.flatMap { it.archiveFile } - + dependsOn(compileMuzzle) dependsOn(shadowModule) dependsOn(shadowMuzzleTooling) - + doLast { // Create instrumentation classloader - val instrumentationUrls = arrayOf( - muzzleShadowJarFile.get().asFile.toURI().toURL(), - muzzleToolingShadowJarFile.get().asFile.toURI().toURL() - ) - val instrumentationCL = URLClassLoader(instrumentationUrls, ClassLoader.getPlatformClassLoader()) - + val instrumentationUrls = + arrayOf( + muzzleShadowJarFile + .get() + .asFile + .toURI() + .toURL(), + muzzleToolingShadowJarFile + .get() + .asFile + .toURI() + .toURL(), + ) + val instrumentationCL = + URLClassLoader(instrumentationUrls, ClassLoader.getPlatformClassLoader()) + MuzzleGradlePluginUtil.printMuzzleReferences(instrumentationCL) } } -val hasRelevantTask = gradle.startParameter.taskNames.any { - // removing leading ':' if present - val taskName = it.removePrefix(":") - val projectPath = project.path.substring(1) - // Either the specific muzzle task in this project or a top level muzzle task. - taskName == "${projectPath}:muzzle" || taskName.startsWith("instrumentation:muzzle") || - taskName.contains(":muzzle-Assert") -} +val hasRelevantTask = + gradle.startParameter.taskNames.any { + // removing leading ':' if present + val taskName = it.removePrefix(":") + val projectPath = project.path.substring(1) + // Either the specific muzzle task in this project or a top level muzzle task. + taskName == "$projectPath:muzzle" || taskName.startsWith("instrumentation:muzzle") || + taskName.contains(":muzzle-Assert") + } if (hasRelevantTask) { val system = newRepositorySystem() @@ -182,12 +214,27 @@ if (hasRelevantTask) { if (muzzleDirective.coreJdk.get()) { runAfter = addMuzzleTask(muzzleDirective, null, runAfter) } else { - for (singleVersion in muzzleDirectiveToArtifacts(muzzleDirective, system, session, projectRepositories)) { + for (singleVersion in muzzleDirectiveToArtifacts( + muzzleDirective, + system, + session, + projectRepositories, + )) { runAfter = addMuzzleTask(muzzleDirective, singleVersion, runAfter) } if (muzzleDirective.assertInverse.get()) { - for (inverseDirective in inverseOf(muzzleDirective, system, session, projectRepositories)) { - for (singleVersion in muzzleDirectiveToArtifacts(inverseDirective, system, session, projectRepositories)) { + for (inverseDirective in inverseOf( + muzzleDirective, + system, + session, + projectRepositories, + )) { + for (singleVersion in muzzleDirectiveToArtifacts( + inverseDirective, + system, + session, + projectRepositories, + )) { runAfter = addMuzzleTask(inverseDirective, singleVersion, runAfter) } } @@ -198,57 +245,75 @@ if (hasRelevantTask) { } fun getProjectRepositories(project: Project): List { - val projectRepositories = project.repositories - .filterIsInstance() - .map { - RemoteRepository.Builder( - it.name, - "default", - it.url.toString()) - .build() - } + val projectRepositories = + project.repositories + .filterIsInstance() + .map { + RemoteRepository + .Builder( + it.name, + "default", + it.url.toString(), + ).build() + } // dependencyResolutionManagement.repositories are not being added to project.repositories, // they need to be queries separately if (projectRepositories.isEmpty()) { // Manually add mavenCentral until https://github.com/gradle/gradle/issues/17295 // Adding mavenLocal is much more complicated but hopefully isn't required for normal usage of // Muzzle. - return listOf(RemoteRepository.Builder( - "MavenCentral", "default", "https://repo.maven.apache.org/maven2/") - .build()) + return listOf( + RemoteRepository + .Builder("MavenCentral", "default", "https://repo.maven.apache.org/maven2/") + .build(), + ) } return projectRepositories } -fun createInstrumentationClassloader(muzzleShadowJar: File, muzzleToolingShadowJar: File): ClassLoader { +fun createInstrumentationClassloader( + muzzleShadowJar: File, + muzzleToolingShadowJar: File, +): ClassLoader { logger.info("Creating instrumentation class loader for: $path") - return classpathLoader(files(muzzleShadowJar, muzzleToolingShadowJar), ClassLoader.getPlatformClassLoader()) + return classpathLoader( + files(muzzleShadowJar, muzzleToolingShadowJar), + ClassLoader.getPlatformClassLoader(), + ) } -fun classpathLoader(classpath: FileCollection, parent: ClassLoader): ClassLoader { +fun classpathLoader( + classpath: FileCollection, + parent: ClassLoader, +): ClassLoader { logger.info("Adding to class loader:") - val urls: Array = StreamSupport.stream(classpath.spliterator(), false) - .map { - logger.info("--${it}") - it.toURI().toURL() - } - .toArray(::arrayOfNulls) + val urls: Array = + StreamSupport + .stream(classpath.spliterator(), false) + .map { + logger.info("--$it") + it.toURI().toURL() + }.toArray(::arrayOfNulls) if (parent is URLClassLoader) { parent.urLs.forEach { - logger.info("--${it}") + logger.info("--$it") } } return URLClassLoader(urls, parent) } -fun newRepositorySystem(): RepositorySystem { - return MavenRepositorySystemUtils.newServiceLocator().apply { - addService(RepositoryConnectorFactory::class.java, BasicRepositoryConnectorFactory::class.java) - addService(TransporterFactory::class.java, HttpTransporterFactory::class.java) - }.run { - getService(RepositorySystem::class.java) - } -} +fun newRepositorySystem(): RepositorySystem = + MavenRepositorySystemUtils + .newServiceLocator() + .apply { + addService( + RepositoryConnectorFactory::class.java, + BasicRepositoryConnectorFactory::class.java, + ) + addService(TransporterFactory::class.java, HttpTransporterFactory::class.java) + }.run { + getService(RepositorySystem::class.java) + } fun newRepositorySystemSession(system: RepositorySystem): RepositorySystemSession { val muzzleRepo = layout.buildDirectory.dir("muzzleRepo") @@ -258,150 +323,206 @@ fun newRepositorySystemSession(system: RepositorySystem): RepositorySystemSessio } } -fun addMuzzleTask(muzzleDirective: MuzzleDirective, versionArtifact: Artifact?, runAfter: TaskProvider) - : TaskProvider { - val taskName = if (versionArtifact == null) { - "muzzle-Assert${muzzleDirective}" - } else { - StringBuilder("muzzle-Assert").apply { - if (muzzleDirective.assertPass.get()) { - append("Pass") - } else { - append("Fail") - } - append('-') - .append(versionArtifact.groupId) - .append('-') - .append(versionArtifact.artifactId) - .append('-') - .append(versionArtifact.version) - if (!muzzleDirective.name.get().isEmpty()) { - append(muzzleDirective.nameSlug) - } - }.run { toString() } - } +fun addMuzzleTask( + muzzleDirective: MuzzleDirective, + versionArtifact: Artifact?, + runAfter: TaskProvider, +): TaskProvider { + val taskName = + if (versionArtifact == null) { + "muzzle-Assert$muzzleDirective" + } else { + StringBuilder("muzzle-Assert") + .apply { + if (muzzleDirective.assertPass.get()) { + append("Pass") + } else { + append("Fail") + } + append('-') + .append(versionArtifact.groupId) + .append('-') + .append(versionArtifact.artifactId) + .append('-') + .append(versionArtifact.version) + if (!muzzleDirective.name.get().isEmpty()) { + append(muzzleDirective.nameSlug) + } + }.run { toString() } + } val config = configurations.create(taskName) if (versionArtifact != null) { - val dep = (dependencies.create(versionArtifact.run { "${groupId}:${artifactId}:${version}" }) as ModuleDependency).apply { - isTransitive = true - exclude("com.sun.jdmk", "jmxtools") - exclude("com.sun.jmx", "jmxri") - for (excluded in muzzleDirective.excludedDependencies.get()) { - val (group, module) = excluded.split(':') - exclude(group, module) + val dep = + ( + dependencies.create( + versionArtifact.run { + "$groupId:$artifactId:$version" + }, + ) as ModuleDependency + ).apply { + isTransitive = true + exclude("com.sun.jdmk", "jmxtools") + exclude("com.sun.jmx", "jmxri") + for (excluded in muzzleDirective.excludedDependencies.get()) { + val (group, module) = excluded.split(':') + exclude(group, module) + } } - } config.dependencies.add(dep) for (additionalDependency in muzzleDirective.additionalDependencies.get()) { - val additional = if (additionalDependency is String && additionalDependency.count { it == ':' } < 2) { - // Dependency definition without version, use the artifact's version. - "${additionalDependency}:${versionArtifact.version}" - } else { - additionalDependency - } - val additionalDep = (dependencies.create(additional) as ModuleDependency).apply { - isTransitive = true - } + val additional = + if (additionalDependency is String && + additionalDependency.count { it == ':' } < 2 + ) { + // Dependency definition without version, use the artifact's version. + "$additionalDependency:${versionArtifact.version}" + } else { + additionalDependency + } + val additionalDep = + (dependencies.create(additional) as ModuleDependency).apply { + isTransitive = true + } config.dependencies.add(additionalDep) } } - val muzzleTask = tasks.register(taskName) { - // Some old library versions have broken or missing transitive dependencies - // on Maven Central (e.g. SNAPSHOTs, Maven 1 POMs, deleted artifacts). - // Use lenient resolution so these don't break configuration cache - // serialization. For assertFail this is always safe: fewer classes can only - // add more mismatches. For assertPass a missing transitive can cause a - // false muzzle failure but never a false pass; such versions should be - // skipped in the module's build.gradle.kts when found. - val configFiles = config.incoming.artifactView { lenient(true) }.files - val muzzleShadowJarFile = shadowModule.flatMap { it.archiveFile } - val muzzleToolingShadowJarFile = shadowMuzzleTooling.flatMap { it.archiveFile } - val muzzleBootstrapShadowJarFile = shadowMuzzleBootstrap.flatMap { it.archiveFile } - val excludedNames = muzzleDirective.excludedInstrumentationNames.get() - val shouldAssertPass = muzzleDirective.assertPass.get() - - dependsOn(configurations.named("runtimeClasspath")) - dependsOn(shadowModule) - dependsOn(shadowMuzzleTooling) - dependsOn(shadowMuzzleBootstrap) - - doLast { - // Create instrumentation classloader - val instrumentationUrls = arrayOf( - muzzleShadowJarFile.get().asFile.toURI().toURL(), - muzzleToolingShadowJarFile.get().asFile.toURI().toURL() - ) - val instrumentationCL = URLClassLoader(instrumentationUrls, ClassLoader.getPlatformClassLoader()) - - // Create user classloader - val userUrls = (configFiles + muzzleBootstrapShadowJarFile.get().asFile).map { it.toURI().toURL() }.toTypedArray() - val userCL = URLClassLoader(userUrls, ClassLoader.getPlatformClassLoader()) - - MuzzleGradlePluginUtil.assertInstrumentationMuzzled(instrumentationCL, userCL, - excludedNames, shouldAssertPass) + val muzzleTask = + tasks.register(taskName) { + // Some old library versions have broken or missing transitive dependencies + // on Maven Central (e.g. SNAPSHOTs, Maven 1 POMs, deleted artifacts). + // Use lenient resolution so these don't break configuration cache + // serialization. For assertFail this is always safe: fewer classes can only + // add more mismatches. For assertPass a missing transitive can cause a + // false muzzle failure but never a false pass; such versions should be + // skipped in the module's build.gradle.kts when found. + val configFiles = config.incoming.artifactView { lenient(true) }.files + val muzzleShadowJarFile = shadowModule.flatMap { it.archiveFile } + val muzzleToolingShadowJarFile = shadowMuzzleTooling.flatMap { it.archiveFile } + val muzzleBootstrapShadowJarFile = shadowMuzzleBootstrap.flatMap { it.archiveFile } + val excludedNames = muzzleDirective.excludedInstrumentationNames.get() + val shouldAssertPass = muzzleDirective.assertPass.get() + + dependsOn(configurations.named("runtimeClasspath")) + dependsOn(shadowModule) + dependsOn(shadowMuzzleTooling) + dependsOn(shadowMuzzleBootstrap) + + doLast { + // Create instrumentation classloader + val instrumentationUrls = + arrayOf( + muzzleShadowJarFile + .get() + .asFile + .toURI() + .toURL(), + muzzleToolingShadowJarFile + .get() + .asFile + .toURI() + .toURL(), + ) + val instrumentationCL = + URLClassLoader(instrumentationUrls, ClassLoader.getPlatformClassLoader()) + + // Create user classloader + val userUrls = + (configFiles + muzzleBootstrapShadowJarFile.get().asFile) + .map { + it.toURI().toURL() + }.toTypedArray() + val userCL = URLClassLoader(userUrls, ClassLoader.getPlatformClassLoader()) + + MuzzleGradlePluginUtil.assertInstrumentationMuzzled( + instrumentationCL, + userCL, + excludedNames, + shouldAssertPass, + ) + } } - } runAfter.configure { finalizedBy(muzzleTask) } return muzzleTask } -fun createClassLoaderForTask(muzzleTaskFiles: FileCollection, muzzleBootstrapShadowJar: File): ClassLoader { +fun createClassLoaderForTask( + muzzleTaskFiles: FileCollection, + muzzleBootstrapShadowJar: File, +): ClassLoader { logger.info("Creating user class loader for muzzle check") - return classpathLoader(muzzleTaskFiles + files(muzzleBootstrapShadowJar), ClassLoader.getPlatformClassLoader()) + return classpathLoader( + muzzleTaskFiles + files(muzzleBootstrapShadowJar), + ClassLoader.getPlatformClassLoader(), + ) } -fun inverseOf(muzzleDirective: MuzzleDirective, system: RepositorySystem, session: RepositorySystemSession, repos: List): Set { +fun inverseOf( + muzzleDirective: MuzzleDirective, + system: RepositorySystem, + session: RepositorySystemSession, + repos: List, +): Set { val inverseDirectives = mutableSetOf() - val allVersionsArtifact = DefaultArtifact( - muzzleDirective.group.get(), - muzzleDirective.module.get(), - muzzleDirective.classifier.get(), - "jar", - "[,)") - val directiveArtifact = DefaultArtifact( - muzzleDirective.group.get(), - muzzleDirective.module.get(), - muzzleDirective.classifier.get(), - "jar", - muzzleDirective.versions.get()) - - val allRangeRequest = VersionRangeRequest().apply { - repositories = repos - artifact = allVersionsArtifact - } + val allVersionsArtifact = + DefaultArtifact( + muzzleDirective.group.get(), + muzzleDirective.module.get(), + muzzleDirective.classifier.get(), + "jar", + "[,)", + ) + val directiveArtifact = + DefaultArtifact( + muzzleDirective.group.get(), + muzzleDirective.module.get(), + muzzleDirective.classifier.get(), + "jar", + muzzleDirective.versions.get(), + ) + + val allRangeRequest = + VersionRangeRequest().apply { + repositories = repos + artifact = allVersionsArtifact + } val allRangeResult = system.resolveVersionRange(session, allRangeRequest) - val rangeRequest = VersionRangeRequest().apply { - repositories = repos - artifact = directiveArtifact - } + val rangeRequest = + VersionRangeRequest().apply { + repositories = repos + artifact = directiveArtifact + } val rangeResult = system.resolveVersionRange(session, rangeRequest) allRangeResult.versions.removeAll(rangeResult.versions) for (version in filterVersions(allRangeResult, muzzleDirective.normalizedSkipVersions)) { - val inverseDirective = objects.newInstance(MuzzleDirective::class).apply { - name.set(muzzleDirective.name) - group.set(muzzleDirective.group) - module.set(muzzleDirective.module) - classifier.set(muzzleDirective.classifier) - versions.set(version) - assertPass.set(!muzzleDirective.assertPass.get()) - additionalDependencies.set(muzzleDirective.additionalDependencies) - excludedDependencies.set(muzzleDirective.excludedDependencies) - excludedInstrumentationNames.set(muzzleDirective.excludedInstrumentationNames) - } + val inverseDirective = + objects.newInstance(MuzzleDirective::class).apply { + name.set(muzzleDirective.name) + group.set(muzzleDirective.group) + module.set(muzzleDirective.module) + classifier.set(muzzleDirective.classifier) + versions.set(version) + assertPass.set(!muzzleDirective.assertPass.get()) + additionalDependencies.set(muzzleDirective.additionalDependencies) + excludedDependencies.set(muzzleDirective.excludedDependencies) + excludedInstrumentationNames.set(muzzleDirective.excludedInstrumentationNames) + } inverseDirectives.add(inverseDirective) } return inverseDirectives } -fun filterVersions(range: VersionRangeResult, skipVersions: Set) = sequence { +fun filterVersions( + range: VersionRangeResult, + skipVersions: Set, +) = sequence { val predicate = AcceptableVersions(skipVersions) if (predicate.test(range.lowestVersion)) { yield(range.lowestVersion.toString()) @@ -418,29 +539,39 @@ fun filterVersions(range: VersionRangeResult, skipVersions: Set) = seque } }.distinct().take(RANGE_COUNT_LIMIT) -fun muzzleDirectiveToArtifacts(muzzleDirective: MuzzleDirective, system: RepositorySystem, session: RepositorySystemSession, repos: List) = sequence { - val directiveArtifact: Artifact = DefaultArtifact( - muzzleDirective.group.get(), - muzzleDirective.module.get(), - muzzleDirective.classifier.get(), - "jar", - muzzleDirective.versions.get()) - - val rangeRequest = VersionRangeRequest().apply { - repositories = repos - artifact = directiveArtifact - } - val rangeResult = system.resolveVersionRange(session, rangeRequest) +fun muzzleDirectiveToArtifacts( + muzzleDirective: MuzzleDirective, + system: RepositorySystem, + session: RepositorySystemSession, + repos: List, +) = sequence { + val directiveArtifact: Artifact = + DefaultArtifact( + muzzleDirective.group.get(), + muzzleDirective.module.get(), + muzzleDirective.classifier.get(), + "jar", + muzzleDirective.versions.get(), + ) - val allVersionArtifacts = filterVersions(rangeResult, muzzleDirective.normalizedSkipVersions) - .map { - DefaultArtifact( - muzzleDirective.group.get(), - muzzleDirective.module.get(), - muzzleDirective.classifier.get(), - "jar", - it) + val rangeRequest = + VersionRangeRequest().apply { + repositories = repos + artifact = directiveArtifact } + val rangeResult = system.resolveVersionRange(session, rangeRequest) + + val allVersionArtifacts = + filterVersions(rangeResult, muzzleDirective.normalizedSkipVersions) + .map { + DefaultArtifact( + muzzleDirective.group.get(), + muzzleDirective.module.get(), + muzzleDirective.classifier.get(), + "jar", + it, + ) + } allVersionArtifacts.ifEmpty { throw GradleException("No muzzle artifacts found for $muzzleDirective") diff --git a/gradle-plugins/src/main/kotlin/io.opentelemetry.instrumentation.muzzle-generation.gradle.kts b/gradle-plugins/src/main/kotlin/io.opentelemetry.instrumentation.muzzle-generation.gradle.kts index cacc2460352d..34bf0cbf83d9 100644 --- a/gradle-plugins/src/main/kotlin/io.opentelemetry.instrumentation.muzzle-generation.gradle.kts +++ b/gradle-plugins/src/main/kotlin/io.opentelemetry.instrumentation.muzzle-generation.gradle.kts @@ -1,6 +1,6 @@ -import java.net.URLConnection import net.bytebuddy.ClassFileVersion import net.bytebuddy.build.gradle.ByteBuddySimpleTask +import java.net.URLConnection plugins { `java-library` @@ -33,26 +33,30 @@ val codegen by configurations.creating { } val sourceSet = sourceSets.main.get() -val inputClasspath = (sourceSet.output.resourcesDir?.let { codegen.plus(project.files(it)) } - ?: codegen) - .plus(sourceSet.output.dirs) // needed to support embedding shadowed modules into instrumentation - .plus(configurations.runtimeClasspath.get()) +val inputClasspath = + ( + sourceSet.output.resourcesDir?.let { codegen.plus(project.files(it)) } + ?: codegen + ).plus(sourceSet.output.dirs) // needed to support embedding shadowed modules into instrumentation + .plus(configurations.runtimeClasspath.get()) // disable url connection caching to avoid java.util.zip.ZipException: ZipFile invalid LOC header (bad signature) // during byte buddy plugin discovery when muzzle jar has changed URLConnection.setDefaultUseCaches("jar", false) -val languageTasks = LANGUAGES.map { language -> - if (fileTree("src/${sourceSet.name}/${language}").isEmpty) { - return@map null - } - val compileTaskName = sourceSet.getCompileTaskName(language) - if (!tasks.names.contains(compileTaskName)) { - return@map null - } - val compileTask = tasks.named(compileTaskName) - createLanguageTask(compileTask, "byteBuddy${language.replaceFirstChar(Char::titlecase)}") -}.filterNotNull() +val languageTasks = + LANGUAGES + .map { language -> + if (fileTree("src/${sourceSet.name}/$language").isEmpty) { + return@map null + } + val compileTaskName = sourceSet.getCompileTaskName(language) + if (!tasks.names.contains(compileTaskName)) { + return@map null + } + val compileTask = tasks.named(compileTaskName) + createLanguageTask(compileTask, "byteBuddy${language.replaceFirstChar(Char::titlecase)}") + }.filterNotNull() tasks { named(sourceSet.classesTaskName) { @@ -61,8 +65,10 @@ tasks { } fun createLanguageTask( - compileTaskProvider: TaskProvider<*>, name: String): TaskProvider<*> { - return tasks.register(name) { + compileTaskProvider: TaskProvider<*>, + name: String, +): TaskProvider<*> = + tasks.register(name) { group = "Byte Buddy" outputs.cacheIf { true } classFileVersion = ClassFileVersion.JAVA_V8 @@ -71,8 +77,9 @@ fun createLanguageTask( // this does not work for kotlin as compile task does not extend AbstractCompile if (compileTask is AbstractCompile) { val classesDirectory = compileTask.destinationDirectory.asFile.get() - val rawClassesDirectory: File = File(classesDirectory.parent, "${classesDirectory.name}raw") - .absoluteFile + val rawClassesDirectory: File = + File(classesDirectory.parent, "${classesDirectory.name}raw") + .absoluteFile compileTask.destinationDirectory.set(rawClassesDirectory) source = rawClassesDirectory target = classesDirectory @@ -81,4 +88,3 @@ fun createLanguageTask( discoverySet = codegen } } -} diff --git a/gradle-plugins/src/main/kotlin/io/opentelemetry/javaagent/muzzle/AcceptableVersions.kt b/gradle-plugins/src/main/kotlin/io/opentelemetry/javaagent/muzzle/AcceptableVersions.kt index 6271152efb47..0d352c8fd856 100644 --- a/gradle-plugins/src/main/kotlin/io/opentelemetry/javaagent/muzzle/AcceptableVersions.kt +++ b/gradle-plugins/src/main/kotlin/io/opentelemetry/javaagent/muzzle/AcceptableVersions.kt @@ -9,9 +9,9 @@ import org.eclipse.aether.version.Version import java.util.Locale import java.util.function.Predicate -class AcceptableVersions(private val skipVersions: Collection) : - Predicate { - +class AcceptableVersions( + private val skipVersions: Collection +) : Predicate { override fun test(version: Version?): Boolean { if (version == null) { return false @@ -20,22 +20,23 @@ class AcceptableVersions(private val skipVersions: Collection) : if (skipVersions.contains(versionString)) { return false } - val draftVersion = versionString.contains("rc") - || versionString.contains(".cr") - || versionString.contains("alpha") - || versionString.contains("beta") - || versionString.contains("-b") - || versionString.contains(".m") - || versionString.contains("-m") - || versionString.contains("-dev") - || versionString.contains("-ea") - || versionString.contains("-atlassian-") - || versionString.contains("public_draft") - || versionString.contains("snapshot") - || versionString.contains("test") - || versionString.startsWith("0.0.0-") - || GIT_SHA_PATTERN.matches(versionString) - || DATETIME_PATTERN.matches(versionString) + val draftVersion = + versionString.contains("rc") || + versionString.contains(".cr") || + versionString.contains("alpha") || + versionString.contains("beta") || + versionString.contains("-b") || + versionString.contains(".m") || + versionString.contains("-m") || + versionString.contains("-dev") || + versionString.contains("-ea") || + versionString.contains("-atlassian-") || + versionString.contains("public_draft") || + versionString.contains("snapshot") || + versionString.contains("test") || + versionString.startsWith("0.0.0-") || + GIT_SHA_PATTERN.matches(versionString) || + DATETIME_PATTERN.matches(versionString) return !draftVersion } diff --git a/gradle-plugins/src/main/kotlin/io/opentelemetry/javaagent/muzzle/MuzzleDirective.kt b/gradle-plugins/src/main/kotlin/io/opentelemetry/javaagent/muzzle/MuzzleDirective.kt index d2754ed5c41e..f56862a92ae2 100644 --- a/gradle-plugins/src/main/kotlin/io/opentelemetry/javaagent/muzzle/MuzzleDirective.kt +++ b/gradle-plugins/src/main/kotlin/io/opentelemetry/javaagent/muzzle/MuzzleDirective.kt @@ -11,7 +11,6 @@ import org.gradle.api.provider.SetProperty import java.util.stream.Collectors abstract class MuzzleDirective { - abstract val name: Property abstract val group: Property abstract val module: Property @@ -77,9 +76,12 @@ abstract class MuzzleDirective { get() = NORMALIZE_NAME_SLUG.replace(name.get().trim(), "-") internal val normalizedSkipVersions: Set - get() = skipVersions.getOrElse(setOf()).stream() - .map(String::lowercase) - .collect(Collectors.toSet()) + get() = + skipVersions + .getOrElse(setOf()) + .stream() + .map(String::lowercase) + .collect(Collectors.toSet()) override fun toString(): String { val sb = StringBuilder() @@ -96,7 +98,8 @@ abstract class MuzzleDirective { } else { sb.append("fail") } - sb.append(group.get()) + sb + .append(group.get()) .append(':') .append(module.get()) .append(':') diff --git a/gradle-plugins/src/main/kotlin/io/opentelemetry/javaagent/muzzle/MuzzleExtension.kt b/gradle-plugins/src/main/kotlin/io/opentelemetry/javaagent/muzzle/MuzzleExtension.kt index e9af96a12adf..fa4e524e1e65 100644 --- a/gradle-plugins/src/main/kotlin/io/opentelemetry/javaagent/muzzle/MuzzleExtension.kt +++ b/gradle-plugins/src/main/kotlin/io/opentelemetry/javaagent/muzzle/MuzzleExtension.kt @@ -10,21 +10,24 @@ import org.gradle.api.model.ObjectFactory import org.gradle.api.provider.ListProperty import javax.inject.Inject -abstract class MuzzleExtension @Inject constructor(private val objectFactory: ObjectFactory) { +abstract class MuzzleExtension + @Inject + constructor( + private val objectFactory: ObjectFactory + ) { + internal abstract val directives: ListProperty - internal abstract val directives: ListProperty + fun pass(action: Action) { + val pass = objectFactory.newInstance(MuzzleDirective::class.java) + action.execute(pass) + pass.assertPass.set(true) + directives.add(pass) + } - fun pass(action: Action) { - val pass = objectFactory.newInstance(MuzzleDirective::class.java) - action.execute(pass) - pass.assertPass.set(true) - directives.add(pass) + fun fail(action: Action) { + val fail = objectFactory.newInstance(MuzzleDirective::class.java) + action.execute(fail) + fail.assertPass.set(false) + directives.add(fail) + } } - - fun fail(action: Action) { - val fail = objectFactory.newInstance(MuzzleDirective::class.java) - action.execute(fail) - fail.assertPass.set(false) - directives.add(fail) - } -} diff --git a/gradle-plugins/src/main/kotlin/io/opentelemetry/javaagent/muzzle/matcher/MuzzleGradlePluginUtil.kt b/gradle-plugins/src/main/kotlin/io/opentelemetry/javaagent/muzzle/matcher/MuzzleGradlePluginUtil.kt index f7c3b8039227..fcf530fa1bc4 100644 --- a/gradle-plugins/src/main/kotlin/io/opentelemetry/javaagent/muzzle/matcher/MuzzleGradlePluginUtil.kt +++ b/gradle-plugins/src/main/kotlin/io/opentelemetry/javaagent/muzzle/matcher/MuzzleGradlePluginUtil.kt @@ -5,6 +5,9 @@ package io.opentelemetry.javaagent.muzzle.matcher +// TODO the next line is not true anymore. Switch from System.err to Gradle logger. +// Runs in special class loader so tedious to provide access to the Gradle logger. + /** * Entry point for the muzzle gradle plugin. * @@ -24,11 +27,7 @@ package io.opentelemetry.javaagent.muzzle.matcher * library that we want to muzzle-check: "does this version provide all the expected hooks and * classes and methods that our instrumentations expect". */ - -// TODO the next line is not true anymore. Switch from System.err to Gradle logger. -// Runs in special class loader so tedious to provide access to the Gradle logger. class MuzzleGradlePluginUtil { - companion object { /** * Verifies that all instrumentations present in the {@code agentClassLoader} can be safely @@ -52,17 +51,21 @@ class MuzzleGradlePluginUtil { * version passes different {@code userClassLoader}. */ @Suppress("UNCHECKED_CAST") - fun assertInstrumentationMuzzled(agentClassLoader: ClassLoader, userClassLoader: ClassLoader, - excludedInstrumentationNames: Set, assertPass: Boolean) { - + fun assertInstrumentationMuzzled( + agentClassLoader: ClassLoader, + userClassLoader: ClassLoader, + excludedInstrumentationNames: Set, + assertPass: Boolean + ) { val matcherClass = agentClassLoader.loadClass("io.opentelemetry.javaagent.tooling.muzzle.ClassLoaderMatcher") // We cannot reference Mismatch class directly here, because we are loaded from a different // class loader. - val allMismatches = matcherClass - .getMethod("matchesAll", ClassLoader::class.java, Boolean::class.javaPrimitiveType, Set::class.java) - .invoke(null, userClassLoader, assertPass, excludedInstrumentationNames) - as Map> + val allMismatches = + matcherClass + .getMethod("matchesAll", ClassLoader::class.java, Boolean::class.javaPrimitiveType, Set::class.java) + .invoke(null, userClassLoader, assertPass, excludedInstrumentationNames) + as Map> allMismatches.forEach { moduleName, mismatches -> val passed = mismatches.isEmpty() @@ -93,8 +96,8 @@ class MuzzleGradlePluginUtil { *

Called by the {@code printMuzzleReferences} gradle task. */ fun printMuzzleReferences(instrumentationClassLoader: ClassLoader) { - val matcherClass = instrumentationClassLoader.loadClass( - "io.opentelemetry.javaagent.tooling.muzzle.ReferencesPrinter") + val matcherClass = + instrumentationClassLoader.loadClass("io.opentelemetry.javaagent.tooling.muzzle.ReferencesPrinter") matcherClass.getMethod("printMuzzleReferences").invoke(null) } } diff --git a/instrumentation-api-incubator/build.gradle.kts b/instrumentation-api-incubator/build.gradle.kts index 2a0d8dc8bd50..c68a2d580967 100644 --- a/instrumentation-api-incubator/build.gradle.kts +++ b/instrumentation-api-incubator/build.gradle.kts @@ -42,10 +42,11 @@ val generateJflex by tasks.registering(JavaExec::class) { doFirst { val outputDir = outputDirProvider.get().asFile outputDir.mkdirs() - val specFiles = listOf( - sourceDir.asFile.resolve("SqlSanitizer.jflex"), - sourceDir.asFile.resolve("SqlSanitizerWithSummary.jflex"), - ) + val specFiles = + listOf( + sourceDir.asFile.resolve("SqlSanitizer.jflex"), + sourceDir.asFile.resolve("SqlSanitizerWithSummary.jflex"), + ) args( listOf("-d", outputDir.absolutePath, "--nobak") + specFiles.map { it.absolutePath }, ) @@ -89,14 +90,20 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database,code,service.peer,rpc") inputs.dir(jflexOutputDir) } val testBothSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database/dup,code/dup,service.peer/dup,rpc/dup") inputs.dir(jflexOutputDir) diff --git a/instrumentation-api-incubator/javaagent-testing/build.gradle.kts b/instrumentation-api-incubator/javaagent-testing/build.gradle.kts index f5530dbc5e17..0d9c90408a13 100644 --- a/instrumentation-api-incubator/javaagent-testing/build.gradle.kts +++ b/instrumentation-api-incubator/javaagent-testing/build.gradle.kts @@ -11,7 +11,7 @@ dependencies { tasks { test { jvmArgs( - "-Dotel.config.file=$projectDir/src/test/resources/declarative-config.yaml" + "-Dotel.config.file=$projectDir/src/test/resources/declarative-config.yaml", ) } } diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/config/internal/CommonConfig.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/config/internal/CommonConfig.java index d52314aa9dcb..3f1fd1b7d455 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/config/internal/CommonConfig.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/config/internal/CommonConfig.java @@ -81,8 +81,9 @@ public CommonConfig(OpenTelemetry openTelemetry) { commonConfig.get("http").get("client").getBoolean("redact_query_parameters/development"); if (oldRedact != null) { logger.warning( - "otel.instrumentation.http.client.experimental.redact-query-parameters is deprecated. " - + "Use otel.instrumentation.sanitization.url.experimental.sensitive-query-parameters instead."); + "otel.instrumentation.http.client.experimental.redact-query-parameters is deprecated. Use" + + " otel.instrumentation.sanitization.url.experimental.sensitive-query-parameters" + + " instead."); } List newConfigValue = generalConfig diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbConnectionPoolMetrics.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbConnectionPoolMetrics.java index 6eb1274648dd..4803b327e818 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbConnectionPoolMetrics.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbConnectionPoolMetrics.java @@ -65,7 +65,8 @@ public ObservableLongMeasurement connections() { .upDownCounterBuilder(metricName) .setUnit(emitStableDatabaseSemconv() ? "{connection}" : "{connections}") .setDescription( - "The number of connections that are currently in state described by the state attribute.") + "The number of connections that are currently in state described by the state" + + " attribute.") .buildObserver(); } @@ -114,7 +115,8 @@ public ObservableLongMeasurement pendingRequestsForConnection() { .setDescription( emitStableDatabaseSemconv() ? "The number of current pending requests for an open connection." - : "The number of pending requests for an open connection, cumulative for the entire pool.") + : "The number of pending requests for an open connection, cumulative for the entire" + + " pool.") .buildObserver(); } @@ -134,7 +136,8 @@ public LongCounter connectionTimeouts() { .counterBuilder(metricName) .setUnit(emitStableDatabaseSemconv() ? "{timeout}" : "{timeouts}") .setDescription( - "The number of connection timeouts that have occurred trying to obtain a connection from the pool.") + "The number of connection timeouts that have occurred trying to obtain a connection" + + " from the pool.") .build(); } diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/service/peer/internal/ServicePeerResolver.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/service/peer/internal/ServicePeerResolver.java index e0023befa2cf..4f5b6af37af6 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/service/peer/internal/ServicePeerResolver.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/service/peer/internal/ServicePeerResolver.java @@ -65,7 +65,8 @@ public ServicePeerResolver(OpenTelemetry openTelemetry) { if (serviceName == null && serviceNamespace == null) { logger.log( WARNING, - "Invalid service_peer_mapping entry - at least one of service_name or service_namespace is required: {0}", + "Invalid service_peer_mapping entry - at least one of service_name or" + + " service_namespace is required: {0}", entry); return; } diff --git a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlQueryAnalyzerTest.java b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlQueryAnalyzerTest.java index a73b04678aea..a2970de24b1b 100644 --- a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlQueryAnalyzerTest.java +++ b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlQueryAnalyzerTest.java @@ -252,7 +252,10 @@ void querySummaryIsTruncated() { assertThat(result).isNotNull(); assertThat(result) .isEqualTo( - "SELECT very_long_table_name_0 very_long_table_name_1 very_long_table_name_2 very_long_table_name_3 very_long_table_name_4 very_long_table_name_5 very_long_table_name_6 very_long_table_name_7 very_long_table_name_8 very_long_table_name_9"); + "SELECT very_long_table_name_0 very_long_table_name_1 very_long_table_name_2" + + " very_long_table_name_3 very_long_table_name_4 very_long_table_name_5" + + " very_long_table_name_6 very_long_table_name_7 very_long_table_name_8" + + " very_long_table_name_9"); assertThat(result.length()).isEqualTo(236); } @@ -468,14 +471,16 @@ private static Stream simplifyArgs() { "select col from table1 union select col from table2", expect("SELECT", null, "SELECT table1 SELECT table2")), Arguments.of( - "SELECT id, name FROM employees UNION ALL SELECT id, name FROM contractors UNION SELECT id, name FROM vendors", + "SELECT id, name FROM employees UNION ALL SELECT id, name FROM contractors UNION SELECT" + + " id, name FROM vendors", expect("SELECT", null, "SELECT employees SELECT contractors SELECT vendors")), // Parenthesized table with UNION - identifier cancels pending subquery push Arguments.of( "SELECT * FROM (t UNION SELECT * FROM t2), t3", expect("SELECT", null, "SELECT t SELECT t2")), Arguments.of( - "select id, (select max(foo) from (select foo from foos union all select foo from bars)) as foo from main_table", + "select id, (select max(foo) from (select foo from foos union all select foo from" + + " bars)) as foo from main_table", expect("SELECT", null, "SELECT SELECT SELECT foos SELECT bars main_table")), Arguments.of( "select col from table where col in (select * from anotherTable)", @@ -861,11 +866,13 @@ private static Stream simplifyArgs() { "SELECT")), // Multiple CTEs - CTE references filtered in main query Arguments.of( - "WITH a AS (SELECT * FROM t1), b AS (SELECT * FROM t2) SELECT * FROM a JOIN b ON a.id = b.id", + "WITH a AS (SELECT * FROM t1), b AS (SELECT * FROM t2) SELECT * FROM a JOIN b ON a.id =" + + " b.id", expect("SELECT", null, "SELECT t1 SELECT t2 SELECT")), // Recursive CTE - self-reference filtered in CTE body and main query Arguments.of( - "WITH RECURSIVE cte AS (SELECT id FROM t WHERE parent IS NULL UNION ALL SELECT t.id FROM t JOIN cte ON t.parent = cte.id) SELECT * FROM cte", + "WITH RECURSIVE cte AS (SELECT id FROM t WHERE parent IS NULL UNION ALL SELECT t.id" + + " FROM t JOIN cte ON t.parent = cte.id) SELECT * FROM cte", expect("SELECT", null, "SELECT t SELECT t SELECT"))); } @@ -897,9 +904,11 @@ private static Stream ddlArgs() { "ALTER TABLE t2 DROP COLUMN c, DROP COLUMN d", expect("ALTER TABLE", "t2", "ALTER TABLE t2")), Arguments.of( - "ALTER TABLE users ADD COLUMN email VARCHAR(255), DROP COLUMN legacy_id, MODIFY COLUMN status INT", + "ALTER TABLE users ADD COLUMN email VARCHAR(255), DROP COLUMN legacy_id, MODIFY COLUMN" + + " status INT", expect( - "ALTER TABLE users ADD COLUMN email VARCHAR(?), DROP COLUMN legacy_id, MODIFY COLUMN status INT", + "ALTER TABLE users ADD COLUMN email VARCHAR(?), DROP COLUMN legacy_id, MODIFY" + + " COLUMN status INT", "ALTER TABLE", "users", "ALTER TABLE users"))); diff --git a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/internal/SqlCommenterUtilTest.java b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/internal/SqlCommenterUtilTest.java index 101c385f9fd9..3e63deab22b3 100644 --- a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/internal/SqlCommenterUtilTest.java +++ b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/internal/SqlCommenterUtilTest.java @@ -59,7 +59,8 @@ void sqlCommenter( try (Scope ignore = parent.makeCurrent()) { String fragment = hasTraceState - ? "/*traceparent='00-ff01020304050600ff0a0b0c0d0e0f00-090a0b0c0d0e0f00-01', tracestate='test%3Dtest%27'*/" + ? "/*traceparent='00-ff01020304050600ff0a0b0c0d0e0f00-090a0b0c0d0e0f00-01'," + + " tracestate='test%3Dtest%27'*/" : "/*traceparent='00-ff01020304050600ff0a0b0c0d0e0f00-090a0b0c0d0e0f00-01'*/"; assertThat(SqlCommenterUtil.processQuery("SELECT 1", propagator, prepend)) .isEqualTo(prepend ? fragment + " SELECT 1" : "SELECT 1 " + fragment); diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterBuilder.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterBuilder.java index 6b6a2914bf83..d80e05fe0e88 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterBuilder.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterBuilder.java @@ -364,7 +364,8 @@ private String getSchemaUrl() { default: logger.log( WARNING, - "Multiple schemaUrls were detected: {0}. The built Instrumenter will have no schemaUrl assigned.", + "Multiple schemaUrls were detected: {0}. The built Instrumenter will have no schemaUrl" + + " assigned.", computedSchemaUrls); return null; } diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/EmbeddedInstrumentationProperties.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/EmbeddedInstrumentationProperties.java index 70002f426220..b06fb3c96400 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/EmbeddedInstrumentationProperties.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/EmbeddedInstrumentationProperties.java @@ -40,7 +40,8 @@ public final class EmbeddedInstrumentationProperties { public static void setPropertiesLoader(ClassLoader propertiesLoader) { if (loader != DEFAULT_LOADER) { logger.warning( - "Embedded properties loader has already been set up, further setPropertiesLoader() calls are ignored"); + "Embedded properties loader has already been set up, further setPropertiesLoader() calls" + + " are ignored"); return; } loader = propertiesLoader; diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/http/HttpClientAttributesExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/http/HttpClientAttributesExtractorTest.java index 31b563c82508..a098b02f2c8b 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/http/HttpClientAttributesExtractorTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/http/HttpClientAttributesExtractorTest.java @@ -206,26 +206,40 @@ void normal() { "https://user1:secret@github.com/path/, https://REDACTED:REDACTED@github.com/path/", "https://user1:secret@github.com#test.html, https://REDACTED:REDACTED@github.com#test.html", "https://user1:secret@github.com?foo=b@r, https://REDACTED:REDACTED@github.com?foo=b@r", - "https://user1:secret@github.com/p@th?foo=b@r, https://REDACTED:REDACTED@github.com/p@th?foo=b@r", + "https://user1:secret@github.com/p@th?foo=b@r," + + " https://REDACTED:REDACTED@github.com/p@th?foo=b@r", "https://github.com/p@th?foo=b@r, https://github.com/p@th?foo=b@r", "https://github.com#t@st.html, https://github.com#t@st.html", "user1:secret@github.com, user1:secret@github.com", "https://github.com@, https://github.com@", "https://service.com?paramA=valA¶mB=valB, https://service.com?paramA=valA¶mB=valB", "https://service.com?AWSAccessKeyId=AKIAIOSFODNN7, https://service.com?AWSAccessKeyId=REDACTED", - "https://service.com?Signature=39Up9jzHkxhuIhFE9594DJxe7w6cIRCg0V6ICGS0%3A377, https://service.com?Signature=REDACTED", - "https://service.com?sig=39Up9jzHkxhuIhFE9594DJxe7w6cIRCg0V6ICGS0, https://service.com?sig=REDACTED", - "https://service.com?X-Goog-Signature=39Up9jzHkxhuIhFE9594DJxe7w6cIRCg0V6ICGS0, https://service.com?X-Goog-Signature=REDACTED", - "https://service.com?paramA=valA&AWSAccessKeyId=AKIAIOSFODNN7¶mB=valB, https://service.com?paramA=valA&AWSAccessKeyId=REDACTED¶mB=valB", - "https://service.com?AWSAccessKeyId=AKIAIOSFODNN7¶mA=valA, https://service.com?AWSAccessKeyId=REDACTED¶mA=valA", - "https://service.com?paramA=valA&AWSAccessKeyId=AKIAIOSFODNN7, https://service.com?paramA=valA&AWSAccessKeyId=REDACTED", - "https://service.com?AWSAccessKeyId=AKIAIOSFODNN7&AWSAccessKeyId=ZGIAIOSFODNN7, https://service.com?AWSAccessKeyId=REDACTED&AWSAccessKeyId=REDACTED", - "https://service.com?AWSAccessKeyId=AKIAIOSFODNN7#ref, https://service.com?AWSAccessKeyId=REDACTED#ref", - "https://service.com?AWSAccessKeyId=AKIAIOSFODNN7&aa&bb, https://service.com?AWSAccessKeyId=REDACTED&aa&bb", - "https://service.com?aa&bb&AWSAccessKeyId=AKIAIOSFODNN7, https://service.com?aa&bb&AWSAccessKeyId=REDACTED", - "https://service.com?AWSAccessKeyId=AKIAIOSFODNN7&&, https://service.com?AWSAccessKeyId=REDACTED&&", - "https://service.com?&&AWSAccessKeyId=AKIAIOSFODNN7, https://service.com?&&AWSAccessKeyId=REDACTED", - "https://service.com?AWSAccessKeyId=AKIAIOSFODNN7&a&b#fragment, https://service.com?AWSAccessKeyId=REDACTED&a&b#fragment" + "https://service.com?Signature=39Up9jzHkxhuIhFE9594DJxe7w6cIRCg0V6ICGS0%3A377," + + " https://service.com?Signature=REDACTED", + "https://service.com?sig=39Up9jzHkxhuIhFE9594DJxe7w6cIRCg0V6ICGS0," + + " https://service.com?sig=REDACTED", + "https://service.com?X-Goog-Signature=39Up9jzHkxhuIhFE9594DJxe7w6cIRCg0V6ICGS0," + + " https://service.com?X-Goog-Signature=REDACTED", + "https://service.com?paramA=valA&AWSAccessKeyId=AKIAIOSFODNN7¶mB=valB," + + " https://service.com?paramA=valA&AWSAccessKeyId=REDACTED¶mB=valB", + "https://service.com?AWSAccessKeyId=AKIAIOSFODNN7¶mA=valA," + + " https://service.com?AWSAccessKeyId=REDACTED¶mA=valA", + "https://service.com?paramA=valA&AWSAccessKeyId=AKIAIOSFODNN7," + + " https://service.com?paramA=valA&AWSAccessKeyId=REDACTED", + "https://service.com?AWSAccessKeyId=AKIAIOSFODNN7&AWSAccessKeyId=ZGIAIOSFODNN7," + + " https://service.com?AWSAccessKeyId=REDACTED&AWSAccessKeyId=REDACTED", + "https://service.com?AWSAccessKeyId=AKIAIOSFODNN7#ref," + + " https://service.com?AWSAccessKeyId=REDACTED#ref", + "https://service.com?AWSAccessKeyId=AKIAIOSFODNN7&aa&bb," + + " https://service.com?AWSAccessKeyId=REDACTED&aa&bb", + "https://service.com?aa&bb&AWSAccessKeyId=AKIAIOSFODNN7," + + " https://service.com?aa&bb&AWSAccessKeyId=REDACTED", + "https://service.com?AWSAccessKeyId=AKIAIOSFODNN7&&," + + " https://service.com?AWSAccessKeyId=REDACTED&&", + "https://service.com?&&AWSAccessKeyId=AKIAIOSFODNN7," + + " https://service.com?&&AWSAccessKeyId=REDACTED", + "https://service.com?AWSAccessKeyId=AKIAIOSFODNN7&a&b#fragment," + + " https://service.com?AWSAccessKeyId=REDACTED&a&b#fragment" }) void shouldRedactUserInfoAndQueryParameters(String url, String expectedResult) { Map request = new HashMap<>(); diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/http/HttpServerAttributesExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/http/HttpServerAttributesExtractorTest.java index 43277f55caf1..6efd76c6a0f0 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/http/HttpServerAttributesExtractorTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/http/HttpServerAttributesExtractorTest.java @@ -558,10 +558,12 @@ void shouldExtractProtocolNameDifferentFromHttp() { "Signature=39Up9jzHkxhuIhFE9594DJxe7w6cIRCg0V6ICGS0%3A377, Signature=REDACTED", "sig=39Up9jzHkxhuIhFE9594DJxe7w6cIRCg0V6ICGS0, sig=REDACTED", "X-Goog-Signature=39Up9jzHkxhuIhFE9594DJxe7w6cIRCg0V6ICGS0, X-Goog-Signature=REDACTED", - "paramA=valA&AWSAccessKeyId=AKIAIOSFODNN7¶mB=valB, paramA=valA&AWSAccessKeyId=REDACTED¶mB=valB", + "paramA=valA&AWSAccessKeyId=AKIAIOSFODNN7¶mB=valB," + + " paramA=valA&AWSAccessKeyId=REDACTED¶mB=valB", "AWSAccessKeyId=AKIAIOSFODNN7¶mA=valA, AWSAccessKeyId=REDACTED¶mA=valA", "paramA=valA&AWSAccessKeyId=AKIAIOSFODNN7, paramA=valA&AWSAccessKeyId=REDACTED", - "AWSAccessKeyId=AKIAIOSFODNN7&AWSAccessKeyId=ZGIAIOSFODNN7, AWSAccessKeyId=REDACTED&AWSAccessKeyId=REDACTED", + "AWSAccessKeyId=AKIAIOSFODNN7&AWSAccessKeyId=ZGIAIOSFODNN7," + + " AWSAccessKeyId=REDACTED&AWSAccessKeyId=REDACTED", "AWSAccessKeyId=AKIAIOSFODNN7#ref, AWSAccessKeyId=REDACTED#ref", "AWSAccessKeyId=AKIAIOSFODNN7&aa&bb, AWSAccessKeyId=REDACTED&aa&bb", "aa&bb&AWSAccessKeyId=AKIAIOSFODNN7, aa&bb&AWSAccessKeyId=REDACTED", diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/url/internal/UrlQuerySanitizerTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/url/internal/UrlQuerySanitizerTest.java index 1107515990a4..8736de66e0a2 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/url/internal/UrlQuerySanitizerTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/url/internal/UrlQuerySanitizerTest.java @@ -93,7 +93,8 @@ void redactUrl_shouldReturnOriginalWhenNoSensitiveParamsPresent() { // Basic URL structure - scheme and host preservation "https://example.com?secret=val, https://example.com?secret=REDACTED", // With path - path preservation - "https://example.com/path/to/resource?secret=val, https://example.com/path/to/resource?secret=REDACTED", + "https://example.com/path/to/resource?secret=val," + + " https://example.com/path/to/resource?secret=REDACTED", // With port - port preservation "https://example.com:8080?apiKey=val, https://example.com:8080?apiKey=REDACTED", // Integration - verify redactInternal delegation works (fragment, multiple params) diff --git a/instrumentation-docs/src/main/java/io/opentelemetry/instrumentation/docs/DocGeneratorApplication.java b/instrumentation-docs/src/main/java/io/opentelemetry/instrumentation/docs/DocGeneratorApplication.java index e4d63edd68e7..3d0dad6f5ed6 100644 --- a/instrumentation-docs/src/main/java/io/opentelemetry/instrumentation/docs/DocGeneratorApplication.java +++ b/instrumentation-docs/src/main/java/io/opentelemetry/instrumentation/docs/DocGeneratorApplication.java @@ -44,7 +44,8 @@ public static void main(String[] args) throws IOException { writer.write("# This file is generated and should not be manually edited.\n"); writer.write("# The structure and contents are a work in progress and subject to change.\n"); writer.write( - "# For more information see: https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/13468\n\n"); + "# For more information see:" + + " https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/13468\n\n"); writer.write("file_format: 0.5\n\n"); YamlHelper.generateInstrumentationYaml(modules, writer); } diff --git a/instrumentation-docs/src/main/java/io/opentelemetry/instrumentation/docs/DocSynchronization.java b/instrumentation-docs/src/main/java/io/opentelemetry/instrumentation/docs/DocSynchronization.java index af9867b1aed8..ddb6a28aefc7 100644 --- a/instrumentation-docs/src/main/java/io/opentelemetry/instrumentation/docs/DocSynchronization.java +++ b/instrumentation-docs/src/main/java/io/opentelemetry/instrumentation/docs/DocSynchronization.java @@ -67,7 +67,8 @@ public static void main(String[] args) { finalMessage.append(combinedMessage.toString()); finalMessage.append("\n\n## How to Fix\n\n"); finalMessage.append( - "For guidance on updating the OpenTelemetry.io documentation, see: [Documenting Instrumentation](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/docs/contributing/documenting-instrumentation.md#opentelemetryio)"); + "For guidance on updating the OpenTelemetry.io documentation, see: [Documenting" + + " Instrumentation](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/docs/contributing/documenting-instrumentation.md#opentelemetryio)"); finalMessage.append("\n=== AUDIT_FAILURE_END ==="); logger.severe(finalMessage.toString()); diff --git a/instrumentation-docs/src/main/java/io/opentelemetry/instrumentation/docs/internal/TelemetryMerger.java b/instrumentation-docs/src/main/java/io/opentelemetry/instrumentation/docs/internal/TelemetryMerger.java index 9abbccc7229c..84f8f298e5c9 100644 --- a/instrumentation-docs/src/main/java/io/opentelemetry/instrumentation/docs/internal/TelemetryMerger.java +++ b/instrumentation-docs/src/main/java/io/opentelemetry/instrumentation/docs/internal/TelemetryMerger.java @@ -130,7 +130,8 @@ private static void mergeMetricsList( if (existingNames.contains(metric.getName())) { logger.warning( String.format( - "Manual metric '%s' in 'when: %s' conflicts with emitted metric in %s. Using manual definition.", + "Manual metric '%s' in 'when: %s' conflicts with emitted metric in %s. Using manual" + + " definition.", metric.getName(), when, instrumentationName)); // Remove the existing metric and add the manual one existing.removeIf(m -> m.getName().equals(metric.getName())); @@ -156,7 +157,8 @@ private static void mergeSpansList( if (existingKinds.contains(span.getSpanKind())) { logger.warning( String.format( - "Manual span kind '%s' in 'when: %s' conflicts with emitted span in %s. Using manual definition.", + "Manual span kind '%s' in 'when: %s' conflicts with emitted span in %s. Using" + + " manual definition.", span.getSpanKind(), when, instrumentationName)); // Remove the existing span and add the manual one existing.removeIf(s -> s.getSpanKind().equals(span.getSpanKind())); diff --git a/instrumentation-docs/src/test/java/io/opentelemetry/instrumentation/docs/parsers/EmittedMetricsParserTest.java b/instrumentation-docs/src/test/java/io/opentelemetry/instrumentation/docs/parsers/EmittedMetricsParserTest.java index c23dd617d7a6..6383bf5188a9 100644 --- a/instrumentation-docs/src/test/java/io/opentelemetry/instrumentation/docs/parsers/EmittedMetricsParserTest.java +++ b/instrumentation-docs/src/test/java/io/opentelemetry/instrumentation/docs/parsers/EmittedMetricsParserTest.java @@ -68,23 +68,23 @@ void getMetricsFromFilesCombinesFilesCorrectly(@TempDir Path tempDir) throws IOE String file1Content = """ - when: default - metrics_by_scope: - - scope: io.opentelemetry.MetricParserTest - metrics: - - name: metric1 - type: counter - """; + when: default + metrics_by_scope: + - scope: io.opentelemetry.MetricParserTest + metrics: + - name: metric1 + type: counter + """; String file2Content = """ - when: default - metrics_by_scope: - - scope: io.opentelemetry.MetricParserTest - metrics: - - name: metric2 - type: gauge - """; + when: default + metrics_by_scope: + - scope: io.opentelemetry.MetricParserTest + metrics: + - name: metric2 + type: gauge + """; Files.writeString(telemetryDir.resolve("metrics-1.yaml"), file1Content); Files.writeString(telemetryDir.resolve("metrics-2.yaml"), file2Content); diff --git a/instrumentation-docs/src/test/java/io/opentelemetry/instrumentation/docs/parsers/GradleParserTest.java b/instrumentation-docs/src/test/java/io/opentelemetry/instrumentation/docs/parsers/GradleParserTest.java index e9c6eb3a9117..5f67149134b0 100644 --- a/instrumentation-docs/src/test/java/io/opentelemetry/instrumentation/docs/parsers/GradleParserTest.java +++ b/instrumentation-docs/src/test/java/io/opentelemetry/instrumentation/docs/parsers/GradleParserTest.java @@ -17,13 +17,14 @@ class GradleParserTest { void testExtractMuzzleVersions_SinglePassBlock() { String gradleBuildFileContent = """ - muzzle { - pass { - group.set("org.elasticsearch.client") - module.set("rest") - versions.set("[5.0,6.4)") - } - }"""; + muzzle { + pass { + group.set("org.elasticsearch.client") + module.set("rest") + versions.set("[5.0,6.4)") + } + }\ + """; DependencyInfo info = GradleParser.parseGradleFile(gradleBuildFileContent, InstrumentationType.JAVAAGENT); assertThat(info.versions().size()).isEqualTo(1); @@ -35,12 +36,12 @@ void testExtractMuzzleVersions_SinglePassBlock() { void testExtractCoreJdk() { String gradleBuildFileContent = """ - muzzle { - pass { - coreJdk() - } - } - """; + muzzle { + pass { + coreJdk() + } + } + """; DependencyInfo info = GradleParser.parseGradleFile(gradleBuildFileContent, InstrumentationType.JAVAAGENT); @@ -52,16 +53,16 @@ void testExtractCoreJdk() { void testExtractMinimumJavaVersion() { String gradleBuildFileContent = """ - muzzle { - pass { - coreJdk() - } + muzzle { + pass { + coreJdk() } + } - otelJava { - minJavaVersionSupported.set(JavaVersion.VERSION_11) - } - """; + otelJava { + minJavaVersionSupported.set(JavaVersion.VERSION_11) + } + """; DependencyInfo info = GradleParser.parseGradleFile(gradleBuildFileContent, InstrumentationType.JAVAAGENT); @@ -74,18 +75,18 @@ void testExtractMinimumJavaVersion() { void testExtractMinimumJavaVersionIgnoredWithinIfCondition() { String gradleBuildFileContent = """ - muzzle { - pass { - coreJdk() - } + muzzle { + pass { + coreJdk() } + } - if (latestDepTest) { - otelJava { - minJavaVersionSupported.set(JavaVersion.VERSION_11) - } + if (latestDepTest) { + otelJava { + minJavaVersionSupported.set(JavaVersion.VERSION_11) } - """; + } + """; DependencyInfo info = GradleParser.parseGradleFile(gradleBuildFileContent, InstrumentationType.JAVAAGENT); @@ -97,36 +98,36 @@ void testExtractMinimumJavaVersionIgnoredWithinIfCondition() { void testExtractMuzzleVersions_MultiplePassBlocks() { String gradleBuildFileContent = """ - plugins { - id("otel.javaagent-instrumentation") - id("otel.nullaway-conventions") - id("otel.scala-conventions") + plugins { + id("otel.javaagent-instrumentation") + id("otel.nullaway-conventions") + id("otel.scala-conventions") + } + + val zioVersion = "2.0.0" + val scalaVersion = "2.12" + + muzzle { + pass { + group.set("dev.zio") + module.set("zio_2.12") + versions.set("[$zioVersion,)") + assertInverse.set(true) } - - val zioVersion = "2.0.0" - val scalaVersion = "2.12" - - muzzle { - pass { - group.set("dev.zio") - module.set("zio_2.12") - versions.set("[$zioVersion,)") - assertInverse.set(true) - } - pass { - group.set("dev.zio") - module.set("zio_2.13") - versions.set("[$zioVersion,)") - assertInverse.set(true) - } - pass { - group.set("dev.zio") - module.set("zio_3") - versions.set("[$zioVersion,)") - assertInverse.set(true) - } + pass { + group.set("dev.zio") + module.set("zio_2.13") + versions.set("[$zioVersion,)") + assertInverse.set(true) + } + pass { + group.set("dev.zio") + module.set("zio_3") + versions.set("[$zioVersion,)") + assertInverse.set(true) } - """; + } + """; DependencyInfo info = GradleParser.parseGradleFile(gradleBuildFileContent, InstrumentationType.JAVAAGENT); diff --git a/instrumentation-docs/src/test/java/io/opentelemetry/instrumentation/docs/parsers/SpanParserTest.java b/instrumentation-docs/src/test/java/io/opentelemetry/instrumentation/docs/parsers/SpanParserTest.java index 5e67c441b913..f17e17e532a9 100644 --- a/instrumentation-docs/src/test/java/io/opentelemetry/instrumentation/docs/parsers/SpanParserTest.java +++ b/instrumentation-docs/src/test/java/io/opentelemetry/instrumentation/docs/parsers/SpanParserTest.java @@ -30,45 +30,45 @@ void getSpansFromFilesCombinesFilesCorrectly(@TempDir Path tempDir) throws IOExc String file1Content = """ - when: default - spans_by_scope: - - scope: test - spans: - - span_kind: INTERNAL - attributes: - - scope: io.opentelemetry.clickhouse-client-0.5 - spans: - - span_kind: SERVER - attributes: - - name: server.address - type: STRING - """; + when: default + spans_by_scope: + - scope: test + spans: + - span_kind: INTERNAL + attributes: + - scope: io.opentelemetry.clickhouse-client-0.5 + spans: + - span_kind: SERVER + attributes: + - name: server.address + type: STRING + """; String file2Content = """ - when: default - spans_by_scope: - - scope: test - spans: - - span_kind: INTERNAL - attributes: - - scope: io.opentelemetry.clickhouse-client-0.5 - spans: - - span_kind: CLIENT - attributes: - - name: db.statement - type: STRING - - name: server.port - type: LONG - - name: db.system - type: STRING - - name: server.address - type: STRING - - name: db.name - type: STRING - - name: db.operation - type: STRING - """; + when: default + spans_by_scope: + - scope: test + spans: + - span_kind: INTERNAL + attributes: + - scope: io.opentelemetry.clickhouse-client-0.5 + spans: + - span_kind: CLIENT + attributes: + - name: db.statement + type: STRING + - name: server.port + type: LONG + - name: db.system + type: STRING + - name: server.address + type: STRING + - name: db.name + type: STRING + - name: db.operation + type: STRING + """; Files.writeString(telemetryDir.resolve("spans-1.yaml"), file1Content); Files.writeString(telemetryDir.resolve("spans-2.yaml"), file2Content); @@ -202,39 +202,39 @@ void getSpansFromFilesIncludesAllowListedScopes(@TempDir Path tempDir) throws IO String file1Content = """ - when: default - spans_by_scope: - - scope: io.opentelemetry.grpc-1.6 - spans: - - span_kind: CLIENT - attributes: - - name: rpc.system - type: STRING - - name: rpc.grpc.status_code - type: LONG - - name: server.port - type: LONG - - name: rpc.method - type: STRING - - name: rpc.service - type: STRING - - name: server.address - type: STRING - - span_kind: SERVER - attributes: - - name: rpc.system - type: STRING - - name: rpc.grpc.status_code - type: LONG - - name: server.port - type: LONG - - name: rpc.method - type: STRING - - name: rpc.service - type: STRING - - name: server.address - type: STRING - """; + when: default + spans_by_scope: + - scope: io.opentelemetry.grpc-1.6 + spans: + - span_kind: CLIENT + attributes: + - name: rpc.system + type: STRING + - name: rpc.grpc.status_code + type: LONG + - name: server.port + type: LONG + - name: rpc.method + type: STRING + - name: rpc.service + type: STRING + - name: server.address + type: STRING + - span_kind: SERVER + attributes: + - name: rpc.system + type: STRING + - name: rpc.grpc.status_code + type: LONG + - name: server.port + type: LONG + - name: rpc.method + type: STRING + - name: rpc.service + type: STRING + - name: server.address + type: STRING + """; Files.writeString(telemetryDir.resolve("spans-1.yaml"), file1Content); diff --git a/instrumentation-docs/src/test/java/io/opentelemetry/instrumentation/docs/utils/YamlHelperTest.java b/instrumentation-docs/src/test/java/io/opentelemetry/instrumentation/docs/utils/YamlHelperTest.java index b3159a9d42b0..5b633e8919a2 100644 --- a/instrumentation-docs/src/test/java/io/opentelemetry/instrumentation/docs/utils/YamlHelperTest.java +++ b/instrumentation-docs/src/test/java/io/opentelemetry/instrumentation/docs/utils/YamlHelperTest.java @@ -183,34 +183,34 @@ void testGenerateInstrumentationYamlSeparatesClassifications() throws Exception String expectedYaml = """ - libraries: - - name: spring-web-6.0 - description: Spring Web 6.0 instrumentation - semantic_conventions: - - DATABASE_CLIENT_METRICS - - DATABASE_CLIENT_SPANS - features: - - HTTP_ROUTE - - CONTEXT_PROPAGATION - source_path: instrumentation/spring/spring-web/spring-web-6.0 - minimum_java_version: 11 - scope: - name: io.opentelemetry.spring-web-6.0 - javaagent_target_versions: - - org.springframework:spring-web:[6.0.0,) - configurations: - - name: otel.instrumentation.spring-web-6.0.enabled - description: Enables or disables Spring Web 6.0 instrumentation. - type: boolean - default: true - custom: - - name: opentelemetry-external-annotations - source_path: instrumentation/opentelemetry-external-annotations-1.0 - scope: - name: io.opentelemetry.opentelemetry-external-annotations - javaagent_target_versions: - - io.opentelemetry:opentelemetry-extension-annotations:[0.16.0,) - """; + libraries: + - name: spring-web-6.0 + description: Spring Web 6.0 instrumentation + semantic_conventions: + - DATABASE_CLIENT_METRICS + - DATABASE_CLIENT_SPANS + features: + - HTTP_ROUTE + - CONTEXT_PROPAGATION + source_path: instrumentation/spring/spring-web/spring-web-6.0 + minimum_java_version: 11 + scope: + name: io.opentelemetry.spring-web-6.0 + javaagent_target_versions: + - org.springframework:spring-web:[6.0.0,) + configurations: + - name: otel.instrumentation.spring-web-6.0.enabled + description: Enables or disables Spring Web 6.0 instrumentation. + type: boolean + default: true + custom: + - name: opentelemetry-external-annotations + source_path: instrumentation/opentelemetry-external-annotations-1.0 + scope: + name: io.opentelemetry.opentelemetry-external-annotations + javaagent_target_versions: + - io.opentelemetry:opentelemetry-extension-annotations:[0.16.0,) + """; assertThat(expectedYaml).isEqualTo(stringWriter.toString()); } @@ -219,19 +219,19 @@ void testGenerateInstrumentationYamlSeparatesClassifications() throws Exception void testMetadataParser() throws JsonProcessingException { String input = """ - description: test description - classification: internal - disabled_by_default: true - library_link: https://example.com/test-library - features: - - HTTP_ROUTE - - CONTROLLER_SPANS - configurations: - - name: otel.instrumentation.common.db.query-sanitization.enabled - description: Enables query sanitization for database queries. - type: boolean - default: true - """; + description: test description + classification: internal + disabled_by_default: true + library_link: https://example.com/test-library + features: + - HTTP_ROUTE + - CONTROLLER_SPANS + configurations: + - name: otel.instrumentation.common.db.query-sanitization.enabled + description: Enables query sanitization for database queries. + type: boolean + default: true + """; InstrumentationMetadata metadata = YamlHelper.metaDataParser(input); @@ -633,23 +633,23 @@ void testYamlGenerationWithLibraryLink() throws Exception { String expectedYaml = """ - libraries: - - name: other-lib-1.0 - description: Test library instrumentation without link - source_path: instrumentation/other-lib/other-lib-1.0 - scope: - name: io.opentelemetry.other-lib-1.0 - javaagent_target_versions: - - com.example:test-library:[1.0.0,) - - name: test-lib-1.0 - description: Test library instrumentation with link - library_link: https://example.com/test-library-docs - source_path: instrumentation/test-lib/test-lib-1.0 - scope: - name: io.opentelemetry.test-lib-1.0 - javaagent_target_versions: - - com.example:test-library:[1.0.0,) - """; + libraries: + - name: other-lib-1.0 + description: Test library instrumentation without link + source_path: instrumentation/other-lib/other-lib-1.0 + scope: + name: io.opentelemetry.other-lib-1.0 + javaagent_target_versions: + - com.example:test-library:[1.0.0,) + - name: test-lib-1.0 + description: Test library instrumentation with link + library_link: https://example.com/test-library-docs + source_path: instrumentation/test-lib/test-lib-1.0 + scope: + name: io.opentelemetry.test-lib-1.0 + javaagent_target_versions: + - com.example:test-library:[1.0.0,) + """; assertThat(expectedYaml).isEqualTo(stringWriter.toString()); } @@ -751,28 +751,28 @@ void testInstrumentationsSortedBySemanticVersion() throws Exception { String expectedYaml = """ - libraries: - - name: opentelemetry-api-1.9 - source_path: instrumentation/opentelemetry-api/opentelemetry-api-1.9 - scope: - name: io.opentelemetry.opentelemetry-api-1.9 - - name: opentelemetry-api-1.10 - source_path: instrumentation/opentelemetry-api/opentelemetry-api-1.10 - scope: - name: io.opentelemetry.opentelemetry-api-1.10 - - name: opentelemetry-api-1.56 - source_path: instrumentation/opentelemetry-api/opentelemetry-api-1.56 - scope: - name: io.opentelemetry.opentelemetry-api-1.56 - - name: opentelemetry-api-1.57 - source_path: instrumentation/opentelemetry-api/opentelemetry-api-1.57 - scope: - name: io.opentelemetry.opentelemetry-api-1.57 - - name: opentelemetry-api-2.0 - source_path: instrumentation/opentelemetry-api/opentelemetry-api-2.0 - scope: - name: io.opentelemetry.opentelemetry-api-2.0 - """; + libraries: + - name: opentelemetry-api-1.9 + source_path: instrumentation/opentelemetry-api/opentelemetry-api-1.9 + scope: + name: io.opentelemetry.opentelemetry-api-1.9 + - name: opentelemetry-api-1.10 + source_path: instrumentation/opentelemetry-api/opentelemetry-api-1.10 + scope: + name: io.opentelemetry.opentelemetry-api-1.10 + - name: opentelemetry-api-1.56 + source_path: instrumentation/opentelemetry-api/opentelemetry-api-1.56 + scope: + name: io.opentelemetry.opentelemetry-api-1.56 + - name: opentelemetry-api-1.57 + source_path: instrumentation/opentelemetry-api/opentelemetry-api-1.57 + scope: + name: io.opentelemetry.opentelemetry-api-1.57 + - name: opentelemetry-api-2.0 + source_path: instrumentation/opentelemetry-api/opentelemetry-api-2.0 + scope: + name: io.opentelemetry.opentelemetry-api-2.0 + """; assertThat(expectedYaml).isEqualTo(stringWriter.toString()); } diff --git a/instrumentation/akka/akka-http-10.0/javaagent/build.gradle.kts b/instrumentation/akka/akka-http-10.0/javaagent/build.gradle.kts index f82152c3e628..b5e9b5e00a6d 100644 --- a/instrumentation/akka/akka-http-10.0/javaagent/build.gradle.kts +++ b/instrumentation/akka/akka-http-10.0/javaagent/build.gradle.kts @@ -69,7 +69,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/alibaba-druid-1.0/javaagent/build.gradle.kts b/instrumentation/alibaba-druid-1.0/javaagent/build.gradle.kts index cf2db1586094..ae504ea83ca7 100644 --- a/instrumentation/alibaba-druid-1.0/javaagent/build.gradle.kts +++ b/instrumentation/alibaba-druid-1.0/javaagent/build.gradle.kts @@ -24,7 +24,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database") diff --git a/instrumentation/alibaba-druid-1.0/library/build.gradle.kts b/instrumentation/alibaba-druid-1.0/library/build.gradle.kts index bc6ff46a63dd..bf9f3d673a0a 100644 --- a/instrumentation/alibaba-druid-1.0/library/build.gradle.kts +++ b/instrumentation/alibaba-druid-1.0/library/build.gradle.kts @@ -11,7 +11,10 @@ dependencies { tasks { val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") } diff --git a/instrumentation/apache-dbcp-2.0/javaagent/build.gradle.kts b/instrumentation/apache-dbcp-2.0/javaagent/build.gradle.kts index ee2df3ab8a68..a52e2cfbee0e 100644 --- a/instrumentation/apache-dbcp-2.0/javaagent/build.gradle.kts +++ b/instrumentation/apache-dbcp-2.0/javaagent/build.gradle.kts @@ -25,7 +25,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") diff --git a/instrumentation/apache-dbcp-2.0/library/build.gradle.kts b/instrumentation/apache-dbcp-2.0/library/build.gradle.kts index eb7afb1d91c0..efad1aa7466d 100644 --- a/instrumentation/apache-dbcp-2.0/library/build.gradle.kts +++ b/instrumentation/apache-dbcp-2.0/library/build.gradle.kts @@ -11,7 +11,10 @@ dependencies { tasks { val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") diff --git a/instrumentation/apache-dubbo-2.7/javaagent/build.gradle.kts b/instrumentation/apache-dubbo-2.7/javaagent/build.gradle.kts index 4db91aaad2a3..1a8b2cc5a741 100644 --- a/instrumentation/apache-dubbo-2.7/javaagent/build.gradle.kts +++ b/instrumentation/apache-dubbo-2.7/javaagent/build.gradle.kts @@ -48,25 +48,27 @@ tasks.withType().configureEach { systemProperty("collectMetadata", otelProps.collectMetadata) } -val stableSemconvSuites = testing.suites.withType(JvmTestSuite::class).map { suite -> - tasks.register("${suite.name}StableSemconv") { - testClassesDirs = suite.sources.output.classesDirs - classpath = suite.sources.runtimeClasspath +val stableSemconvSuites = + testing.suites.withType(JvmTestSuite::class).map { suite -> + tasks.register("${suite.name}StableSemconv") { + testClassesDirs = suite.sources.output.classesDirs + classpath = suite.sources.runtimeClasspath - jvmArgs("-Dotel.semconv-stability.opt-in=rpc,service.peer") - systemProperty("metadataConfig", "otel.semconv-stability.opt-in=rpc,service.peer") + jvmArgs("-Dotel.semconv-stability.opt-in=rpc,service.peer") + systemProperty("metadataConfig", "otel.semconv-stability.opt-in=rpc,service.peer") + } } -} -val bothSemconvSuites = testing.suites.withType(JvmTestSuite::class).map { suite -> - tasks.register("${suite.name}BothSemconv") { - testClassesDirs = suite.sources.output.classesDirs - classpath = suite.sources.runtimeClasspath +val bothSemconvSuites = + testing.suites.withType(JvmTestSuite::class).map { suite -> + tasks.register("${suite.name}BothSemconv") { + testClassesDirs = suite.sources.output.classesDirs + classpath = suite.sources.runtimeClasspath - jvmArgs("-Dotel.semconv-stability.opt-in=rpc/dup,service.peer") - systemProperty("metadataConfig", "otel.semconv-stability.opt-in=rpc/dup,service.peer") + jvmArgs("-Dotel.semconv-stability.opt-in=rpc/dup,service.peer") + systemProperty("metadataConfig", "otel.semconv-stability.opt-in=rpc/dup,service.peer") + } } -} tasks { check { diff --git a/instrumentation/apache-dubbo-2.7/library-autoconfigure/build.gradle.kts b/instrumentation/apache-dubbo-2.7/library-autoconfigure/build.gradle.kts index 2a6ded639200..a704aa32e348 100644 --- a/instrumentation/apache-dubbo-2.7/library-autoconfigure/build.gradle.kts +++ b/instrumentation/apache-dubbo-2.7/library-autoconfigure/build.gradle.kts @@ -24,7 +24,10 @@ tasks.withType().configureEach { tasks { val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=rpc") @@ -32,7 +35,10 @@ tasks { } val testBothSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=rpc/dup") diff --git a/instrumentation/apache-elasticjob-3.0/javaagent/build.gradle.kts b/instrumentation/apache-elasticjob-3.0/javaagent/build.gradle.kts index 307a6f9f39a4..0fa1a72e0e0d 100644 --- a/instrumentation/apache-elasticjob-3.0/javaagent/build.gradle.kts +++ b/instrumentation/apache-elasticjob-3.0/javaagent/build.gradle.kts @@ -23,11 +23,17 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.apache-elasticjob.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.apache-elasticjob.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.apache-elasticjob.experimental-span-attributes=true", + ) } check { diff --git a/instrumentation/apache-httpasyncclient-4.1/javaagent/build.gradle.kts b/instrumentation/apache-httpasyncclient-4.1/javaagent/build.gradle.kts index ff891b9518db..80e4f28bc45e 100644 --- a/instrumentation/apache-httpasyncclient-4.1/javaagent/build.gradle.kts +++ b/instrumentation/apache-httpasyncclient-4.1/javaagent/build.gradle.kts @@ -23,7 +23,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/apache-httpclient/apache-httpclient-2.0/javaagent/build.gradle.kts b/instrumentation/apache-httpclient/apache-httpclient-2.0/javaagent/build.gradle.kts index 258076cc2f72..6e2da199d5e3 100644 --- a/instrumentation/apache-httpclient/apache-httpclient-2.0/javaagent/build.gradle.kts +++ b/instrumentation/apache-httpclient/apache-httpclient-2.0/javaagent/build.gradle.kts @@ -26,7 +26,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/apache-httpclient/apache-httpclient-4.0/javaagent/build.gradle.kts b/instrumentation/apache-httpclient/apache-httpclient-4.0/javaagent/build.gradle.kts index 4f44a8e09685..91c63be5af52 100644 --- a/instrumentation/apache-httpclient/apache-httpclient-4.0/javaagent/build.gradle.kts +++ b/instrumentation/apache-httpclient/apache-httpclient-4.0/javaagent/build.gradle.kts @@ -37,7 +37,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/apache-httpclient/apache-httpclient-4.3/library/build.gradle.kts b/instrumentation/apache-httpclient/apache-httpclient-4.3/library/build.gradle.kts index 03061009eaa6..b476d7b5e9eb 100644 --- a/instrumentation/apache-httpclient/apache-httpclient-4.3/library/build.gradle.kts +++ b/instrumentation/apache-httpclient/apache-httpclient-4.3/library/build.gradle.kts @@ -18,7 +18,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/build.gradle.kts b/instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/build.gradle.kts index 587cb33243f6..cdb520db6401 100644 --- a/instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/build.gradle.kts +++ b/instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/build.gradle.kts @@ -27,7 +27,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/apache-httpclient/apache-httpclient-5.2/library/build.gradle.kts b/instrumentation/apache-httpclient/apache-httpclient-5.2/library/build.gradle.kts index f49e8a0f575a..0f929ea263c9 100644 --- a/instrumentation/apache-httpclient/apache-httpclient-5.2/library/build.gradle.kts +++ b/instrumentation/apache-httpclient/apache-httpclient-5.2/library/build.gradle.kts @@ -14,7 +14,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/apache-shenyu-2.4/javaagent/build.gradle.kts b/instrumentation/apache-shenyu-2.4/javaagent/build.gradle.kts index 6d70b254fae1..02c4dad8782a 100644 --- a/instrumentation/apache-shenyu-2.4/javaagent/build.gradle.kts +++ b/instrumentation/apache-shenyu-2.4/javaagent/build.gradle.kts @@ -42,7 +42,10 @@ if (otelProps.testLatestDeps) { tasks.withType().configureEach { jvmArgs("-Dotel.instrumentation.apache-shenyu.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.apache-shenyu.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.apache-shenyu.experimental-span-attributes=true", + ) systemProperty("collectMetadata", otelProps.collectMetadata) // required on jdk17 diff --git a/instrumentation/armeria/armeria-1.3/javaagent/build.gradle.kts b/instrumentation/armeria/armeria-1.3/javaagent/build.gradle.kts index 00b1f6656070..00aae92b249b 100644 --- a/instrumentation/armeria/armeria-1.3/javaagent/build.gradle.kts +++ b/instrumentation/armeria/armeria-1.3/javaagent/build.gradle.kts @@ -49,7 +49,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/armeria/armeria-1.3/library/build.gradle.kts b/instrumentation/armeria/armeria-1.3/library/build.gradle.kts index 0816e435b22e..9ace4e67fab8 100644 --- a/instrumentation/armeria/armeria-1.3/library/build.gradle.kts +++ b/instrumentation/armeria/armeria-1.3/library/build.gradle.kts @@ -18,7 +18,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") } diff --git a/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaHttpClientAttributesGetter.java b/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaHttpClientAttributesGetter.java index f192f64a8e53..8a18617b26ee 100644 --- a/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaHttpClientAttributesGetter.java +++ b/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaHttpClientAttributesGetter.java @@ -164,7 +164,8 @@ private static HttpRequest request(ClientRequestContext ctx) { HttpRequest request = ctx.request(); if (request == null) { throw new IllegalStateException( - "Context always has a request in decorators, this exception indicates a programming bug."); + "Context always has a request in decorators, this exception indicates a programming" + + " bug."); } return request; } diff --git a/instrumentation/armeria/armeria-grpc-1.14/javaagent/build.gradle.kts b/instrumentation/armeria/armeria-grpc-1.14/javaagent/build.gradle.kts index 21d823f76cb1..134e684879f9 100644 --- a/instrumentation/armeria/armeria-grpc-1.14/javaagent/build.gradle.kts +++ b/instrumentation/armeria/armeria-grpc-1.14/javaagent/build.gradle.kts @@ -64,14 +64,20 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=rpc") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=rpc") } val testBothSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=rpc/dup") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=rpc/dup") diff --git a/instrumentation/async-http-client/async-http-client-1.8/javaagent/build.gradle.kts b/instrumentation/async-http-client/async-http-client-1.8/javaagent/build.gradle.kts index 19c06189edc8..bd226811b07d 100644 --- a/instrumentation/async-http-client/async-http-client-1.8/javaagent/build.gradle.kts +++ b/instrumentation/async-http-client/async-http-client-1.8/javaagent/build.gradle.kts @@ -12,7 +12,9 @@ muzzle { } dependencies { - implementation(project(":instrumentation:async-http-client:async-http-client-common-1.8:javaagent")) + implementation( + project(":instrumentation:async-http-client:async-http-client-common-1.8:javaagent"), + ) library("com.ning:async-http-client:1.8.0") @@ -38,7 +40,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/async-http-client/async-http-client-1.9/javaagent/build.gradle.kts b/instrumentation/async-http-client/async-http-client-1.9/javaagent/build.gradle.kts index b9fbb9f9ccdd..4530b16771dd 100644 --- a/instrumentation/async-http-client/async-http-client-1.9/javaagent/build.gradle.kts +++ b/instrumentation/async-http-client/async-http-client-1.9/javaagent/build.gradle.kts @@ -12,7 +12,9 @@ muzzle { } dependencies { - implementation(project(":instrumentation:async-http-client:async-http-client-common-1.8:javaagent")) + implementation( + project(":instrumentation:async-http-client:async-http-client-common-1.8:javaagent"), + ) library("com.ning:async-http-client:1.9.0") @@ -36,7 +38,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/async-http-client/async-http-client-2.0/javaagent/build.gradle.kts b/instrumentation/async-http-client/async-http-client-2.0/javaagent/build.gradle.kts index 64835a9abb7a..bc14e1474ec8 100644 --- a/instrumentation/async-http-client/async-http-client-2.0/javaagent/build.gradle.kts +++ b/instrumentation/async-http-client/async-http-client-2.0/javaagent/build.gradle.kts @@ -44,7 +44,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/aws-lambda/aws-lambda-core-1.0/library/src/test/java/io/opentelemetry/instrumentation/awslambdacore/v1_0/internal/HeadersFactoryTest.java b/instrumentation/aws-lambda/aws-lambda-core-1.0/library/src/test/java/io/opentelemetry/instrumentation/awslambdacore/v1_0/internal/HeadersFactoryTest.java index 14731e696dcf..1086fbf32964 100644 --- a/instrumentation/aws-lambda/aws-lambda-core-1.0/library/src/test/java/io/opentelemetry/instrumentation/awslambdacore/v1_0/internal/HeadersFactoryTest.java +++ b/instrumentation/aws-lambda/aws-lambda-core-1.0/library/src/test/java/io/opentelemetry/instrumentation/awslambdacore/v1_0/internal/HeadersFactoryTest.java @@ -20,12 +20,8 @@ class HeadersFactoryTest { void shouldReadHeadersFromStream() { // given String json = - "{" - + "\"headers\" : {" - + "\"X-B3-TraceId\": \"4fd0b6131f19f39af59518d127b0cafe\", \"X-B3-SpanId\": \"0000000000000456\", \"X-B3-Sampled\": \"true\"" - + "}," - + "\"body\" : \"hello\"" - + "}"; + "{\"headers\" : {\"X-B3-TraceId\": \"4fd0b6131f19f39af59518d127b0cafe\", \"X-B3-SpanId\":" + + " \"0000000000000456\", \"X-B3-Sampled\": \"true\"},\"body\" : \"hello\"}"; InputStream inputStream = new ByteArrayInputStream(json.getBytes(Charset.defaultCharset())); // when Map headers = HeadersFactory.ofStream(inputStream); diff --git a/instrumentation/aws-lambda/aws-lambda-events-3.11/library/src/test/java/io/opentelemetry/instrumentation/awslambdaevents/v3_11/TracingRequestWrapperStandardEventsTest.java b/instrumentation/aws-lambda/aws-lambda-events-3.11/library/src/test/java/io/opentelemetry/instrumentation/awslambdaevents/v3_11/TracingRequestWrapperStandardEventsTest.java index d8f7b92d243b..29388939db1e 100644 --- a/instrumentation/aws-lambda/aws-lambda-events-3.11/library/src/test/java/io/opentelemetry/instrumentation/awslambdaevents/v3_11/TracingRequestWrapperStandardEventsTest.java +++ b/instrumentation/aws-lambda/aws-lambda-events-3.11/library/src/test/java/io/opentelemetry/instrumentation/awslambdaevents/v3_11/TracingRequestWrapperStandardEventsTest.java @@ -70,33 +70,41 @@ private static Map, EventInfo> buildEventExamples() { + " \"kinesis\": {\n" + " \"kinesisSchemaVersion\": \"1.0\",\n" + " \"partitionKey\": \"1\",\n" - + " \"sequenceNumber\": \"49590338271490256608559692538361571095921575989136588898\",\n" + + " \"sequenceNumber\":" + + " \"49590338271490256608559692538361571095921575989136588898\",\n" + " \"data\": \"SGVsbG8sIHRoaXMgaXMgYSB0ZXN0Lg==\",\n" + " \"approximateArrivalTimestamp\": 1545084650.987\n" + " },\n" + " \"eventSource\": \"aws:kinesis\",\n" + " \"eventVersion\": \"1.0\",\n" - + " \"eventID\": \"shardId-000000000006:49590338271490256608559692538361571095921575989136588898\",\n" + + " \"eventID\":" + + " \"shardId-000000000006:49590338271490256608559692538361571095921575989136588898\",\n" + " \"eventName\": \"aws:kinesis:record\",\n" - + " \"invokeIdentityArn\": \"arn:aws:iam::123456789012:role/lambda-role\",\n" + + " \"invokeIdentityArn\":" + + " \"arn:aws:iam::123456789012:role/lambda-role\",\n" + " \"awsRegion\": \"us-east-2\",\n" - + " \"eventSourceARN\": \"arn:aws:kinesis:us-east-2:123456789012:stream/lambda-stream\"\n" + + " \"eventSourceARN\":" + + " \"arn:aws:kinesis:us-east-2:123456789012:stream/lambda-stream\"\n" + " },\n" + " {\n" + " \"kinesis\": {\n" + " \"kinesisSchemaVersion\": \"1.0\",\n" + " \"partitionKey\": \"1\",\n" - + " \"sequenceNumber\": \"49590338271490256608559692540925702759324208523137515618\",\n" + + " \"sequenceNumber\":" + + " \"49590338271490256608559692540925702759324208523137515618\",\n" + " \"data\": \"VGhpcyBpcyBvbmx5IGEgdGVzdC4=\",\n" + " \"approximateArrivalTimestamp\": 1545084711.166\n" + " },\n" + " \"eventSource\": \"aws:kinesis\",\n" + " \"eventVersion\": \"1.0\",\n" - + " \"eventID\": \"shardId-000000000006:49590338271490256608559692540925702759324208523137515618\",\n" + + " \"eventID\":" + + " \"shardId-000000000006:49590338271490256608559692540925702759324208523137515618\",\n" + " \"eventName\": \"aws:kinesis:record\",\n" - + " \"invokeIdentityArn\": \"arn:aws:iam::123456789012:role/lambda-role\",\n" + + " \"invokeIdentityArn\":" + + " \"arn:aws:iam::123456789012:role/lambda-role\",\n" + " \"awsRegion\": \"us-east-2\",\n" - + " \"eventSourceARN\": \"arn:aws:kinesis:us-east-2:123456789012:stream/lambda-stream\"\n" + + " \"eventSourceARN\":" + + " \"arn:aws:kinesis:us-east-2:123456789012:stream/lambda-stream\"\n" + " }\n" + " ]\n" + "}")); @@ -119,7 +127,8 @@ private static Map, EventInfo> buildEventExamples() { + " \"messageAttributes\": {},\n" + " \"md5OfBody\": \"e4e68fb7bd0e697a0ae8f1bb342846b3\",\n" + " \"eventSource\": \"aws:sqs\",\n" - + " \"eventSourceARN\": \"arn:aws:sqs:us-east-2:123456789012:my-queue\",\n" + + " \"eventSourceARN\":" + + " \"arn:aws:sqs:us-east-2:123456789012:my-queue\",\n" + " \"awsRegion\": \"us-east-2\"\n" + " },\n" + " {\n" @@ -135,7 +144,8 @@ private static Map, EventInfo> buildEventExamples() { + " \"messageAttributes\": {},\n" + " \"md5OfBody\": \"e4e68fb7bd0e697a0ae8f1bb342846b3\",\n" + " \"eventSource\": \"aws:sqs\",\n" - + " \"eventSourceARN\": \"arn:aws:sqs:us-east-2:123456789012:my-queue\",\n" + + " \"eventSourceARN\":" + + " \"arn:aws:sqs:us-east-2:123456789012:my-queue\",\n" + " \"awsRegion\": \"us-east-2\"\n" + " }\n" + " ]\n" @@ -160,7 +170,8 @@ private static Map, EventInfo> buildEventExamples() { + " },\n" + " \"responseElements\": {\n" + " \"x-amz-request-id\": \"D82B88E5F771F645\",\n" - + " \"x-amz-id-2\": \"vlR7PnpV2Ce81l0PRw6jlUpck7Jo5ZsQjryTjKlc5aLWGVHPZLj5NeC6qMa0emYBDXOo6QBU0Wo=\"\n" + + " \"x-amz-id-2\":" + + " \"vlR7PnpV2Ce81l0PRw6jlUpck7Jo5ZsQjryTjKlc5aLWGVHPZLj5NeC6qMa0emYBDXOo6QBU0Wo=\"\n" + " },\n" + " \"s3\": {\n" + " \"s3SchemaVersion\": \"1.0\",\n" @@ -190,13 +201,16 @@ private static Map, EventInfo> buildEventExamples() { + " \"Records\": [\n" + " {\n" + " \"EventVersion\": \"1.0\",\n" - + " \"EventSubscriptionArn\": \"arn:aws:sns:us-east-2:123456789012:sns-lambda:21be56ed-a058-49f5-8c98-aedd2564c486\",\n" + + " \"EventSubscriptionArn\":" + + " \"arn:aws:sns:us-east-2:123456789012:sns-lambda:21be56ed-a058-49f5-8c98-aedd2564c486\",\n" + " \"EventSource\": \"aws:sns\",\n" + " \"Sns\": {\n" + " \"SignatureVersion\": \"1\",\n" + " \"Timestamp\": \"2019-01-02T12:45:07.000Z\",\n" - + " \"Signature\": \"tcc6faL2yUC6dgZdmrwh1Y4cGa/ebXEkAi6RibDsvpi+tE/1+82j...65r==\",\n" - + " \"SigningCertUrl\": \"https://sns.us-east-2.amazonaws.com/SimpleNotificationService-ac565b8b1a6c5d002d285f9598aa1d9b.pem\",\n" + + " \"Signature\":" + + " \"tcc6faL2yUC6dgZdmrwh1Y4cGa/ebXEkAi6RibDsvpi+tE/1+82j...65r==\",\n" + + " \"SigningCertUrl\":" + + " \"https://sns.us-east-2.amazonaws.com/SimpleNotificationService-ac565b8b1a6c5d002d285f9598aa1d9b.pem\",\n" + " \"MessageId\": \"95df01b4-ee98-5cb9-9903-4c221d41eb5e\",\n" + " \"Message\": \"Hello from SNS!\",\n" + " \"MessageAttributes\": {\n" @@ -210,7 +224,8 @@ private static Map, EventInfo> buildEventExamples() { + " }\n" + " },\n" + " \"Type\": \"Notification\",\n" - + " \"UnsubscribeUrl\": \"https://sns.us-east-2.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-2:123456789012:test-lambda:21be56ed-a058-49f5-8c98-aedd2564c486\",\n" + + " \"UnsubscribeUrl\":" + + " \"https://sns.us-east-2.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-2:123456789012:test-lambda:21be56ed-a058-49f5-8c98-aedd2564c486\",\n" + " \"TopicArn\":\"arn:aws:sns:us-east-2:123456789012:sns-lambda\",\n" + " \"Subject\": \"TestInvoke\"\n" + " }\n" diff --git a/instrumentation/aws-lambda/aws-lambda-events-common-2.2/library/src/test/java/io/opentelemetry/instrumentation/awslambdaevents/common/v2_2/internal/SerializationUtilTest.java b/instrumentation/aws-lambda/aws-lambda-events-common-2.2/library/src/test/java/io/opentelemetry/instrumentation/awslambdaevents/common/v2_2/internal/SerializationUtilTest.java index 1e97b74ec5cb..b3d25107b1d0 100644 --- a/instrumentation/aws-lambda/aws-lambda-events-common-2.2/library/src/test/java/io/opentelemetry/instrumentation/awslambdaevents/common/v2_2/internal/SerializationUtilTest.java +++ b/instrumentation/aws-lambda/aws-lambda-events-common-2.2/library/src/test/java/io/opentelemetry/instrumentation/awslambdaevents/common/v2_2/internal/SerializationUtilTest.java @@ -49,33 +49,39 @@ private static Map, String> buildEventExamples() { + " \"kinesis\": {\n" + " \"kinesisSchemaVersion\": \"1.0\",\n" + " \"partitionKey\": \"1\",\n" - + " \"sequenceNumber\": \"49590338271490256608559692538361571095921575989136588898\",\n" + + " \"sequenceNumber\":" + + " \"49590338271490256608559692538361571095921575989136588898\",\n" + " \"data\": \"SGVsbG8sIHRoaXMgaXMgYSB0ZXN0Lg==\",\n" + " \"approximateArrivalTimestamp\": 1545084650.987\n" + " },\n" + " \"eventSource\": \"aws:kinesis\",\n" + " \"eventVersion\": \"1.0\",\n" - + " \"eventID\": \"shardId-000000000006:49590338271490256608559692538361571095921575989136588898\",\n" + + " \"eventID\":" + + " \"shardId-000000000006:49590338271490256608559692538361571095921575989136588898\",\n" + " \"eventName\": \"aws:kinesis:record\",\n" + " \"invokeIdentityArn\": \"arn:aws:iam::123456789012:role/lambda-role\",\n" + " \"awsRegion\": \"us-east-2\",\n" - + " \"eventSourceARN\": \"arn:aws:kinesis:us-east-2:123456789012:stream/lambda-stream\"\n" + + " \"eventSourceARN\":" + + " \"arn:aws:kinesis:us-east-2:123456789012:stream/lambda-stream\"\n" + " },\n" + " {\n" + " \"kinesis\": {\n" + " \"kinesisSchemaVersion\": \"1.0\",\n" + " \"partitionKey\": \"1\",\n" - + " \"sequenceNumber\": \"49590338271490256608559692540925702759324208523137515618\",\n" + + " \"sequenceNumber\":" + + " \"49590338271490256608559692540925702759324208523137515618\",\n" + " \"data\": \"VGhpcyBpcyBvbmx5IGEgdGVzdC4=\",\n" + " \"approximateArrivalTimestamp\": 1545084711.166\n" + " },\n" + " \"eventSource\": \"aws:kinesis\",\n" + " \"eventVersion\": \"1.0\",\n" - + " \"eventID\": \"shardId-000000000006:49590338271490256608559692540925702759324208523137515618\",\n" + + " \"eventID\":" + + " \"shardId-000000000006:49590338271490256608559692540925702759324208523137515618\",\n" + " \"eventName\": \"aws:kinesis:record\",\n" + " \"invokeIdentityArn\": \"arn:aws:iam::123456789012:role/lambda-role\",\n" + " \"awsRegion\": \"us-east-2\",\n" - + " \"eventSourceARN\": \"arn:aws:kinesis:us-east-2:123456789012:stream/lambda-stream\"\n" + + " \"eventSourceARN\":" + + " \"arn:aws:kinesis:us-east-2:123456789012:stream/lambda-stream\"\n" + " }\n" + " ]\n" + "}"); @@ -135,7 +141,8 @@ private static Map, String> buildEventExamples() { + " },\n" + " \"responseElements\": {\n" + " \"x-amz-request-id\": \"D82B88E5F771F645\",\n" - + " \"x-amz-id-2\": \"vlR7PnpV2Ce81l0PRw6jlUpck7Jo5ZsQjryTjKlc5aLWGVHPZLj5NeC6qMa0emYBDXOo6QBU0Wo=\"\n" + + " \"x-amz-id-2\":" + + " \"vlR7PnpV2Ce81l0PRw6jlUpck7Jo5ZsQjryTjKlc5aLWGVHPZLj5NeC6qMa0emYBDXOo6QBU0Wo=\"\n" + " },\n" + " \"s3\": {\n" + " \"s3SchemaVersion\": \"1.0\",\n" @@ -163,13 +170,16 @@ private static Map, String> buildEventExamples() { + " \"Records\": [\n" + " {\n" + " \"EventVersion\": \"1.0\",\n" - + " \"EventSubscriptionArn\": \"arn:aws:sns:us-east-2:123456789012:sns-lambda:21be56ed-a058-49f5-8c98-aedd2564c486\",\n" + + " \"EventSubscriptionArn\":" + + " \"arn:aws:sns:us-east-2:123456789012:sns-lambda:21be56ed-a058-49f5-8c98-aedd2564c486\",\n" + " \"EventSource\": \"aws:sns\",\n" + " \"Sns\": {\n" + " \"SignatureVersion\": \"1\",\n" + " \"Timestamp\": \"2019-01-02T12:45:07.000Z\",\n" - + " \"Signature\": \"tcc6faL2yUC6dgZdmrwh1Y4cGa/ebXEkAi6RibDsvpi+tE/1+82j...65r==\",\n" - + " \"SigningCertUrl\": \"https://sns.us-east-2.amazonaws.com/SimpleNotificationService-ac565b8b1a6c5d002d285f9598aa1d9b.pem\",\n" + + " \"Signature\":" + + " \"tcc6faL2yUC6dgZdmrwh1Y4cGa/ebXEkAi6RibDsvpi+tE/1+82j...65r==\",\n" + + " \"SigningCertUrl\":" + + " \"https://sns.us-east-2.amazonaws.com/SimpleNotificationService-ac565b8b1a6c5d002d285f9598aa1d9b.pem\",\n" + " \"MessageId\": \"95df01b4-ee98-5cb9-9903-4c221d41eb5e\",\n" + " \"Message\": \"Hello from SNS!\",\n" + " \"MessageAttributes\": {\n" @@ -183,7 +193,8 @@ private static Map, String> buildEventExamples() { + " }\n" + " },\n" + " \"Type\": \"Notification\",\n" - + " \"UnsubscribeUrl\": \"https://sns.us-east-2.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-2:123456789012:test-lambda:21be56ed-a058-49f5-8c98-aedd2564c486\",\n" + + " \"UnsubscribeUrl\":" + + " \"https://sns.us-east-2.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-2:123456789012:test-lambda:21be56ed-a058-49f5-8c98-aedd2564c486\",\n" + " \"TopicArn\":\"arn:aws:sns:us-east-2:123456789012:sns-lambda\",\n" + " \"Subject\": \"TestInvoke\"\n" + " }\n" diff --git a/instrumentation/aws-sdk/aws-sdk-1.11/javaagent/build.gradle.kts b/instrumentation/aws-sdk/aws-sdk-1.11/javaagent/build.gradle.kts index b1b960520ebd..9d83d5f3ce83 100644 --- a/instrumentation/aws-sdk/aws-sdk-1.11/javaagent/build.gradle.kts +++ b/instrumentation/aws-sdk/aws-sdk-1.11/javaagent/build.gradle.kts @@ -153,7 +153,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") diff --git a/instrumentation/aws-sdk/aws-sdk-1.11/library-autoconfigure/build.gradle.kts b/instrumentation/aws-sdk/aws-sdk-1.11/library-autoconfigure/build.gradle.kts index 7f883a46f9a4..21a30a2ee3df 100644 --- a/instrumentation/aws-sdk/aws-sdk-1.11/library-autoconfigure/build.gradle.kts +++ b/instrumentation/aws-sdk/aws-sdk-1.11/library-autoconfigure/build.gradle.kts @@ -26,11 +26,17 @@ dependencies { tasks { withType().configureEach { systemProperty("otel.instrumentation.aws-sdk.experimental-span-attributes", "true") - systemProperty("otel.instrumentation.messaging.experimental.capture-headers", "Test-Message-Header") + systemProperty( + "otel.instrumentation.messaging.experimental.capture-headers", + "Test-Message-Header", + ) } val testReceiveSpansDisabled by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { diff --git a/instrumentation/aws-sdk/aws-sdk-1.11/library/build.gradle.kts b/instrumentation/aws-sdk/aws-sdk-1.11/library/build.gradle.kts index e2fdddb61902..9bf89b47af6c 100644 --- a/instrumentation/aws-sdk/aws-sdk-1.11/library/build.gradle.kts +++ b/instrumentation/aws-sdk/aws-sdk-1.11/library/build.gradle.kts @@ -52,7 +52,10 @@ testing { tasks { val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") } diff --git a/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/PluginImplUtil.java b/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/PluginImplUtil.java index 6f2916db4091..31044767ae25 100644 --- a/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/PluginImplUtil.java +++ b/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/PluginImplUtil.java @@ -49,8 +49,8 @@ static boolean isImplPresent(String implSimpleClassName) { + implFullClassName + " (" + e.getClass().getName() - + "). " - + "Most likely, corresponding SDK component is either not on classpath or incompatible."); + + "). Most likely, corresponding SDK component is either not on classpath or" + + " incompatible."); return false; } } diff --git a/instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractLambdaClientTest.java b/instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractLambdaClientTest.java index c8ee02ae9860..8d91197f23e0 100644 --- a/instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractLambdaClientTest.java +++ b/instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractLambdaClientTest.java @@ -29,89 +29,49 @@ public abstract class AbstractLambdaClientTest extends AbstractBaseAwsClientTest { private static final String LAMBDA_CREATE_EVENT_SOURCE_MAPPING_RESPONSE_BODY = - "{" - + "\"UUID\": \"e31def54-5e5d-4c1b-8e0f-bf1b11c137b7\"," - + "\"BatchSize\": 10," - + "\"MaximumBatchingWindowInSeconds\": 0," - + "\"EventSourceArn\": \"arn:aws:sqs:us-west-2:123456789012:MyTestQueue.fifo\"," - + "\"FunctionArn\": \"arn:aws:lambda:us-west-2:123456789012:function:myFn01-Temp\"," - + "\"LastModified\": \"1.754882043E9\"," - + "\"State\": \"Creating\"," - + "\"StateTransitionReason\": \"USER_INITIATED\"," - + "\"FunctionResponseTypes\": []," - + "\"EventSourceMappingArn\": \"arn:aws:lambda:us-west-2:123456789012:event-source-mapping:e31def54-5e5d-4c1b-8e0f-bf1b11c137b7\"" + "{\"UUID\": \"e31def54-5e5d-4c1b-8e0f-bf1b11c137b7\",\"BatchSize\":" + + " 10,\"MaximumBatchingWindowInSeconds\": 0,\"EventSourceArn\":" + + " \"arn:aws:sqs:us-west-2:123456789012:MyTestQueue.fifo\",\"FunctionArn\":" + + " \"arn:aws:lambda:us-west-2:123456789012:function:myFn01-Temp\",\"LastModified\":" + + " \"1.754882043E9\",\"State\": \"Creating\",\"StateTransitionReason\":" + + " \"USER_INITIATED\",\"FunctionResponseTypes\": [],\"EventSourceMappingArn\":" + + " \"arn:aws:lambda:us-west-2:123456789012:event-source-mapping:e31def54-5e5d-4c1b-8e0f-bf1b11c137b7\"" + "}"; private static final String LAMBDA_GET_EVENT_SOURCE_MAPPING_RESPONSE_BODY = - "{" - + "\"UUID\": \"e31def54-5e5d-4c1b-8e0f-bf1b11c138c8\"," - + "\"BatchSize\": 10," - + "\"MaximumBatchingWindowInSeconds\": 0," - + "\"EventSourceArn\": \"arn:aws:sqs:us-west-2:123456789012:MyTestQueue.fifo\"," - + "\"FunctionArn\": \"arn:aws:lambda:us-west-2:123456789012:function:myFn01-Temp\"," - + "\"LastModified\": \"1.755054843E9\"," - + "\"State\": \"Enabled\"," - + "\"StateTransitionReason\": \"USER_INITIATED\"," - + "\"FunctionResponseTypes\": []," - + "\"EventSourceMappingArn\": \"arn:aws:lambda:us-west-2:123456789012:event-source-mapping:e31def54-5e5d-4c1b-8e0f-bf1b11c138c8\"" + "{\"UUID\": \"e31def54-5e5d-4c1b-8e0f-bf1b11c138c8\",\"BatchSize\":" + + " 10,\"MaximumBatchingWindowInSeconds\": 0,\"EventSourceArn\":" + + " \"arn:aws:sqs:us-west-2:123456789012:MyTestQueue.fifo\",\"FunctionArn\":" + + " \"arn:aws:lambda:us-west-2:123456789012:function:myFn01-Temp\",\"LastModified\":" + + " \"1.755054843E9\",\"State\": \"Enabled\",\"StateTransitionReason\":" + + " \"USER_INITIATED\",\"FunctionResponseTypes\": [],\"EventSourceMappingArn\":" + + " \"arn:aws:lambda:us-west-2:123456789012:event-source-mapping:e31def54-5e5d-4c1b-8e0f-bf1b11c138c8\"" + "}"; private static final String LAMBDA_GET_FUNCTION_RESPONSE_BODY = - "{" - + "\"Configuration\": {" - + " \"FunctionName\": \"lambda-function-name-foo\"," - + " \"FunctionArn\": \"arn:aws:lambda:us-west-2:123456789012:function:lambda-function-name-foo\"," - + " \"Runtime\": \"nodejs22.x\"," - + " \"Role\": \"arn:aws:iam::123456789012:role/service-role/Fn-role-pr7kt0bf\"," - + " \"Handler\": \"index.handler\"," - + " \"CodeSize\": 295," - + " \"Description\": \"\"," - + " \"Timeout\": 3," - + " \"MemorySize\": 128," - + " \"LastModified\": \"1.743573094E9\"," - + " \"CodeSha256\": \"q8E7Nexf5xxhKT9/d4bGpAYOXJYFAUjJ0UDj8OivK8E=\"," - + " \"Version\": \"$LATEST\"," - + " \"Environment\": {" - + " \"Variables\": {" - + " \"AWS_LAMBDA_EXEC_WRAPPER\": \"/opt/otel-instrument\"" - + "}" - + " }," - + " \"TracingConfig\": {" - + " \"Mode\": \"PassThrough\"" - + " }," - + " \"RevisionId\": \"955247dc-c724-4653-8f8b-f702c6f9c389\"," - + " \"Layers\": [" - + " {" - + " \"Arn\": \"arn:aws:lambda:us-west-2:615299751070:layer:AWSOpenTelemetryDistroJs:6\"," - + " \"CodeSize\": 14455992" - + " }" - + " ]," - + " \"State\": \"Active\"," - + " \"LastUpdateStatus\": \"Successful\"," - + " \"PackageType\": \"Zip\"," - + " \"Architectures\": [" - + " \"x86_64\"" - + " ]," - + " \"EphemeralStorage\": {" - + " \"Size\": 512" - + " }," - + " \"SnapStart\": {" - + " \"ApplyOn\": \"None\"," - + " \"OptimizationStatus\": \"Off\"" - + " }," - + " \"RuntimeVersionConfig\": {" - + " \"RuntimeVersionArn\": \"arn:aws:lambda:us-west-2::runtime:fd2e05b324f99edd3c6e17800b2535deb79bcce74b7506d595a94870b3d9bd2e\"" - + " }," - + " \"LoggingConfig\": {" - + " \"LogFormat\": \"Text\"," - + " \"LogGroup\": \"/aws/lambda/mlambda-function-name-foo\"" - + " }" - + " }," - + " \"Code\": {" - + " \"RepositoryType\": \"S3\"," - + " \"Location\": \"https://awslambda-us-west-2-tasks.s3.us-west-2.amazonaws.com/snapshots/123456789012/lambda-function-name-foo-47425b12\"" - + " }" - + "}"; + "{\"Configuration\": { \"FunctionName\": \"lambda-function-name-foo\", \"FunctionArn\":" + + " \"arn:aws:lambda:us-west-2:123456789012:function:lambda-function-name-foo\", " + + " \"Runtime\": \"nodejs22.x\", \"Role\":" + + " \"arn:aws:iam::123456789012:role/service-role/Fn-role-pr7kt0bf\", \"Handler\":" + + " \"index.handler\", \"CodeSize\": 295, \"Description\": \"\", \"Timeout\": 3, " + + " \"MemorySize\": 128, \"LastModified\": \"1.743573094E9\", \"CodeSha256\":" + + " \"q8E7Nexf5xxhKT9/d4bGpAYOXJYFAUjJ0UDj8OivK8E=\", \"Version\": \"$LATEST\", " + + " \"Environment\": { \"Variables\": { \"AWS_LAMBDA_EXEC_WRAPPER\":" + + " \"/opt/otel-instrument\"} }, \"TracingConfig\": { \"Mode\": \"PassThrough\"" + + " }, \"RevisionId\": \"955247dc-c724-4653-8f8b-f702c6f9c389\", \"Layers\": [ " + + " { \"Arn\":" + + " \"arn:aws:lambda:us-west-2:615299751070:layer:AWSOpenTelemetryDistroJs:6\", " + + " \"CodeSize\": 14455992 } ], \"State\": \"Active\", \"LastUpdateStatus\":" + + " \"Successful\", \"PackageType\": \"Zip\", \"Architectures\": [ \"x86_64\" " + + " ], \"EphemeralStorage\": { \"Size\": 512 }, \"SnapStart\": { " + + " \"ApplyOn\": \"None\", \"OptimizationStatus\": \"Off\" }, " + + " \"RuntimeVersionConfig\": { \"RuntimeVersionArn\":" + + " \"arn:aws:lambda:us-west-2::runtime:fd2e05b324f99edd3c6e17800b2535deb79bcce74b7506d595a94870b3d9bd2e\"" + + " }, \"LoggingConfig\": { \"LogFormat\": \"Text\", \"LogGroup\":" + + " \"/aws/lambda/mlambda-function-name-foo\" } }, \"Code\": { \"RepositoryType\":" + + " \"S3\", \"Location\":" + + " \"https://awslambda-us-west-2-tasks.s3.us-west-2.amazonaws.com/snapshots/123456789012/lambda-function-name-foo-47425b12\"" + + " }}"; public abstract AWSLambdaClientBuilder configureClient(AWSLambdaClientBuilder client); diff --git a/instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractS3ClientTest.java b/instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractS3ClientTest.java index c4b6ac2581cc..df9b493d1e31 100644 --- a/instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractS3ClientTest.java +++ b/instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractS3ClientTest.java @@ -166,7 +166,8 @@ void testTimeoutAndRetryErrorsNotCaptured() { .hasNoParent() .hasException( new SdkClientException( - "Unable to execute HTTP request: Request did not complete before the request timeout configuration.")) + "Unable to execute HTTP request: Request did not complete" + + " before the request timeout configuration.")) .hasAttributesSatisfyingExactly( equalTo(URL_FULL, server.httpUri().toString()), equalTo(HTTP_REQUEST_METHOD, "GET"), diff --git a/instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractSecretsManagerClientTest.java b/instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractSecretsManagerClientTest.java index 94c17445f157..525d692e898f 100644 --- a/instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractSecretsManagerClientTest.java +++ b/instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractSecretsManagerClientTest.java @@ -40,11 +40,9 @@ void sendCreateSecretRequestWithMockedResponse() throws Exception { .build(); String body = - "{" - + "\"ARN\": \"arn:aws:secretsmanager:us-west-2:123456789012:secret:MyTestDatabaseSecret-a1b2c3\"," - + "\"Name\": \"MyTestDatabaseSecret\"," - + "\"VersionId\": \"EXAMPLE1-90ab-cdef-fedc-ba987SECRET1\"" - + "}"; + "{\"ARN\":" + + " \"arn:aws:secretsmanager:us-west-2:123456789012:secret:MyTestDatabaseSecret-a1b2c3\",\"Name\":" + + " \"MyTestDatabaseSecret\",\"VersionId\": \"EXAMPLE1-90ab-cdef-fedc-ba987SECRET1\"}"; server.enqueue(HttpResponse.of(HttpStatus.OK, MediaType.PLAIN_TEXT_UTF_8, body)); Object response = @@ -71,11 +69,9 @@ void sendDescribeSecretRequestWithMockedResponse() throws Exception { .build(); String body = - "{" - + "\"ARN\": \"arn:aws:secretsmanager:us-east-1:123456789012:secret:My-Secret-Id-WzAXar\"," - + "\"Name\": \"My-Secret-Id\"," - + "\"VersionId\": \"EXAMPLE1-90ab-cdef-fedc-ba987SECRET1\"" - + "}"; + "{\"ARN\":" + + " \"arn:aws:secretsmanager:us-east-1:123456789012:secret:My-Secret-Id-WzAXar\",\"Name\":" + + " \"My-Secret-Id\",\"VersionId\": \"EXAMPLE1-90ab-cdef-fedc-ba987SECRET1\"}"; server.enqueue(HttpResponse.of(HttpStatus.OK, MediaType.PLAIN_TEXT_UTF_8, body)); Object response = diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/build.gradle.kts b/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/build.gradle.kts index a36748ec8dec..53c0f1206572 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/build.gradle.kts +++ b/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/build.gradle.kts @@ -128,8 +128,14 @@ testing { val s3CrtTest by registering(JvmTestSuite::class) { dependencies { - implementation("software.amazon.awssdk:s3:" + if (otelProps.testLatestDeps) "latest.release" else "2.27.21") - implementation("software.amazon.awssdk.crt:aws-crt:" + if (otelProps.testLatestDeps) "latest.release" else "0.30.11") + implementation( + "software.amazon.awssdk:s3:" + + if (otelProps.testLatestDeps) "latest.release" else "2.27.21", + ) + implementation( + "software.amazon.awssdk.crt:aws-crt:" + + if (otelProps.testLatestDeps) "latest.release" else "0.30.11", + ) implementation(project(":instrumentation:aws-sdk:aws-sdk-2.2:library")) implementation("org.testcontainers:testcontainers-localstack") } @@ -165,7 +171,10 @@ testing { tasks { val testExperimentalSqs by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { @@ -176,7 +185,10 @@ tasks { } val testReceiveSpansDisabled by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { @@ -186,7 +198,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library-autoconfigure/build.gradle.kts b/instrumentation/aws-sdk/aws-sdk-2.2/library-autoconfigure/build.gradle.kts index e668812bac31..19d78a74740f 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library-autoconfigure/build.gradle.kts +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library-autoconfigure/build.gradle.kts @@ -28,12 +28,18 @@ tasks { withType().configureEach { systemProperty("otel.instrumentation.aws-sdk.experimental-span-attributes", true) systemProperty("otel.instrumentation.aws-sdk.experimental-record-individual-http-error", true) - systemProperty("otel.instrumentation.messaging.experimental.capture-headers", "Test-Message-Header") + systemProperty( + "otel.instrumentation.messaging.experimental.capture-headers", + "Test-Message-Header", + ) systemProperty("testLatestDeps", otelProps.testLatestDeps) } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/build.gradle.kts b/instrumentation/aws-sdk/aws-sdk-2.2/library/build.gradle.kts index 2adb77888736..058b2c6d9fe6 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/build.gradle.kts +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/build.gradle.kts @@ -76,7 +76,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/PluginImplUtil.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/PluginImplUtil.java index 8c1c1a80129d..b5792029e93a 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/PluginImplUtil.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/PluginImplUtil.java @@ -51,8 +51,8 @@ static boolean isImplPresent(String implSimpleClassName) { + implFullClassName + " (" + e.getClass().getName() - + "). " - + "Most likely, corresponding SDK component is either not on classpath or incompatible."); + + "). Most likely, corresponding SDK component is either not on classpath or" + + " incompatible."); return false; } } diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractAws2BedrockRuntimeTest.java b/instrumentation/aws-sdk/aws-sdk-2.2/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractAws2BedrockRuntimeTest.java index f42e096e6ce9..5cc76ba7fa59 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractAws2BedrockRuntimeTest.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractAws2BedrockRuntimeTest.java @@ -482,7 +482,11 @@ void testConverseToolCall() { KeyValue.of( "content", Value.of( - " The User has asked for the current weather in two locations: Seattle and San Francisco. To provide the requested information, I will use the \"get_current_weather\" tool for each location separately. \n"))))); + " The User has asked for the current weather in two" + + " locations: Seattle and San Francisco. To provide the" + + " requested information, I will use the" + + " \"get_current_weather\" tool for each location" + + " separately. \n"))))); // Clear to allow asserting telemetry of user request and tool result processing separately. getTesting().clearData(); @@ -630,7 +634,11 @@ void testConverseToolCall() { KeyValue.of( "content", Value.of( - " The User has asked for the current weather in two locations: Seattle and San Francisco. To provide the requested information, I will use the \"get_current_weather\" tool for each location separately. \n")))), + " The User has asked for the current weather in two" + + " locations: Seattle and San Francisco. To provide the" + + " requested information, I will use the" + + " \"get_current_weather\" tool for each location" + + " separately. \n")))), log -> log.hasAttributesSatisfyingExactly( equalTo(GEN_AI_PROVIDER_NAME, AWS_BEDROCK), @@ -663,9 +671,13 @@ void testConverseToolCall() { KeyValue.of( "content", Value.of( - " The tool has provided the current weather for both locations. Now I will compile this information and present it to the User. \n" + " The tool has provided the current weather for both" + + " locations. Now I will compile this information and" + + " present it to the User. \n" + "\n" - + "The current weather in Seattle is 50 degrees and raining. In San Francisco, the weather is 70 degrees and sunny."))))); + + "The current weather in Seattle is 50 degrees and" + + " raining. In San Francisco, the weather is 70 degrees" + + " and sunny."))))); } @Test @@ -863,7 +875,11 @@ void testConverseToolCallStream() throws InterruptedException, ExecutionExceptio KeyValue.of( "content", Value.of( - " The User has asked for the current weather in two locations: Seattle and San Francisco. To provide the requested information, I will use the \"get_current_weather\" tool for each location separately. \n"))))); + " The User has asked for the current weather in two" + + " locations: Seattle and San Francisco. To provide the" + + " requested information, I will use the" + + " \"get_current_weather\" tool for each location" + + " separately. \n"))))); // Clear to allow asserting telemetry of user request and tool result processing separately. getTesting().clearData(); @@ -1030,7 +1046,11 @@ void testConverseToolCallStream() throws InterruptedException, ExecutionExceptio KeyValue.of( "content", Value.of( - " The User has asked for the current weather in two locations: Seattle and San Francisco. To provide the requested information, I will use the \"get_current_weather\" tool for each location separately. \n")))), + " The User has asked for the current weather in two" + + " locations: Seattle and San Francisco. To provide the" + + " requested information, I will use the" + + " \"get_current_weather\" tool for each location" + + " separately. \n")))), log -> log.hasAttributesSatisfyingExactly( equalTo(GEN_AI_PROVIDER_NAME, AWS_BEDROCK), @@ -1063,9 +1083,13 @@ void testConverseToolCallStream() throws InterruptedException, ExecutionExceptio KeyValue.of( "content", Value.of( - " The tool has provided the current weather for both locations. Now I will compile the information and present it to the User. \n" + " The tool has provided the current weather for both" + + " locations. Now I will compile the information and" + + " present it to the User. \n" + "\n" - + "The current weather in Seattle is 50 degrees and it is raining. In San Francisco, the weather is 70 degrees and sunny."))))); + + "The current weather in Seattle is 50 degrees and it is" + + " raining. In San Francisco, the weather is 70 degrees" + + " and sunny."))))); } private static ToolConfiguration currentWeatherToolConfig() { @@ -2644,7 +2668,11 @@ void testInvokeModelToolCallAmazonNova() { KeyValue.of( "content", Value.of( - " To provide the current weather in both Seattle and San Francisco, I will use the \"get_current_weather\" tool twice, once for each city. I will need to specify the \"location\" argument for each call.\n"))))); + " To provide the current weather in both Seattle and" + + " San Francisco, I will use the \"get_current_weather\"" + + " tool twice, once for each city. I will need to specify" + + " the \"location\" argument for each" + + " call.\n"))))); // Clear to allow asserting telemetry of user request and tool result processing separately. getTesting().clearData(); @@ -2821,7 +2849,11 @@ void testInvokeModelToolCallAmazonNova() { KeyValue.of( "content", Value.of( - " To provide the current weather in both Seattle and San Francisco, I will use the \"get_current_weather\" tool twice, once for each city. I will need to specify the \"location\" argument for each call.\n")))), + " To provide the current weather in both Seattle and" + + " San Francisco, I will use the \"get_current_weather\"" + + " tool twice, once for each city. I will need to specify" + + " the \"location\" argument for each" + + " call.\n")))), log -> log.hasAttributesSatisfyingExactly( equalTo(GEN_AI_PROVIDER_NAME, AWS_BEDROCK), @@ -2854,9 +2886,13 @@ void testInvokeModelToolCallAmazonNova() { KeyValue.of( "content", Value.of( - " I have received the weather information for both cities. Now I will compile this information and present it to the user.\n" + " I have received the weather information for both" + + " cities. Now I will compile this information and present" + + " it to the user.\n" + "\n" - + "The current weather in Seattle is 50 degrees and it is raining. The current weather in San Francisco is 70 degrees and it is sunny."))))); + + "The current weather in Seattle is 50 degrees and it is" + + " raining. The current weather in San Francisco is 70" + + " degrees and it is sunny."))))); } @Test @@ -3121,7 +3157,11 @@ public void accept(PayloadPart chunk) { KeyValue.of( "content", Value.of( - " To provide the current weather in Seattle and San Francisco today, I will need to use the \"get_current_weather\" tool twice, once for each city. I will need to specify the location for each call.\n"))))); + " To provide the current weather in Seattle and San" + + " Francisco today, I will need to use the" + + " \"get_current_weather\" tool twice, once for each city." + + " I will need to specify the location for each" + + " call.\n"))))); // Clear to allow asserting telemetry of user request and tool result processing separately. getTesting().clearData(); @@ -3341,7 +3381,11 @@ public void accept(PayloadPart chunk) { KeyValue.of( "content", Value.of( - " To provide the current weather in Seattle and San Francisco today, I will need to use the \"get_current_weather\" tool twice, once for each city. I will need to specify the location for each call.\n")))), + " To provide the current weather in Seattle and San" + + " Francisco today, I will need to use the" + + " \"get_current_weather\" tool twice, once for each city." + + " I will need to specify the location for each" + + " call.\n")))), log -> log.hasAttributesSatisfyingExactly( equalTo(GEN_AI_PROVIDER_NAME, AWS_BEDROCK), @@ -3374,9 +3418,13 @@ public void accept(PayloadPart chunk) { KeyValue.of( "content", Value.of( - " I have received the weather information for both cities. Now I will compile this information into a clear response for the User.\n" + " I have received the weather information for both" + + " cities. Now I will compile this information into a" + + " clear response for the User.\n" + "\n" - + "The current weather in Seattle is 50 degrees and it is raining. In San Francisco, the weather is 70 degrees and sunny."))))); + + "The current weather in Seattle is 50 degrees and it is" + + " raining. In San Francisco, the weather is 70 degrees" + + " and sunny."))))); } @Test @@ -3573,7 +3621,10 @@ void testInvokeModelToolCallAnthropicClaude() { KeyValue.of( "content", Value.of( - "To answer your question about the weather in Seattle and San Francisco today, I'll need to use the get_current_weather function for both cities. Let me do that for you now."))))); + "To answer your question about the weather in Seattle and San" + + " Francisco today, I'll need to use the" + + " get_current_weather function for both cities. Let me do" + + " that for you now."))))); // Clear to allow asserting telemetry of user request and tool result processing separately. getTesting().clearData(); @@ -3728,7 +3779,10 @@ void testInvokeModelToolCallAnthropicClaude() { KeyValue.of( "content", Value.of( - "To answer your question about the weather in Seattle and San Francisco today, I'll need to use the get_current_weather function for both cities. Let me do that for you now.")))), + "To answer your question about the weather in Seattle and San" + + " Francisco today, I'll need to use the" + + " get_current_weather function for both cities. Let me do" + + " that for you now.")))), log -> log.hasAttributesSatisfyingExactly( equalTo(GEN_AI_PROVIDER_NAME, AWS_BEDROCK), @@ -3759,14 +3813,22 @@ void testInvokeModelToolCallAnthropicClaude() { KeyValue.of( "content", Value.of( - "Thank you for your patience. I've retrieved the current weather information for both cities. Here's the weather report for Seattle and San Francisco today:\n" + "Thank you for your patience. I've retrieved the current" + + " weather information for both cities. Here's the weather" + + " report for Seattle and San Francisco today:\n" + "\n" + "Seattle: 50 degrees and raining\n" + "San Francisco: 70 degrees and sunny\n" + "\n" - + "As you can see, the weather conditions are quite different in these two cities today. Seattle is experiencing cooler temperatures with rain, which is fairly typical for the Pacific Northwest. On the other hand, San Francisco is enjoying a warmer, sunny day, which is pleasant for outdoor activities.\n" + + "As you can see, the weather conditions are quite" + + " different in these two cities today. Seattle is" + + " experiencing cooler temperatures with rain, which is" + + " fairly typical for the Pacific Northwest. On the other" + + " hand, San Francisco is enjoying a warmer, sunny day," + + " which is pleasant for outdoor activities.\n" + "\n" - + "Is there anything else you'd like to know about the weather in these or any other cities?"))))); + + "Is there anything else you'd like to know about the" + + " weather in these or any other cities?"))))); } @Test @@ -4034,7 +4096,11 @@ public void accept(PayloadPart chunk) { KeyValue.of( "content", Value.of( - "To get the current weather for both Seattle and San Francisco, I'll need to use the get_current_weather function for each city. I'll make two separate calls within the same function calls block since these requests are independent of each other."))))); + "To get the current weather for both Seattle and San Francisco," + + " I'll need to use the get_current_weather function for" + + " each city. I'll make two separate calls within the same" + + " function calls block since these requests are" + + " independent of each other."))))); // Clear to allow asserting telemetry of user request and tool result processing separately. getTesting().clearData(); @@ -4229,7 +4295,11 @@ public void accept(PayloadPart chunk) { KeyValue.of( "content", Value.of( - "To get the current weather for both Seattle and San Francisco, I'll need to use the get_current_weather function for each city. I'll make two separate calls within the same function calls block since these requests are independent of each other.")))), + "To get the current weather for both Seattle and San Francisco," + + " I'll need to use the get_current_weather function for" + + " each city. I'll make two separate calls within the same" + + " function calls block since these requests are" + + " independent of each other.")))), log -> log.hasAttributesSatisfyingExactly( equalTo(GEN_AI_PROVIDER_NAME, AWS_BEDROCK), @@ -4262,12 +4332,24 @@ public void accept(PayloadPart chunk) { Value.of( "\n" + "\n" - + "Based on the results from the weather function, I can provide you with the current weather information for both cities:\n" + + "Based on the results from the weather function, I can" + + " provide you with the current weather information for" + + " both cities:\n" + "\n" - + "Seattle: The current weather in Seattle is 50 degrees and raining.\n" + + "Seattle: The current weather in Seattle is 50 degrees" + + " and raining.\n" + "\n" - + "San Francisco: The current weather in San Francisco is 70 degrees and sunny.\n" + + "San Francisco: The current weather in San Francisco is" + + " 70 degrees and sunny.\n" + "\n" - + "As you can see, there's quite a difference in the weather between these two West Coast cities today. Seattle is experiencing cooler temperatures with rain, which is fairly typical for the city. On the other hand, San Francisco is enjoying warmer weather with sunshine. If you're planning any activities in either of these cities, you might want to dress accordingly and perhaps bring an umbrella if you're in Seattle!"))))); + + "As you can see, there's quite a difference in the" + + " weather between these two West Coast cities today." + + " Seattle is experiencing cooler temperatures with rain," + + " which is fairly typical for the city. On the other" + + " hand, San Francisco is enjoying warmer weather with" + + " sunshine. If you're planning any activities in either" + + " of these cities, you might want to dress accordingly" + + " and perhaps bring an umbrella if you're in" + + " Seattle!"))))); } } diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractAws2ClientTest.java b/instrumentation/aws-sdk/aws-sdk-2.2/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractAws2ClientTest.java index b894f1330765..43f83a4f58a6 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractAws2ClientTest.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractAws2ClientTest.java @@ -148,89 +148,49 @@ public abstract class AbstractAws2ClientTest extends AbstractAws2ClientCoreTest + ""; private static final String lambdaCreateEventSourceMappingResponseBody = - "{" - + "\"UUID\": \"e31def54-5e5d-4c1b-8e0f-bf1b11c137b7\"," - + "\"BatchSize\": 10," - + "\"MaximumBatchingWindowInSeconds\": 0," - + "\"EventSourceArn\": \"arn:aws:sqs:us-west-2:123456789012:MyTestQueue.fifo\"," - + "\"FunctionArn\": \"arn:aws:lambda:us-west-2:123456789012:function:myFn01-Temp\"," - + "\"LastModified\": \"1.754882043E9\"," - + "\"State\": \"Creating\"," - + "\"StateTransitionReason\": \"USER_INITIATED\"," - + "\"FunctionResponseTypes\": []," - + "\"EventSourceMappingArn\": \"arn:aws:lambda:us-west-2:123456789012:event-source-mapping:e31def54-5e5d-4c1b-8e0f-bf1b11c137b7\"" + "{\"UUID\": \"e31def54-5e5d-4c1b-8e0f-bf1b11c137b7\",\"BatchSize\":" + + " 10,\"MaximumBatchingWindowInSeconds\": 0,\"EventSourceArn\":" + + " \"arn:aws:sqs:us-west-2:123456789012:MyTestQueue.fifo\",\"FunctionArn\":" + + " \"arn:aws:lambda:us-west-2:123456789012:function:myFn01-Temp\",\"LastModified\":" + + " \"1.754882043E9\",\"State\": \"Creating\",\"StateTransitionReason\":" + + " \"USER_INITIATED\",\"FunctionResponseTypes\": [],\"EventSourceMappingArn\":" + + " \"arn:aws:lambda:us-west-2:123456789012:event-source-mapping:e31def54-5e5d-4c1b-8e0f-bf1b11c137b7\"" + "}"; private static final String lambdaGetEventSourceMappingResponseBody = - "{" - + "\"UUID\": \"e31def54-5e5d-4c1b-8e0f-bf1b11c138c8\"," - + "\"BatchSize\": 10," - + "\"MaximumBatchingWindowInSeconds\": 0," - + "\"EventSourceArn\": \"arn:aws:sqs:us-west-2:123456789012:MyTestQueue.fifo\"," - + "\"FunctionArn\": \"arn:aws:lambda:us-west-2:123456789012:function:myFn01-Temp\"," - + "\"LastModified\": \"1.755054843E9\"," - + "\"State\": \"Enabled\"," - + "\"StateTransitionReason\": \"USER_INITIATED\"," - + "\"FunctionResponseTypes\": []," - + "\"EventSourceMappingArn\": \"arn:aws:lambda:us-west-2:123456789012:event-source-mapping:e31def54-5e5d-4c1b-8e0f-bf1b11c138c8\"" + "{\"UUID\": \"e31def54-5e5d-4c1b-8e0f-bf1b11c138c8\",\"BatchSize\":" + + " 10,\"MaximumBatchingWindowInSeconds\": 0,\"EventSourceArn\":" + + " \"arn:aws:sqs:us-west-2:123456789012:MyTestQueue.fifo\",\"FunctionArn\":" + + " \"arn:aws:lambda:us-west-2:123456789012:function:myFn01-Temp\",\"LastModified\":" + + " \"1.755054843E9\",\"State\": \"Enabled\",\"StateTransitionReason\":" + + " \"USER_INITIATED\",\"FunctionResponseTypes\": [],\"EventSourceMappingArn\":" + + " \"arn:aws:lambda:us-west-2:123456789012:event-source-mapping:e31def54-5e5d-4c1b-8e0f-bf1b11c138c8\"" + "}"; private static final String lambdaGetFunctionResponseBody = - "{" - + "\"Configuration\": {" - + " \"FunctionName\": \"lambda-function-name-foo\"," - + " \"FunctionArn\": \"arn:aws:lambda:us-west-2:123456789012:function:lambda-function-name-foo\"," - + " \"Runtime\": \"nodejs22.x\"," - + " \"Role\": \"arn:aws:iam::123456789012:role/service-role/Fn-role-pr7kt0bf\"," - + " \"Handler\": \"index.handler\"," - + " \"CodeSize\": 295," - + " \"Description\": \"\"," - + " \"Timeout\": 3," - + " \"MemorySize\": 128," - + " \"LastModified\": \"1.743573094E9\"," - + " \"CodeSha256\": \"q8E7Nexf5xxhKT9/d4bGpAYOXJYFAUjJ0UDj8OivK8E=\"," - + " \"Version\": \"$LATEST\"," - + " \"Environment\": {" - + " \"Variables\": {" - + " \"AWS_LAMBDA_EXEC_WRAPPER\": \"/opt/otel-instrument\"" - + "}" - + " }," - + " \"TracingConfig\": {" - + " \"Mode\": \"PassThrough\"" - + " }," - + " \"RevisionId\": \"955247dc-c724-4653-8f8b-f702c6f9c389\"," - + " \"Layers\": [" - + " {" - + " \"Arn\": \"arn:aws:lambda:us-west-2:615299751070:layer:AWSOpenTelemetryDistroJs:6\"," - + " \"CodeSize\": 14455992" - + " }" - + " ]," - + " \"State\": \"Active\"," - + " \"LastUpdateStatus\": \"Successful\"," - + " \"PackageType\": \"Zip\"," - + " \"Architectures\": [" - + " \"x86_64\"" - + " ]," - + " \"EphemeralStorage\": {" - + " \"Size\": 512" - + " }," - + " \"SnapStart\": {" - + " \"ApplyOn\": \"None\"," - + " \"OptimizationStatus\": \"Off\"" - + " }," - + " \"RuntimeVersionConfig\": {" - + " \"RuntimeVersionArn\": \"arn:aws:lambda:us-west-2::runtime:fd2e05b324f99edd3c6e17800b2535deb79bcce74b7506d595a94870b3d9bd2e\"" - + " }," - + " \"LoggingConfig\": {" - + " \"LogFormat\": \"Text\"," - + " \"LogGroup\": \"/aws/lambda/mlambda-function-name-foo\"" - + " }" - + " }," - + " \"Code\": {" - + " \"RepositoryType\": \"S3\"," - + " \"Location\": \"https://awslambda-us-west-2-tasks.s3.us-west-2.amazonaws.com/snapshots/123456789012/lambda-function-name-foo-47425b12\"" - + " }" - + "}"; + "{\"Configuration\": { \"FunctionName\": \"lambda-function-name-foo\", \"FunctionArn\":" + + " \"arn:aws:lambda:us-west-2:123456789012:function:lambda-function-name-foo\", " + + " \"Runtime\": \"nodejs22.x\", \"Role\":" + + " \"arn:aws:iam::123456789012:role/service-role/Fn-role-pr7kt0bf\", \"Handler\":" + + " \"index.handler\", \"CodeSize\": 295, \"Description\": \"\", \"Timeout\": 3, " + + " \"MemorySize\": 128, \"LastModified\": \"1.743573094E9\", \"CodeSha256\":" + + " \"q8E7Nexf5xxhKT9/d4bGpAYOXJYFAUjJ0UDj8OivK8E=\", \"Version\": \"$LATEST\", " + + " \"Environment\": { \"Variables\": { \"AWS_LAMBDA_EXEC_WRAPPER\":" + + " \"/opt/otel-instrument\"} }, \"TracingConfig\": { \"Mode\": \"PassThrough\"" + + " }, \"RevisionId\": \"955247dc-c724-4653-8f8b-f702c6f9c389\", \"Layers\": [ " + + " { \"Arn\":" + + " \"arn:aws:lambda:us-west-2:615299751070:layer:AWSOpenTelemetryDistroJs:6\", " + + " \"CodeSize\": 14455992 } ], \"State\": \"Active\", \"LastUpdateStatus\":" + + " \"Successful\", \"PackageType\": \"Zip\", \"Architectures\": [ \"x86_64\" " + + " ], \"EphemeralStorage\": { \"Size\": 512 }, \"SnapStart\": { " + + " \"ApplyOn\": \"None\", \"OptimizationStatus\": \"Off\" }, " + + " \"RuntimeVersionConfig\": { \"RuntimeVersionArn\":" + + " \"arn:aws:lambda:us-west-2::runtime:fd2e05b324f99edd3c6e17800b2535deb79bcce74b7506d595a94870b3d9bd2e\"" + + " }, \"LoggingConfig\": { \"LogFormat\": \"Text\", \"LogGroup\":" + + " \"/aws/lambda/mlambda-function-name-foo\" } }, \"Code\": { \"RepositoryType\":" + + " \"S3\", \"Location\":" + + " \"https://awslambda-us-west-2-tasks.s3.us-west-2.amazonaws.com/snapshots/123456789012/lambda-function-name-foo-47425b12\"" + + " }}"; private static final String rdsBodyContent = "" @@ -238,16 +198,12 @@ public abstract class AbstractAws2ClientTest extends AbstractAws2ClientCoreTest + ""; private static final String secretsManagerBodyContent = - "{" - + " \"ARN\": \"arn:aws:secretsmanager:us-east-1:123456789012:secret:MySecretFromCLI-sNkBwD\"," - + " \"Name\": \"MySecretFromCLI\"," - + " \"VersionId\": \"9959b95b-1234-5678-a19b-a4b0315ca5aa\"," - + " \"SecretString\": \"super-secret-value\"," - + " \"VersionStages\": [" - + " \"AWSCURRENT\"" - + " ]," - + " \"CreatedDate\": \"1.523477145713E9\"" - + "}"; + "{ \"ARN\":" + + " \"arn:aws:secretsmanager:us-east-1:123456789012:secret:MySecretFromCLI-sNkBwD\", " + + " \"Name\": \"MySecretFromCLI\", \"VersionId\":" + + " \"9959b95b-1234-5678-a19b-a4b0315ca5aa\", \"SecretString\":" + + " \"super-secret-value\", \"VersionStages\": [ \"AWSCURRENT\" ], " + + " \"CreatedDate\": \"1.523477145713E9\"}"; private static final String snsPublishResponseBody = "" @@ -260,13 +216,11 @@ public abstract class AbstractAws2ClientTest extends AbstractAws2ClientCoreTest + ""; private static final String snsSubscribeResponseBody = - "" - + " " - + " arn:aws:sns:us-west-2:123456789012:MyTopic:abc123" - + " " - + " " - + " 0ac9cda2-abcd-11d3-f92b-31fa5e8dbc67" - + " " + " " + + " " + + " arn:aws:sns:us-west-2:123456789012:MyTopic:abc123 " + + " " + + " 0ac9cda2-abcd-11d3-f92b-31fa5e8dbc67 " + " "; private static final String snsCreateTopicResponseBody = @@ -606,9 +560,8 @@ private static Stream provideSqsArguments() { String content; if (!Boolean.getBoolean("testLatestDeps")) { content = - "" - + " " - + " d41d8cd98f00b204e9800998ecf8427e" + " " + + " d41d8cd98f00b204e9800998ecf8427e" + " 3ae8f24a165a8cedc005670c81a27295" + " 5fea7756-0ea4-451a-a703-a558b933e274" + " " diff --git a/instrumentation/azure-core/azure-core-1.14/javaagent/build.gradle.kts b/instrumentation/azure-core/azure-core-1.14/javaagent/build.gradle.kts index 0acce4353932..bc5a1f84ae45 100644 --- a/instrumentation/azure-core/azure-core-1.14/javaagent/build.gradle.kts +++ b/instrumentation/azure-core/azure-core-1.14/javaagent/build.gradle.kts @@ -13,16 +13,23 @@ muzzle { sourceSets { main { - val shadedDep = project(":instrumentation:azure-core:azure-core-1.14:library-instrumentation-shaded") + val shadedDep = + project(":instrumentation:azure-core:azure-core-1.14:library-instrumentation-shaded") output.dir( shadedDep.file("build/extracted/shadow"), - "builtBy" to ":instrumentation:azure-core:azure-core-1.14:library-instrumentation-shaded:extractShadowJar" + "builtBy" to + ":instrumentation:azure-core:azure-core-1.14:library-instrumentation-shaded:extractShadowJar", ) } } dependencies { - compileOnly(project(":instrumentation:azure-core:azure-core-1.14:library-instrumentation-shaded", configuration = "shadow")) + compileOnly( + project( + ":instrumentation:azure-core:azure-core-1.14:library-instrumentation-shaded", + configuration = "shadow", + ), + ) library("com.azure:azure-core:1.14.0") diff --git a/instrumentation/azure-core/azure-core-1.14/library-instrumentation-shaded/build.gradle.kts b/instrumentation/azure-core/azure-core-1.14/library-instrumentation-shaded/build.gradle.kts index 67250df40347..a9f2a56fb0a9 100644 --- a/instrumentation/azure-core/azure-core-1.14/library-instrumentation-shaded/build.gradle.kts +++ b/instrumentation/azure-core/azure-core-1.14/library-instrumentation-shaded/build.gradle.kts @@ -18,7 +18,10 @@ tasks { // including only azure-core-tracing-opentelemetry excludes its transitive dependencies include(dependency("com.azure:azure-core-tracing-opentelemetry")) } - relocate("com.azure.core.tracing.opentelemetry", "io.opentelemetry.javaagent.instrumentation.azurecore.v1_14.shaded.com.azure.core.tracing.opentelemetry") + relocate( + "com.azure.core.tracing.opentelemetry", + "io.opentelemetry.javaagent.instrumentation.azurecore.v1_14.shaded.com.azure.core.tracing.opentelemetry", + ) } val extractShadowJar by registering(Copy::class) { diff --git a/instrumentation/azure-core/azure-core-1.19/javaagent/build.gradle.kts b/instrumentation/azure-core/azure-core-1.19/javaagent/build.gradle.kts index d27fd1ec0507..fc08f7ed213f 100644 --- a/instrumentation/azure-core/azure-core-1.19/javaagent/build.gradle.kts +++ b/instrumentation/azure-core/azure-core-1.19/javaagent/build.gradle.kts @@ -13,16 +13,23 @@ muzzle { sourceSets { main { - val shadedDep = project(":instrumentation:azure-core:azure-core-1.19:library-instrumentation-shaded") + val shadedDep = + project(":instrumentation:azure-core:azure-core-1.19:library-instrumentation-shaded") output.dir( shadedDep.file("build/extracted/shadow"), - "builtBy" to ":instrumentation:azure-core:azure-core-1.19:library-instrumentation-shaded:extractShadowJar" + "builtBy" to + ":instrumentation:azure-core:azure-core-1.19:library-instrumentation-shaded:extractShadowJar", ) } } dependencies { - compileOnly(project(":instrumentation:azure-core:azure-core-1.19:library-instrumentation-shaded", configuration = "shadow")) + compileOnly( + project( + ":instrumentation:azure-core:azure-core-1.19:library-instrumentation-shaded", + configuration = "shadow", + ), + ) library("com.azure:azure-core:1.19.0") diff --git a/instrumentation/azure-core/azure-core-1.19/library-instrumentation-shaded/build.gradle.kts b/instrumentation/azure-core/azure-core-1.19/library-instrumentation-shaded/build.gradle.kts index ddfdec284312..ed08f393f3f4 100644 --- a/instrumentation/azure-core/azure-core-1.19/library-instrumentation-shaded/build.gradle.kts +++ b/instrumentation/azure-core/azure-core-1.19/library-instrumentation-shaded/build.gradle.kts @@ -24,7 +24,10 @@ tasks { // including only azure-core-tracing-opentelemetry excludes its transitive dependencies include(dependency("com.azure:azure-core-tracing-opentelemetry")) } - relocate("com.azure.core.tracing.opentelemetry", "io.opentelemetry.javaagent.instrumentation.azurecore.v1_19.shaded.com.azure.core.tracing.opentelemetry") + relocate( + "com.azure.core.tracing.opentelemetry", + "io.opentelemetry.javaagent.instrumentation.azurecore.v1_19.shaded.com.azure.core.tracing.opentelemetry", + ) } val extractShadowJar by registering(Copy::class) { diff --git a/instrumentation/azure-core/azure-core-1.36/javaagent/build.gradle.kts b/instrumentation/azure-core/azure-core-1.36/javaagent/build.gradle.kts index 755a5f7affb3..4d2a01048442 100644 --- a/instrumentation/azure-core/azure-core-1.36/javaagent/build.gradle.kts +++ b/instrumentation/azure-core/azure-core-1.36/javaagent/build.gradle.kts @@ -13,16 +13,23 @@ muzzle { sourceSets { main { - val shadedDep = project(":instrumentation:azure-core:azure-core-1.36:library-instrumentation-shaded") + val shadedDep = + project(":instrumentation:azure-core:azure-core-1.36:library-instrumentation-shaded") output.dir( shadedDep.file("build/extracted/shadow"), - "builtBy" to ":instrumentation:azure-core:azure-core-1.36:library-instrumentation-shaded:extractShadowJar" + "builtBy" to + ":instrumentation:azure-core:azure-core-1.36:library-instrumentation-shaded:extractShadowJar", ) } } dependencies { - compileOnly(project(":instrumentation:azure-core:azure-core-1.36:library-instrumentation-shaded", configuration = "shadow")) + compileOnly( + project( + ":instrumentation:azure-core:azure-core-1.36:library-instrumentation-shaded", + configuration = "shadow", + ), + ) library("com.azure:azure-core:1.36.0") diff --git a/instrumentation/azure-core/azure-core-1.36/library-instrumentation-shaded/build.gradle.kts b/instrumentation/azure-core/azure-core-1.36/library-instrumentation-shaded/build.gradle.kts index a2f56bd6686b..42f70b0cde5e 100644 --- a/instrumentation/azure-core/azure-core-1.36/library-instrumentation-shaded/build.gradle.kts +++ b/instrumentation/azure-core/azure-core-1.36/library-instrumentation-shaded/build.gradle.kts @@ -21,7 +21,10 @@ tasks { // including only azure-core-tracing-opentelemetry excludes its transitive dependencies include(dependency("com.azure:azure-core-tracing-opentelemetry")) } - relocate("com.azure.core.tracing.opentelemetry", "io.opentelemetry.javaagent.instrumentation.azurecore.v1_36.shaded.com.azure.core.tracing.opentelemetry") + relocate( + "com.azure.core.tracing.opentelemetry", + "io.opentelemetry.javaagent.instrumentation.azurecore.v1_36.shaded.com.azure.core.tracing.opentelemetry", + ) } val extractShadowJar by registering(Copy::class) { diff --git a/instrumentation/azure-core/azure-core-1.53/javaagent/build.gradle.kts b/instrumentation/azure-core/azure-core-1.53/javaagent/build.gradle.kts index 587d54a45808..9a5cbf6bd520 100644 --- a/instrumentation/azure-core/azure-core-1.53/javaagent/build.gradle.kts +++ b/instrumentation/azure-core/azure-core-1.53/javaagent/build.gradle.kts @@ -13,16 +13,23 @@ muzzle { sourceSets { main { - val shadedDep = project(":instrumentation:azure-core:azure-core-1.53:library-instrumentation-shaded") + val shadedDep = + project(":instrumentation:azure-core:azure-core-1.53:library-instrumentation-shaded") output.dir( shadedDep.file("build/extracted/shadow"), - "builtBy" to ":instrumentation:azure-core:azure-core-1.53:library-instrumentation-shaded:extractShadowJar" + "builtBy" to + ":instrumentation:azure-core:azure-core-1.53:library-instrumentation-shaded:extractShadowJar", ) } } dependencies { - compileOnly(project(":instrumentation:azure-core:azure-core-1.53:library-instrumentation-shaded", configuration = "shadow")) + compileOnly( + project( + ":instrumentation:azure-core:azure-core-1.53:library-instrumentation-shaded", + configuration = "shadow", + ), + ) library("com.azure:azure-core:1.53.0") diff --git a/instrumentation/azure-core/azure-core-1.53/library-instrumentation-shaded/build.gradle.kts b/instrumentation/azure-core/azure-core-1.53/library-instrumentation-shaded/build.gradle.kts index 28a979116e93..483aeeaf3e25 100644 --- a/instrumentation/azure-core/azure-core-1.53/library-instrumentation-shaded/build.gradle.kts +++ b/instrumentation/azure-core/azure-core-1.53/library-instrumentation-shaded/build.gradle.kts @@ -19,7 +19,7 @@ tasks { } relocate( "com.azure.core.tracing.opentelemetry", - "io.opentelemetry.javaagent.instrumentation.azurecore.v1_53.shaded.com.azure.core.tracing.opentelemetry" + "io.opentelemetry.javaagent.instrumentation.azurecore.v1_53.shaded.com.azure.core.tracing.opentelemetry", ) } diff --git a/instrumentation/build.gradle.kts b/instrumentation/build.gradle.kts index 7eca88d4950a..4b1f1378b683 100644 --- a/instrumentation/build.gradle.kts +++ b/instrumentation/build.gradle.kts @@ -6,12 +6,13 @@ val instrumentationProjectTest = tasks.named("test") // batching up the muzzle tasks alphabetically into 4 chunks // to split them up into separate CI jobs (but not too many CI job) -val instrumentationProjectMuzzle = listOf( - tasks.register("muzzle1"), - tasks.register("muzzle2"), - tasks.register("muzzle3"), - tasks.register("muzzle4"), -) +val instrumentationProjectMuzzle = + listOf( + tasks.register("muzzle1"), + tasks.register("muzzle2"), + tasks.register("muzzle3"), + tasks.register("muzzle4"), + ) var counter = 0 subprojects { diff --git a/instrumentation/c3p0-0.9/javaagent/build.gradle.kts b/instrumentation/c3p0-0.9/javaagent/build.gradle.kts index 41a5b312c56a..a87f789d8309 100644 --- a/instrumentation/c3p0-0.9/javaagent/build.gradle.kts +++ b/instrumentation/c3p0-0.9/javaagent/build.gradle.kts @@ -25,7 +25,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") diff --git a/instrumentation/c3p0-0.9/library/build.gradle.kts b/instrumentation/c3p0-0.9/library/build.gradle.kts index 8624b977a5f2..90d11afb1331 100644 --- a/instrumentation/c3p0-0.9/library/build.gradle.kts +++ b/instrumentation/c3p0-0.9/library/build.gradle.kts @@ -11,7 +11,10 @@ dependencies { tasks { val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") diff --git a/instrumentation/camel-2.20/javaagent-unit-tests/build.gradle.kts b/instrumentation/camel-2.20/javaagent-unit-tests/build.gradle.kts index 15c43e636421..209a4304c5e5 100644 --- a/instrumentation/camel-2.20/javaagent-unit-tests/build.gradle.kts +++ b/instrumentation/camel-2.20/javaagent-unit-tests/build.gradle.kts @@ -4,7 +4,10 @@ plugins { tasks { val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") } diff --git a/instrumentation/camel-2.20/javaagent/build.gradle.kts b/instrumentation/camel-2.20/javaagent/build.gradle.kts index c4c6516ffb36..eacf265e4afd 100644 --- a/instrumentation/camel-2.20/javaagent/build.gradle.kts +++ b/instrumentation/camel-2.20/javaagent/build.gradle.kts @@ -86,7 +86,10 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.camel.experimental-span-attributes=true") @@ -94,7 +97,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") diff --git a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/AwsConnector.java b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/AwsConnector.java index 84159dc5fbf9..0269cbb789b2 100644 --- a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/AwsConnector.java +++ b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/AwsConnector.java @@ -123,7 +123,8 @@ String getQueueArn(String queueUrl) { private static String getSqsPolicy(String resource) { return String.format( - "{\"Statement\": [{\"Effect\": \"Allow\", \"Principal\": \"*\", \"Action\": \"sqs:SendMessage\", \"Resource\": \"%s\"}]}", + "{\"Statement\": [{\"Effect\": \"Allow\", \"Principal\": \"*\", \"Action\":" + + " \"sqs:SendMessage\", \"Resource\": \"%s\"}]}", resource); } diff --git a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/CassandraTest.java b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/CassandraTest.java index 4bc8ccf0734b..862784fdbef2 100644 --- a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/CassandraTest.java +++ b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/CassandraTest.java @@ -101,7 +101,8 @@ static void cassandraSetup() { .withLocalDatacenter(cassandra.getLocalDatacenter()) .build()) { cqlSession.execute( - "CREATE KEYSPACE IF NOT EXISTS test WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};"); + "CREATE KEYSPACE IF NOT EXISTS test WITH replication = {'class': 'SimpleStrategy'," + + " 'replication_factor': 1};"); cqlSession.execute("CREATE TABLE IF NOT EXISTS test.users (id int PRIMARY KEY, name TEXT);"); } } diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/build.gradle.kts b/instrumentation/cassandra/cassandra-3.0/javaagent/build.gradle.kts index 01688dc694f7..73e141dcdc30 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/build.gradle.kts +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/build.gradle.kts @@ -38,7 +38,10 @@ dependencies { } // Requires old Guava. Can't use enforcedPlatform since predates BOM -configurations.testRuntimeClasspath.get().resolutionStrategy.force("com.google.guava:guava:19.0") +configurations.testRuntimeClasspath + .get() + .resolutionStrategy + .force("com.google.guava:guava:19.0") tasks { withType().configureEach { @@ -47,7 +50,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraClientTest.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraClientTest.java index 192eddaee689..34b0af3ecdf7 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraClientTest.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraClientTest.java @@ -319,7 +319,8 @@ private static Stream provideSyncParameters() { "Create keyspace with replication", new Parameter( null, - "CREATE KEYSPACE sync_test WITH REPLICATION = {'class':'SimpleStrategy', 'replication_factor':3}", + "CREATE KEYSPACE sync_test WITH REPLICATION = {'class':'SimpleStrategy'," + + " 'replication_factor':3}", "CREATE KEYSPACE sync_test WITH REPLICATION = {?:?, ?:?}", emitStableDatabaseSemconv() ? "CREATE KEYSPACE" : "CREATE", "CREATE", @@ -373,7 +374,8 @@ private static Stream provideAsyncParameters() { "Create keyspace with replication", new Parameter( null, - "CREATE KEYSPACE async_test WITH REPLICATION = {'class':'SimpleStrategy', 'replication_factor':3}", + "CREATE KEYSPACE async_test WITH REPLICATION = {'class':'SimpleStrategy'," + + " 'replication_factor':3}", "CREATE KEYSPACE async_test WITH REPLICATION = {?:?, ?:?}", emitStableDatabaseSemconv() ? "CREATE KEYSPACE" : "CREATE", "CREATE", diff --git a/instrumentation/cassandra/cassandra-4.0/javaagent/build.gradle.kts b/instrumentation/cassandra/cassandra-4.0/javaagent/build.gradle.kts index 144a06a5caa7..45044b24d775 100644 --- a/instrumentation/cassandra/cassandra-4.0/javaagent/build.gradle.kts +++ b/instrumentation/cassandra/cassandra-4.0/javaagent/build.gradle.kts @@ -31,7 +31,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") diff --git a/instrumentation/cassandra/cassandra-4.4/javaagent/build.gradle.kts b/instrumentation/cassandra/cassandra-4.4/javaagent/build.gradle.kts index be27475cacf8..5eb5742dad99 100644 --- a/instrumentation/cassandra/cassandra-4.4/javaagent/build.gradle.kts +++ b/instrumentation/cassandra/cassandra-4.4/javaagent/build.gradle.kts @@ -42,7 +42,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") diff --git a/instrumentation/cassandra/cassandra-4.4/library/build.gradle.kts b/instrumentation/cassandra/cassandra-4.4/library/build.gradle.kts index ecb350287f92..4254b3629181 100644 --- a/instrumentation/cassandra/cassandra-4.4/library/build.gradle.kts +++ b/instrumentation/cassandra/cassandra-4.4/library/build.gradle.kts @@ -21,7 +21,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") } diff --git a/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java b/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java index 8de13ef582dc..5a78024e1a3f 100644 --- a/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java +++ b/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java @@ -119,7 +119,8 @@ private static Stream provideReactiveParameters() { "Create keyspace with replication", new Parameter( null, - "CREATE KEYSPACE reactive_test WITH REPLICATION = {'class':'SimpleStrategy', 'replication_factor':3}", + "CREATE KEYSPACE reactive_test WITH REPLICATION = {'class':'SimpleStrategy'," + + " 'replication_factor':3}", "CREATE KEYSPACE reactive_test WITH REPLICATION = {?:?, ?:?}", emitStableDatabaseSemconv() ? "CREATE KEYSPACE" : "CREATE", "CREATE", diff --git a/instrumentation/cassandra/cassandra-common-4.0/testing/src/main/java/io/opentelemetry/cassandra/common/v4_0/AbstractCassandraTest.java b/instrumentation/cassandra/cassandra-common-4.0/testing/src/main/java/io/opentelemetry/cassandra/common/v4_0/AbstractCassandraTest.java index bd06cf8214ec..51d7e71b32fd 100644 --- a/instrumentation/cassandra/cassandra-common-4.0/testing/src/main/java/io/opentelemetry/cassandra/common/v4_0/AbstractCassandraTest.java +++ b/instrumentation/cassandra/cassandra-common-4.0/testing/src/main/java/io/opentelemetry/cassandra/common/v4_0/AbstractCassandraTest.java @@ -232,7 +232,8 @@ private static Stream provideSyncParameters() { "Create keyspace with replication", new Parameter( null, - "CREATE KEYSPACE sync_test WITH REPLICATION = {'class':'SimpleStrategy', 'replication_factor':3}", + "CREATE KEYSPACE sync_test WITH REPLICATION = {'class':'SimpleStrategy'," + + " 'replication_factor':3}", "CREATE KEYSPACE sync_test WITH REPLICATION = {?:?, ?:?}", emitStableDatabaseSemconv() ? "CREATE KEYSPACE" : "CREATE", "CREATE", @@ -286,7 +287,8 @@ private static Stream provideAsyncParameters() { "Create keyspace with replication", new Parameter( null, - "CREATE KEYSPACE async_test WITH REPLICATION = {'class':'SimpleStrategy', 'replication_factor':3}", + "CREATE KEYSPACE async_test WITH REPLICATION = {'class':'SimpleStrategy'," + + " 'replication_factor':3}", "CREATE KEYSPACE async_test WITH REPLICATION = {?:?, ?:?}", emitStableDatabaseSemconv() ? "CREATE KEYSPACE" : "CREATE", "CREATE", diff --git a/instrumentation/clickhouse/clickhouse-client-v1-0.5/javaagent/build.gradle.kts b/instrumentation/clickhouse/clickhouse-client-v1-0.5/javaagent/build.gradle.kts index 9ea3a433b03d..cfa826c0e2ef 100644 --- a/instrumentation/clickhouse/clickhouse-client-v1-0.5/javaagent/build.gradle.kts +++ b/instrumentation/clickhouse/clickhouse-client-v1-0.5/javaagent/build.gradle.kts @@ -30,7 +30,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") diff --git a/instrumentation/clickhouse/clickhouse-client-v2-0.8/javaagent/build.gradle.kts b/instrumentation/clickhouse/clickhouse-client-v2-0.8/javaagent/build.gradle.kts index e85c2fcef072..a2ae37da4219 100644 --- a/instrumentation/clickhouse/clickhouse-client-v2-0.8/javaagent/build.gradle.kts +++ b/instrumentation/clickhouse/clickhouse-client-v2-0.8/javaagent/build.gradle.kts @@ -24,7 +24,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") diff --git a/instrumentation/couchbase/couchbase-2.0/javaagent/build.gradle.kts b/instrumentation/couchbase/couchbase-2.0/javaagent/build.gradle.kts index 314ea21574b2..ef20075fe732 100644 --- a/instrumentation/couchbase/couchbase-2.0/javaagent/build.gradle.kts +++ b/instrumentation/couchbase/couchbase-2.0/javaagent/build.gradle.kts @@ -47,7 +47,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") diff --git a/instrumentation/couchbase/couchbase-2.6/javaagent/build.gradle.kts b/instrumentation/couchbase/couchbase-2.6/javaagent/build.gradle.kts index b8059b0a2137..b545b5334c5a 100644 --- a/instrumentation/couchbase/couchbase-2.6/javaagent/build.gradle.kts +++ b/instrumentation/couchbase/couchbase-2.6/javaagent/build.gradle.kts @@ -48,7 +48,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") @@ -56,11 +59,17 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.couchbase.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.couchbase.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.couchbase.experimental-span-attributes=true", + ) } check { diff --git a/instrumentation/couchbase/couchbase-3.1.6/javaagent/build.gradle.kts b/instrumentation/couchbase/couchbase-3.1.6/javaagent/build.gradle.kts index d795ce2c5a1c..c55ccbfa9ac3 100644 --- a/instrumentation/couchbase/couchbase-3.1.6/javaagent/build.gradle.kts +++ b/instrumentation/couchbase/couchbase-3.1.6/javaagent/build.gradle.kts @@ -13,10 +13,12 @@ muzzle { sourceSets { main { - val shadedDep = project(":instrumentation:couchbase:couchbase-3.1.6:tracing-opentelemetry-shaded") + val shadedDep = + project(":instrumentation:couchbase:couchbase-3.1.6:tracing-opentelemetry-shaded") output.dir( shadedDep.file("build/extracted/shadow"), - "builtBy" to ":instrumentation:couchbase:couchbase-3.1.6:tracing-opentelemetry-shaded:extractShadowJar", + "builtBy" to + ":instrumentation:couchbase:couchbase-3.1.6:tracing-opentelemetry-shaded:extractShadowJar", ) } } @@ -48,7 +50,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database") diff --git a/instrumentation/couchbase/couchbase-3.1.6/tracing-opentelemetry-shaded/build.gradle.kts b/instrumentation/couchbase/couchbase-3.1.6/tracing-opentelemetry-shaded/build.gradle.kts index 128e45cc51f1..a55d9169465a 100644 --- a/instrumentation/couchbase/couchbase-3.1.6/tracing-opentelemetry-shaded/build.gradle.kts +++ b/instrumentation/couchbase/couchbase-3.1.6/tracing-opentelemetry-shaded/build.gradle.kts @@ -17,7 +17,7 @@ tasks { } relocate( "com.couchbase.client.tracing.opentelemetry", - "io.opentelemetry.javaagent.instrumentation.couchbase.v3_1_6.shaded.com.couchbase.client.tracing.opentelemetry" + "io.opentelemetry.javaagent.instrumentation.couchbase.v3_1_6.shaded.com.couchbase.client.tracing.opentelemetry", ) } diff --git a/instrumentation/couchbase/couchbase-3.1/javaagent/build.gradle.kts b/instrumentation/couchbase/couchbase-3.1/javaagent/build.gradle.kts index 67ae194f997c..651768eb41ec 100644 --- a/instrumentation/couchbase/couchbase-3.1/javaagent/build.gradle.kts +++ b/instrumentation/couchbase/couchbase-3.1/javaagent/build.gradle.kts @@ -16,7 +16,8 @@ sourceSets { val shadedDep = project(":instrumentation:couchbase:couchbase-3.1:tracing-opentelemetry-shaded") output.dir( shadedDep.file("build/extracted/shadow"), - "builtBy" to ":instrumentation:couchbase:couchbase-3.1:tracing-opentelemetry-shaded:extractShadowJar", + "builtBy" to + ":instrumentation:couchbase:couchbase-3.1:tracing-opentelemetry-shaded:extractShadowJar", ) } } @@ -49,7 +50,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database") diff --git a/instrumentation/couchbase/couchbase-3.1/tracing-opentelemetry-shaded/build.gradle.kts b/instrumentation/couchbase/couchbase-3.1/tracing-opentelemetry-shaded/build.gradle.kts index e1bff72f5885..fba3bf697418 100644 --- a/instrumentation/couchbase/couchbase-3.1/tracing-opentelemetry-shaded/build.gradle.kts +++ b/instrumentation/couchbase/couchbase-3.1/tracing-opentelemetry-shaded/build.gradle.kts @@ -18,7 +18,7 @@ tasks { } relocate( "com.couchbase.client.tracing.opentelemetry", - "io.opentelemetry.javaagent.instrumentation.couchbase.v3_1.shaded.com.couchbase.client.tracing.opentelemetry" + "io.opentelemetry.javaagent.instrumentation.couchbase.v3_1.shaded.com.couchbase.client.tracing.opentelemetry", ) } diff --git a/instrumentation/couchbase/couchbase-3.2/javaagent/build.gradle.kts b/instrumentation/couchbase/couchbase-3.2/javaagent/build.gradle.kts index b8dc91c21046..e351969a61e4 100644 --- a/instrumentation/couchbase/couchbase-3.2/javaagent/build.gradle.kts +++ b/instrumentation/couchbase/couchbase-3.2/javaagent/build.gradle.kts @@ -16,7 +16,8 @@ sourceSets { val shadedDep = project(":instrumentation:couchbase:couchbase-3.2:tracing-opentelemetry-shaded") output.dir( shadedDep.file("build/extracted/shadow"), - "builtBy" to ":instrumentation:couchbase:couchbase-3.2:tracing-opentelemetry-shaded:extractShadowJar", + "builtBy" to + ":instrumentation:couchbase:couchbase-3.2:tracing-opentelemetry-shaded:extractShadowJar", ) } } @@ -50,7 +51,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database") diff --git a/instrumentation/couchbase/couchbase-3.2/tracing-opentelemetry-shaded/build.gradle.kts b/instrumentation/couchbase/couchbase-3.2/tracing-opentelemetry-shaded/build.gradle.kts index c97e14e07e7a..4fae8ef6b5d8 100644 --- a/instrumentation/couchbase/couchbase-3.2/tracing-opentelemetry-shaded/build.gradle.kts +++ b/instrumentation/couchbase/couchbase-3.2/tracing-opentelemetry-shaded/build.gradle.kts @@ -17,7 +17,7 @@ tasks { } relocate( "com.couchbase.client.tracing.opentelemetry", - "io.opentelemetry.javaagent.instrumentation.couchbase.v3_2.shaded.com.couchbase.client.tracing.opentelemetry" + "io.opentelemetry.javaagent.instrumentation.couchbase.v3_2.shaded.com.couchbase.client.tracing.opentelemetry", ) } diff --git a/instrumentation/couchbase/couchbase-3.4/javaagent/build.gradle.kts b/instrumentation/couchbase/couchbase-3.4/javaagent/build.gradle.kts index 855de25e9a2e..6902061e8ea4 100644 --- a/instrumentation/couchbase/couchbase-3.4/javaagent/build.gradle.kts +++ b/instrumentation/couchbase/couchbase-3.4/javaagent/build.gradle.kts @@ -16,7 +16,8 @@ sourceSets { val shadedDep = project(":instrumentation:couchbase:couchbase-3.4:tracing-opentelemetry-shaded") output.dir( shadedDep.file("build/extracted/shadow"), - "builtBy" to ":instrumentation:couchbase:couchbase-3.4:tracing-opentelemetry-shaded:extractShadowJar", + "builtBy" to + ":instrumentation:couchbase:couchbase-3.4:tracing-opentelemetry-shaded:extractShadowJar", ) } } @@ -48,7 +49,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database") diff --git a/instrumentation/couchbase/couchbase-3.4/tracing-opentelemetry-shaded/build.gradle.kts b/instrumentation/couchbase/couchbase-3.4/tracing-opentelemetry-shaded/build.gradle.kts index 17690c1154c7..8c62851664d4 100644 --- a/instrumentation/couchbase/couchbase-3.4/tracing-opentelemetry-shaded/build.gradle.kts +++ b/instrumentation/couchbase/couchbase-3.4/tracing-opentelemetry-shaded/build.gradle.kts @@ -17,7 +17,7 @@ tasks { } relocate( "com.couchbase.client.tracing.opentelemetry", - "io.opentelemetry.javaagent.instrumentation.couchbase.v3_4.shaded.com.couchbase.client.tracing.opentelemetry" + "io.opentelemetry.javaagent.instrumentation.couchbase.v3_4.shaded.com.couchbase.client.tracing.opentelemetry", ) } diff --git a/instrumentation/couchbase/couchbase-common/testing/src/main/java/io/opentelemetry/instrumentation/couchbase/springdata/AbstractCouchbaseSpringRepositoryTest.java b/instrumentation/couchbase/couchbase-common/testing/src/main/java/io/opentelemetry/instrumentation/couchbase/springdata/AbstractCouchbaseSpringRepositoryTest.java index 79c2a28f03dc..1fd073f3da04 100644 --- a/instrumentation/couchbase/couchbase-common/testing/src/main/java/io/opentelemetry/instrumentation/couchbase/springdata/AbstractCouchbaseSpringRepositoryTest.java +++ b/instrumentation/couchbase/couchbase-common/testing/src/main/java/io/opentelemetry/instrumentation/couchbase/springdata/AbstractCouchbaseSpringRepositoryTest.java @@ -62,11 +62,9 @@ void setUpSpring() { singletonList( DefaultView.create( "all", - "function (doc, meta) {" - + " if (doc._class == \"io.opentelemetry.instrumentation.couchbase.springdata.TestDocument\") {" - + " emit(meta.id, null);" - + " }" - + "}")))); + "function (doc, meta) { if (doc._class ==" + + " \"io.opentelemetry.instrumentation.couchbase.springdata.TestDocument\")" + + " { emit(meta.id, null); }}")))); CouchbaseConfig.environment = environment; CouchbaseConfig.bucketSettings = bucketCouchbase; diff --git a/instrumentation/dropwizard/dropwizard-metrics-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/dropwizardmetrics/DropwizardMetricsAdapter.java b/instrumentation/dropwizard/dropwizard-metrics-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/dropwizardmetrics/DropwizardMetricsAdapter.java index d66e86857b8f..7dcad8e8fd9a 100644 --- a/instrumentation/dropwizard/dropwizard-metrics-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/dropwizardmetrics/DropwizardMetricsAdapter.java +++ b/instrumentation/dropwizard/dropwizard-metrics-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/dropwizardmetrics/DropwizardMetricsAdapter.java @@ -83,7 +83,8 @@ private static String sanitizeInstrumentName(String name) { if (sanitized.isEmpty()) { logger.log( WARNING, - "Dropwizard metric name ''{0}'' contains no valid characters after sanitization, skipping instrument creation", + "Dropwizard metric name ''{0}'' contains no valid characters after sanitization, skipping" + + " instrument creation", name); return null; } @@ -92,7 +93,8 @@ private static String sanitizeInstrumentName(String name) { if (!Character.isLetter(sanitized.charAt(0))) { logger.log( WARNING, - "Dropwizard metric name ''{0}'' does not start with a letter after sanitization, skipping instrument creation", + "Dropwizard metric name ''{0}'' does not start with a letter after sanitization, skipping" + + " instrument creation", name); return null; } diff --git a/instrumentation/dropwizard/dropwizard-views-0.7/javaagent/build.gradle.kts b/instrumentation/dropwizard/dropwizard-views-0.7/javaagent/build.gradle.kts index dd830e796548..6e0c36b619df 100644 --- a/instrumentation/dropwizard/dropwizard-views-0.7/javaagent/build.gradle.kts +++ b/instrumentation/dropwizard/dropwizard-views-0.7/javaagent/build.gradle.kts @@ -22,5 +22,8 @@ tasks.withType().configureEach { jvmArgs("-Dotel.instrumentation.common.experimental.view-telemetry.enabled=true") systemProperty("collectMetadata", otelProps.collectMetadata) - systemProperty("metadataConfig", "otel.instrumentation.common.experimental.view-telemetry.enabled=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.common.experimental.view-telemetry.enabled=true", + ) } diff --git a/instrumentation/elasticsearch/elasticsearch-api-client-7.16/javaagent-unit-tests/build.gradle.kts b/instrumentation/elasticsearch/elasticsearch-api-client-7.16/javaagent-unit-tests/build.gradle.kts index 90c632beab95..402fa597fc95 100644 --- a/instrumentation/elasticsearch/elasticsearch-api-client-7.16/javaagent-unit-tests/build.gradle.kts +++ b/instrumentation/elasticsearch/elasticsearch-api-client-7.16/javaagent-unit-tests/build.gradle.kts @@ -3,6 +3,10 @@ plugins { } dependencies { - testImplementation(project(":instrumentation:elasticsearch:elasticsearch-rest-common-5.0:javaagent")) - testImplementation(project(":instrumentation:elasticsearch:elasticsearch-api-client-7.16:javaagent")) + testImplementation( + project(":instrumentation:elasticsearch:elasticsearch-rest-common-5.0:javaagent"), + ) + testImplementation( + project(":instrumentation:elasticsearch:elasticsearch-api-client-7.16:javaagent"), + ) } diff --git a/instrumentation/elasticsearch/elasticsearch-api-client-7.16/javaagent/build.gradle.kts b/instrumentation/elasticsearch/elasticsearch-api-client-7.16/javaagent/build.gradle.kts index 068fa684a474..4c025c5b29f3 100644 --- a/instrumentation/elasticsearch/elasticsearch-api-client-7.16/javaagent/build.gradle.kts +++ b/instrumentation/elasticsearch/elasticsearch-api-client-7.16/javaagent/build.gradle.kts @@ -80,7 +80,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") diff --git a/instrumentation/elasticsearch/elasticsearch-rest-5.0/javaagent/build.gradle.kts b/instrumentation/elasticsearch/elasticsearch-rest-5.0/javaagent/build.gradle.kts index b0b413950b6d..0d2786815005 100644 --- a/instrumentation/elasticsearch/elasticsearch-rest-5.0/javaagent/build.gradle.kts +++ b/instrumentation/elasticsearch/elasticsearch-rest-5.0/javaagent/build.gradle.kts @@ -46,7 +46,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") diff --git a/instrumentation/elasticsearch/elasticsearch-rest-5.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/v5_0/ElasticsearchRest5Test.java b/instrumentation/elasticsearch/elasticsearch-rest-5.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/v5_0/ElasticsearchRest5Test.java index f09442c2e680..c9de0025eaa8 100644 --- a/instrumentation/elasticsearch/elasticsearch-rest-5.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/v5_0/ElasticsearchRest5Test.java +++ b/instrumentation/elasticsearch/elasticsearch-rest-5.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/v5_0/ElasticsearchRest5Test.java @@ -66,7 +66,8 @@ static void setup() { // limit memory usage elasticsearch.withEnv( "ES_JAVA_OPTS", - "-Xmx256m -Xms256m -Dlog4j2.disableJmx=true -Dlog4j2.disable.jmx=true -XX:-UseContainerSupport"); + "-Xmx256m -Xms256m -Dlog4j2.disableJmx=true -Dlog4j2.disable.jmx=true" + + " -XX:-UseContainerSupport"); elasticsearch.start(); httpHost = HttpHost.create(elasticsearch.getHttpHostAddress()); diff --git a/instrumentation/elasticsearch/elasticsearch-rest-6.4/javaagent/build.gradle.kts b/instrumentation/elasticsearch/elasticsearch-rest-6.4/javaagent/build.gradle.kts index 9101edcea8db..625b0ae4bb38 100644 --- a/instrumentation/elasticsearch/elasticsearch-rest-6.4/javaagent/build.gradle.kts +++ b/instrumentation/elasticsearch/elasticsearch-rest-6.4/javaagent/build.gradle.kts @@ -43,7 +43,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") diff --git a/instrumentation/elasticsearch/elasticsearch-rest-6.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/v6_4/ElasticsearchRest6Test.java b/instrumentation/elasticsearch/elasticsearch-rest-6.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/v6_4/ElasticsearchRest6Test.java index 50fed3f69eca..9f20295b0907 100644 --- a/instrumentation/elasticsearch/elasticsearch-rest-6.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/v6_4/ElasticsearchRest6Test.java +++ b/instrumentation/elasticsearch/elasticsearch-rest-6.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/v6_4/ElasticsearchRest6Test.java @@ -58,7 +58,8 @@ static void setUp() { // limit memory usage elasticsearch.withEnv( "ES_JAVA_OPTS", - "-Xmx256m -Xms256m -Dlog4j2.disableJmx=true -Dlog4j2.disable.jmx=true -XX:-UseContainerSupport"); + "-Xmx256m -Xms256m -Dlog4j2.disableJmx=true -Dlog4j2.disable.jmx=true" + + " -XX:-UseContainerSupport"); elasticsearch.start(); httpHost = HttpHost.create(elasticsearch.getHttpHostAddress()); diff --git a/instrumentation/elasticsearch/elasticsearch-rest-7.0/javaagent/build.gradle.kts b/instrumentation/elasticsearch/elasticsearch-rest-7.0/javaagent/build.gradle.kts index 285f4ec79c5f..be6f96db3787 100644 --- a/instrumentation/elasticsearch/elasticsearch-rest-7.0/javaagent/build.gradle.kts +++ b/instrumentation/elasticsearch/elasticsearch-rest-7.0/javaagent/build.gradle.kts @@ -49,7 +49,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") diff --git a/instrumentation/elasticsearch/elasticsearch-rest-7.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/v7_0/ElasticsearchRest7Test.java b/instrumentation/elasticsearch/elasticsearch-rest-7.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/v7_0/ElasticsearchRest7Test.java index fe4c6e99f728..8c329ced8176 100644 --- a/instrumentation/elasticsearch/elasticsearch-rest-7.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/v7_0/ElasticsearchRest7Test.java +++ b/instrumentation/elasticsearch/elasticsearch-rest-7.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/v7_0/ElasticsearchRest7Test.java @@ -59,7 +59,8 @@ static void setUp() { // limit memory usage elasticsearch.withEnv( "ES_JAVA_OPTS", - "-Xmx256m -Xms256m -Dlog4j2.disableJmx=true -Dlog4j2.disable.jmx=true -XX:-UseContainerSupport"); + "-Xmx256m -Xms256m -Dlog4j2.disableJmx=true -Dlog4j2.disable.jmx=true" + + " -XX:-UseContainerSupport"); elasticsearch.start(); httpHost = HttpHost.create(elasticsearch.getHttpHostAddress()); diff --git a/instrumentation/elasticsearch/elasticsearch-rest-7.0/library/build.gradle.kts b/instrumentation/elasticsearch/elasticsearch-rest-7.0/library/build.gradle.kts index b91c8a2582ef..cf3294f3231b 100644 --- a/instrumentation/elasticsearch/elasticsearch-rest-7.0/library/build.gradle.kts +++ b/instrumentation/elasticsearch/elasticsearch-rest-7.0/library/build.gradle.kts @@ -17,7 +17,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database") diff --git a/instrumentation/elasticsearch/elasticsearch-rest-7.0/library/src/test/java/io/opentelemetry/instrumentation/elasticsearch/rest/v7_0/ElasticsearchRest7Test.java b/instrumentation/elasticsearch/elasticsearch-rest-7.0/library/src/test/java/io/opentelemetry/instrumentation/elasticsearch/rest/v7_0/ElasticsearchRest7Test.java index bf9463729154..2a75e68f2fb7 100644 --- a/instrumentation/elasticsearch/elasticsearch-rest-7.0/library/src/test/java/io/opentelemetry/instrumentation/elasticsearch/rest/v7_0/ElasticsearchRest7Test.java +++ b/instrumentation/elasticsearch/elasticsearch-rest-7.0/library/src/test/java/io/opentelemetry/instrumentation/elasticsearch/rest/v7_0/ElasticsearchRest7Test.java @@ -57,7 +57,8 @@ static void setUp() { // limit memory usage elasticsearch.withEnv( "ES_JAVA_OPTS", - "-Xmx256m -Xms256m -Dlog4j2.disableJmx=true -Dlog4j2.disable.jmx=true -XX:-UseContainerSupport"); + "-Xmx256m -Xms256m -Dlog4j2.disableJmx=true -Dlog4j2.disable.jmx=true" + + " -XX:-UseContainerSupport"); elasticsearch.start(); httpHost = HttpHost.create(elasticsearch.getHttpHostAddress()); diff --git a/instrumentation/elasticsearch/elasticsearch-transport-5.0/javaagent/build.gradle.kts b/instrumentation/elasticsearch/elasticsearch-transport-5.0/javaagent/build.gradle.kts index c0bf6fe755b6..26b11c508865 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-5.0/javaagent/build.gradle.kts +++ b/instrumentation/elasticsearch/elasticsearch-transport-5.0/javaagent/build.gradle.kts @@ -31,7 +31,9 @@ dependencies { testInstrumentation(project(":instrumentation:apache-httpasyncclient-4.1:javaagent")) testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent")) - testImplementation(project(":instrumentation:elasticsearch:elasticsearch-transport-common:testing")) + testImplementation( + project(":instrumentation:elasticsearch:elasticsearch-transport-common:testing"), + ) testImplementation("org.apache.logging.log4j:log4j-core:2.11.0") testImplementation("org.apache.logging.log4j:log4j-api:2.11.0") @@ -51,7 +53,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") @@ -59,11 +64,17 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.elasticsearch.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.elasticsearch.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.elasticsearch.experimental-span-attributes=true", + ) } check { diff --git a/instrumentation/elasticsearch/elasticsearch-transport-5.3/javaagent/build.gradle.kts b/instrumentation/elasticsearch/elasticsearch-transport-5.3/javaagent/build.gradle.kts index b0f28134c557..11b6c98f40fd 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-5.3/javaagent/build.gradle.kts +++ b/instrumentation/elasticsearch/elasticsearch-transport-5.3/javaagent/build.gradle.kts @@ -43,7 +43,9 @@ dependencies { testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent")) testInstrumentation(project(":instrumentation:spring:spring-data:spring-data-1.8:javaagent")) - testImplementation(project(":instrumentation:elasticsearch:elasticsearch-transport-common:testing")) + testImplementation( + project(":instrumentation:elasticsearch:elasticsearch-transport-common:testing"), + ) testImplementation("org.apache.logging.log4j:log4j-core:2.11.0") testImplementation("org.apache.logging.log4j:log4j-api:2.11.0") testImplementation("com.google.guava:guava") @@ -71,7 +73,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") @@ -79,11 +84,17 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.elasticsearch.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.elasticsearch.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.elasticsearch.experimental-span-attributes=true", + ) } check { diff --git a/instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/build.gradle.kts b/instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/build.gradle.kts index 3d17112b16bb..8c93b526bd58 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/build.gradle.kts +++ b/instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/build.gradle.kts @@ -34,7 +34,9 @@ dependencies { testLibrary("org.elasticsearch.plugin:transport-netty4-client:6.0.0") testImplementation(project(":instrumentation:elasticsearch:elasticsearch-transport-6.0:testing")) - testImplementation(project(":instrumentation:elasticsearch:elasticsearch-transport-common:testing")) + testImplementation( + project(":instrumentation:elasticsearch:elasticsearch-transport-common:testing"), + ) testImplementation("org.apache.logging.log4j:log4j-core:2.11.0") testImplementation("org.apache.logging.log4j:log4j-api:2.11.0") } @@ -50,8 +52,12 @@ testing { implementation("org.elasticsearch.client:transport:6.0.0") implementation("org.elasticsearch.plugin:transport-netty4-client:6.0.0") } - implementation(project(":instrumentation:elasticsearch:elasticsearch-transport-6.0:testing")) - implementation(project(":instrumentation:elasticsearch:elasticsearch-transport-common:testing")) + implementation( + project(":instrumentation:elasticsearch:elasticsearch-transport-6.0:testing"), + ) + implementation( + project(":instrumentation:elasticsearch:elasticsearch-transport-common:testing"), + ) } } @@ -64,8 +70,12 @@ testing { implementation("org.elasticsearch.client:transport:6.5.0") implementation("org.elasticsearch.plugin:transport-netty4-client:6.5.0") } - implementation(project(":instrumentation:elasticsearch:elasticsearch-transport-6.0:testing")) - implementation(project(":instrumentation:elasticsearch:elasticsearch-transport-common:testing")) + implementation( + project(":instrumentation:elasticsearch:elasticsearch-transport-6.0:testing"), + ) + implementation( + project(":instrumentation:elasticsearch:elasticsearch-transport-common:testing"), + ) } } @@ -78,8 +88,12 @@ testing { implementation("org.elasticsearch.client:transport:7.0.0") implementation("org.elasticsearch.plugin:transport-netty4-client:7.0.0") } - implementation(project(":instrumentation:elasticsearch:elasticsearch-transport-6.0:testing")) - implementation(project(":instrumentation:elasticsearch:elasticsearch-transport-common:testing")) + implementation( + project(":instrumentation:elasticsearch:elasticsearch-transport-6.0:testing"), + ) + implementation( + project(":instrumentation:elasticsearch:elasticsearch-transport-common:testing"), + ) } } } @@ -94,25 +108,30 @@ tasks { val testSuites = testing.suites.withType(JvmTestSuite::class) - val stableSemconvSuites = testSuites.map { suite -> - register("${suite.name}StableSemconv") { - testClassesDirs = suite.sources.output.classesDirs - classpath = suite.sources.runtimeClasspath + val stableSemconvSuites = + testSuites.map { suite -> + register("${suite.name}StableSemconv") { + testClassesDirs = suite.sources.output.classesDirs + classpath = suite.sources.runtimeClasspath - jvmArgs("-Dotel.semconv-stability.opt-in=database") - systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database") + jvmArgs("-Dotel.semconv-stability.opt-in=database") + systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database") + } } - } - - val experimentalSuites = testSuites.map { suite -> - register("${suite.name}Experimental") { - testClassesDirs = suite.sources.output.classesDirs - classpath = suite.sources.runtimeClasspath - jvmArgs("-Dotel.instrumentation.elasticsearch.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.elasticsearch.experimental-span-attributes=true") + val experimentalSuites = + testSuites.map { suite -> + register("${suite.name}Experimental") { + testClassesDirs = suite.sources.output.classesDirs + classpath = suite.sources.runtimeClasspath + + jvmArgs("-Dotel.instrumentation.elasticsearch.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.elasticsearch.experimental-span-attributes=true", + ) + } } - } check { dependsOn(testing.suites, stableSemconvSuites, experimentalSuites) diff --git a/instrumentation/executors/bootstrap/src/main/java/io/opentelemetry/javaagent/bootstrap/executors/PropagatedContext.java b/instrumentation/executors/bootstrap/src/main/java/io/opentelemetry/javaagent/bootstrap/executors/PropagatedContext.java index 7b2a895ec892..a959ee9156f1 100644 --- a/instrumentation/executors/bootstrap/src/main/java/io/opentelemetry/javaagent/bootstrap/executors/PropagatedContext.java +++ b/instrumentation/executors/bootstrap/src/main/java/io/opentelemetry/javaagent/bootstrap/executors/PropagatedContext.java @@ -33,7 +33,8 @@ void setContext(Context context) { if (currentPropagatedContext != context && logger.isLoggable(FINE)) { logger.log( FINE, - "Failed to propagate context because previous propagated context is already set; new: {0}, old: {1}", + "Failed to propagate context because previous propagated context is already set; new:" + + " {0}, old: {1}", new Object[] {context, currentPropagatedContext}); } } diff --git a/instrumentation/executors/javaagent/build.gradle.kts b/instrumentation/executors/javaagent/build.gradle.kts index fc5de9134568..4d43ac3f0bf2 100644 --- a/instrumentation/executors/javaagent/build.gradle.kts +++ b/instrumentation/executors/javaagent/build.gradle.kts @@ -52,7 +52,7 @@ tasks { jvmArgs("-XX:+IgnoreUnrecognizedVMOptions") jvmArgs( - "-Dotel.instrumentation.executors.include=io.opentelemetry.javaagent.instrumentation.executors.ExecutorInstrumentationTest\$CustomThreadPoolExecutor,io.opentelemetry.javaagent.instrumentation.executors.ThreadPoolExecutorTest\$RunnableCheckingThreadPoolExecutor" + "-Dotel.instrumentation.executors.include=io.opentelemetry.javaagent.instrumentation.executors.ExecutorInstrumentationTest\$CustomThreadPoolExecutor,io.opentelemetry.javaagent.instrumentation.executors.ThreadPoolExecutorTest\$RunnableCheckingThreadPoolExecutor", ) jvmArgs("-Djava.awt.headless=true") } diff --git a/instrumentation/executors/jdk21-testing/build.gradle.kts b/instrumentation/executors/jdk21-testing/build.gradle.kts index a6e79228bfb2..93689c3810a1 100644 --- a/instrumentation/executors/jdk21-testing/build.gradle.kts +++ b/instrumentation/executors/jdk21-testing/build.gradle.kts @@ -16,10 +16,14 @@ otelJava { // same vm version that is going to execute the test. Choose whichever is greater 21 or the // version of the vm that is going to run test val testJavaVersion = otelProps.testJavaVersion ?: JavaVersion.current() - minJavaVersionSupported.set(JavaVersion.toVersion(max( - testJavaVersion.majorVersion.toInt(), - JavaVersion.VERSION_21.majorVersion.toInt() - ))) + minJavaVersionSupported.set( + JavaVersion.toVersion( + max( + testJavaVersion.majorVersion.toInt(), + JavaVersion.VERSION_21.majorVersion.toInt(), + ), + ), + ) } tasks.withType().configureEach { diff --git a/instrumentation/external-annotations/javaagent/build.gradle.kts b/instrumentation/external-annotations/javaagent/build.gradle.kts index de53dea27fac..56a590dfcbfc 100644 --- a/instrumentation/external-annotations/javaagent/build.gradle.kts +++ b/instrumentation/external-annotations/javaagent/build.gradle.kts @@ -36,18 +36,26 @@ dependencies { tasks { val testIncludeProperty by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { includeTestsMatching("ConfiguredTraceAnnotationsTest") } include("**/ConfiguredTraceAnnotationsTest.*") - jvmArgs("-Dotel.instrumentation.external-annotations.include=io.opentelemetry.javaagent.instrumentation.extannotations.OuterClass\$InterestingMethod") + jvmArgs( + "-Dotel.instrumentation.external-annotations.include=io.opentelemetry.javaagent.instrumentation.extannotations.OuterClass\$InterestingMethod", + ) } val testDeclarativeConfigInclude by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { @@ -55,12 +63,15 @@ tasks { } include("**/ConfiguredTraceAnnotationsTest.*") jvmArgs( - "-Dotel.config.file=$projectDir/src/test/resources/declarative-config-include.yaml" + "-Dotel.config.file=$projectDir/src/test/resources/declarative-config-include.yaml", ) } val testExcludeMethodsProperty by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { @@ -68,12 +79,15 @@ tasks { } include("**/TracedMethodsExclusionTest.*") jvmArgs( - "-Dotel.instrumentation.external-annotations.exclude-methods=io.opentelemetry.javaagent.instrumentation.extannotations.TracedMethodsExclusionTest\$TestClass[excluded,annotatedButExcluded]" + "-Dotel.instrumentation.external-annotations.exclude-methods=io.opentelemetry.javaagent.instrumentation.extannotations.TracedMethodsExclusionTest\$TestClass[excluded,annotatedButExcluded]", ) } val testDeclarativeConfigExcludeMethods by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { @@ -81,7 +95,7 @@ tasks { } include("**/TracedMethodsExclusionTest.*") jvmArgs( - "-Dotel.config.file=$projectDir/src/test/resources/declarative-config-exclude-methods.yaml" + "-Dotel.config.file=$projectDir/src/test/resources/declarative-config-exclude-methods.yaml", ) } @@ -93,6 +107,11 @@ tasks { } check { - dependsOn(testIncludeProperty, testExcludeMethodsProperty, testDeclarativeConfigInclude, testDeclarativeConfigExcludeMethods) + dependsOn( + testIncludeProperty, + testExcludeMethodsProperty, + testDeclarativeConfigInclude, + testDeclarativeConfigExcludeMethods, + ) } } diff --git a/instrumentation/finagle-http-23.11/javaagent/build.gradle.kts b/instrumentation/finagle-http-23.11/javaagent/build.gradle.kts index 0e704795293d..cd0f71e1db87 100644 --- a/instrumentation/finagle-http-23.11/javaagent/build.gradle.kts +++ b/instrumentation/finagle-http-23.11/javaagent/build.gradle.kts @@ -20,10 +20,11 @@ muzzle { val finagleVersion = "23.11.0" val scalaVersion = "2.13.10" -val scalaMinor = Regex("""^([0-9]+\.[0-9]+)\.?.*$""").find(scalaVersion)!!.run { - val (minorVersion) = this.destructured - minorVersion -} +val scalaMinor = + Regex("""^([0-9]+\.[0-9]+)\.?.*$""").find(scalaVersion)!!.run { + val (minorVersion) = this.destructured + minorVersion + } val scalified = fun(pack: String): String = "${pack}_$scalaMinor" @@ -52,12 +53,15 @@ tasks { systemProperty( "metadataConfig", "otel.instrumentation.http.client.emit-experimental-telemetry=true," + - "otel.instrumentation.http.server.emit-experimental-telemetry=true" + "otel.instrumentation.http.server.emit-experimental-telemetry=true", ) } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.http.client.emit-experimental-telemetry=true") jvmArgs("-Dotel.instrumentation.http.server.emit-experimental-telemetry=true") @@ -66,7 +70,7 @@ tasks { "metadataConfig", "otel.instrumentation.http.client.emit-experimental-telemetry=true," + "otel.instrumentation.http.server.emit-experimental-telemetry=true," + - "otel.semconv-stability.opt-in=service.peer" + "otel.semconv-stability.opt-in=service.peer", ) } diff --git a/instrumentation/finatra-2.9/javaagent/build.gradle.kts b/instrumentation/finatra-2.9/javaagent/build.gradle.kts index d91407229c04..70fd3594071e 100644 --- a/instrumentation/finatra-2.9/javaagent/build.gradle.kts +++ b/instrumentation/finatra-2.9/javaagent/build.gradle.kts @@ -89,7 +89,10 @@ tasks { jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true") systemProperty("collectMetadata", otelProps.collectMetadata) - systemProperty("metadataConfig", "otel.instrumentation.common.experimental.controller-telemetry.enabled=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.common.experimental.controller-telemetry.enabled=true", + ) } if (otelProps.denyUnsafe) { diff --git a/instrumentation/geode-1.4/javaagent/build.gradle.kts b/instrumentation/geode-1.4/javaagent/build.gradle.kts index 46043b4f4ce7..116a39466b10 100644 --- a/instrumentation/geode-1.4/javaagent/build.gradle.kts +++ b/instrumentation/geode-1.4/javaagent/build.gradle.kts @@ -25,7 +25,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") diff --git a/instrumentation/google-http-client-1.19/javaagent/build.gradle.kts b/instrumentation/google-http-client-1.19/javaagent/build.gradle.kts index 6c574dd982b1..00578f0094dc 100644 --- a/instrumentation/google-http-client-1.19/javaagent/build.gradle.kts +++ b/instrumentation/google-http-client-1.19/javaagent/build.gradle.kts @@ -23,7 +23,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/grails-3.0/javaagent/build.gradle.kts b/instrumentation/grails-3.0/javaagent/build.gradle.kts index 861b78c6b921..8404e86a58b7 100644 --- a/instrumentation/grails-3.0/javaagent/build.gradle.kts +++ b/instrumentation/grails-3.0/javaagent/build.gradle.kts @@ -57,7 +57,7 @@ spotless { target("src/**/*.groovy") licenseHeaderFile( rootProject.file("buildscripts/spotless.license.java"), - "(package|import|(?:abstract )?class)" + "(package|import|(?:abstract )?class)", ) endWithNewline() } @@ -73,7 +73,10 @@ tasks { jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true") systemProperty("collectMetadata", otelProps.collectMetadata) - systemProperty("metadataConfig", "otel.instrumentation.common.experimental.controller-telemetry.enabled=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.common.experimental.controller-telemetry.enabled=true", + ) } if (otelProps.denyUnsafe) { diff --git a/instrumentation/graphql-java/graphql-java-20.0/javaagent/build.gradle.kts b/instrumentation/graphql-java/graphql-java-20.0/javaagent/build.gradle.kts index e1e8a9a1f7fa..748b24effee0 100644 --- a/instrumentation/graphql-java/graphql-java-20.0/javaagent/build.gradle.kts +++ b/instrumentation/graphql-java/graphql-java-20.0/javaagent/build.gradle.kts @@ -30,7 +30,10 @@ tasks { } val testDataFetcher by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.graphql.data-fetcher.enabled=true") diff --git a/instrumentation/graphql-java/graphql-java-20.0/library/src/test/java/io/opentelemetry/instrumentation/graphql/v20_0/GraphqlTest.java b/instrumentation/graphql-java/graphql-java-20.0/library/src/test/java/io/opentelemetry/instrumentation/graphql/v20_0/GraphqlTest.java index d6f5e150e55c..f51fde0a8da5 100644 --- a/instrumentation/graphql-java/graphql-java-20.0/library/src/test/java/io/opentelemetry/instrumentation/graphql/v20_0/GraphqlTest.java +++ b/instrumentation/graphql-java/graphql-java-20.0/library/src/test/java/io/opentelemetry/instrumentation/graphql/v20_0/GraphqlTest.java @@ -295,7 +295,8 @@ void dataFetcherException() { equalTo(EXCEPTION_TYPE, "DataFetchingException"), equalTo( EXCEPTION_MESSAGE, - "Exception while fetching data (/bookById) : fetching book failed"))), + "Exception while fetching data (/bookById) : fetching" + + " book failed"))), span -> span.hasName("bookById") .hasKind(SpanKind.INTERNAL) diff --git a/instrumentation/graphql-java/graphql-java-common-12.0/testing/src/main/java/io/opentelemetry/instrumentation/graphql/common/v12_0/AbstractGraphqlTest.java b/instrumentation/graphql-java/graphql-java-common-12.0/testing/src/main/java/io/opentelemetry/instrumentation/graphql/common/v12_0/AbstractGraphqlTest.java index cd23e0f1927b..bd8aca4c2e7a 100644 --- a/instrumentation/graphql-java/graphql-java-common-12.0/testing/src/main/java/io/opentelemetry/instrumentation/graphql/common/v12_0/AbstractGraphqlTest.java +++ b/instrumentation/graphql-java/graphql-java-common-12.0/testing/src/main/java/io/opentelemetry/instrumentation/graphql/common/v12_0/AbstractGraphqlTest.java @@ -282,12 +282,7 @@ void validationError() { // spotless:off ExecutionResult result = graphql.execute( - "" - + " query {\n" - + " book(id: \"a\") {\n" - + " name\n" - + " }\n" - + " }"); + "" + " query {\n" + " book(id: \"a\") {\n" + " name\n" + " }\n" + " }"); // spotless:on assertThat(result.getErrors()).hasSize(1); @@ -340,7 +335,8 @@ void successfulMutation() { equalTo(GRAPHQL_OPERATION_TYPE, "mutation"), normalizedQueryEqualsTo( GRAPHQL_DOCUMENT, - "mutation addNewBook { addBook(id: ?, name: ?, author: ?) { id } }")))); + "mutation addNewBook { addBook(id: ?, name: ?, author: ?) { id" + + " } }")))); } protected static AttributeAssertion normalizedQueryEqualsTo( diff --git a/instrumentation/grizzly-2.3/javaagent/build.gradle.kts b/instrumentation/grizzly-2.3/javaagent/build.gradle.kts index 4e92baae8591..d9a7a076d04c 100644 --- a/instrumentation/grizzly-2.3/javaagent/build.gradle.kts +++ b/instrumentation/grizzly-2.3/javaagent/build.gradle.kts @@ -37,4 +37,7 @@ tasks { } // Requires old Guava. Can't use enforcedPlatform since predates BOM -configurations.testRuntimeClasspath.get().resolutionStrategy.force("com.google.guava:guava:19.0") +configurations.testRuntimeClasspath + .get() + .resolutionStrategy + .force("com.google.guava:guava:19.0") diff --git a/instrumentation/grpc-1.6/javaagent/build.gradle.kts b/instrumentation/grpc-1.6/javaagent/build.gradle.kts index 35e4896be313..e8e26d6df28d 100644 --- a/instrumentation/grpc-1.6/javaagent/build.gradle.kts +++ b/instrumentation/grpc-1.6/javaagent/build.gradle.kts @@ -42,50 +42,63 @@ tasks { // exclude our grpc library instrumentation, the ContextStorageOverride contained within it // breaks the tests - classpath = classpath.filter { - !it.absolutePath.contains("opentelemetry-grpc-1.6") - } + classpath = + classpath.filter { + !it.absolutePath.contains("opentelemetry-grpc-1.6") + } systemProperty("collectMetadata", otelProps.collectMetadata) } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath // exclude our grpc library instrumentation, the ContextStorageOverride contained within it // breaks the tests - classpath = classpath.filter { - !it.absolutePath.contains("opentelemetry-grpc-1.6") - } + classpath = + classpath.filter { + !it.absolutePath.contains("opentelemetry-grpc-1.6") + } systemProperty("metadataConfig", "otel.instrumentation.grpc.experimental-span-attributes=true") jvmArgs("-Dotel.instrumentation.grpc.experimental-span-attributes=true") } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath // exclude our grpc library instrumentation, the ContextStorageOverride contained within it // breaks the tests - classpath = classpath.filter { - !it.absolutePath.contains("opentelemetry-grpc-1.6") - } + classpath = + classpath.filter { + !it.absolutePath.contains("opentelemetry-grpc-1.6") + } jvmArgs("-Dotel.semconv-stability.opt-in=rpc") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=rpc") } val testBothSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath // exclude our grpc library instrumentation, the ContextStorageOverride contained within it // breaks the tests - classpath = classpath.filter { - !it.absolutePath.contains("opentelemetry-grpc-1.6") - } + classpath = + classpath.filter { + !it.absolutePath.contains("opentelemetry-grpc-1.6") + } jvmArgs("-Dotel.semconv-stability.opt-in=rpc/dup") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=rpc/dup") diff --git a/instrumentation/grpc-1.6/library/build.gradle.kts b/instrumentation/grpc-1.6/library/build.gradle.kts index 46c4ad5a3ff7..105b19b34ef4 100644 --- a/instrumentation/grpc-1.6/library/build.gradle.kts +++ b/instrumentation/grpc-1.6/library/build.gradle.kts @@ -25,14 +25,20 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=rpc") } val testBothSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=rpc/dup") diff --git a/instrumentation/guava-10.0/javaagent/build.gradle.kts b/instrumentation/guava-10.0/javaagent/build.gradle.kts index a432aa870111..273a48a04225 100644 --- a/instrumentation/guava-10.0/javaagent/build.gradle.kts +++ b/instrumentation/guava-10.0/javaagent/build.gradle.kts @@ -29,21 +29,30 @@ dependencies { tasks { val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=code") } val testBothSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=code/dup") } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.guava.experimental-span-attributes=true") diff --git a/instrumentation/gwt-2.0/javaagent/build.gradle.kts b/instrumentation/gwt-2.0/javaagent/build.gradle.kts index c7b3acadd5d0..dca272691f71 100644 --- a/instrumentation/gwt-2.0/javaagent/build.gradle.kts +++ b/instrumentation/gwt-2.0/javaagent/build.gradle.kts @@ -55,24 +55,30 @@ dependencies { val warDir = layout.buildDirectory.dir("testapp/war") -val launcher = javaToolchains.launcherFor { - languageVersion.set(JavaLanguageVersion.of(8)) -} +val launcher = + javaToolchains.launcherFor { + languageVersion.set(JavaLanguageVersion.of(8)) + } class CompilerArgumentsProvider( - private val buildDir: Directory + private val buildDir: Directory, ) : CommandLineArgumentProvider { - override fun asArguments(): Iterable = listOf( - // gwt module - "test.gwt.Greeting", - "-war", buildDir.dir("testapp/war").asFile.absolutePath, - "-logLevel", "INFO", - "-localWorkers", "2", - "-compileReport", - "-extra", buildDir.dir("testapp/extra").asFile.absolutePath, - // makes compile a bit faster - "-draftCompile", - ) + override fun asArguments(): Iterable = + listOf( + // gwt module + "test.gwt.Greeting", + "-war", + buildDir.dir("testapp/war").asFile.absolutePath, + "-logLevel", + "INFO", + "-localWorkers", + "2", + "-compileReport", + "-extra", + buildDir.dir("testapp/extra").asFile.absolutePath, + // makes compile a bit faster + "-draftCompile", + ) } tasks { @@ -91,9 +97,11 @@ tasks { argumentProviders.add(CompilerArgumentsProvider(layout.buildDirectory.get())) if (otelProps.testLatestDeps) { - javaLauncher.set(project.javaToolchains.launcherFor { - languageVersion = JavaLanguageVersion.of(11) - }) + javaLauncher.set( + project.javaToolchains.launcherFor { + languageVersion = JavaLanguageVersion.of(11) + }, + ) } } @@ -111,7 +119,10 @@ tasks { dependsOn(copyTestWebapp) // add test app classes to classpath - classpath = sourceSets.test.get().runtimeClasspath.plus(files(layout.buildDirectory.dir("testapp/classes"))) + classpath = + sourceSets.test.get().runtimeClasspath.plus( + files(layout.buildDirectory.dir("testapp/classes")), + ) } } diff --git a/instrumentation/hibernate/hibernate-3.3/javaagent/build.gradle.kts b/instrumentation/hibernate/hibernate-3.3/javaagent/build.gradle.kts index a4489ba4db8d..81b7172b2c66 100644 --- a/instrumentation/hibernate/hibernate-3.3/javaagent/build.gradle.kts +++ b/instrumentation/hibernate/hibernate-3.3/javaagent/build.gradle.kts @@ -60,22 +60,30 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.hibernate.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.hibernate.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.hibernate.experimental-span-attributes=true", + ) } - val stableSemconvSuites = testing.suites.withType(JvmTestSuite::class) - .map { suite -> - register("${suite.name}StableSemconv") { - testClassesDirs = suite.sources.output.classesDirs - classpath = suite.sources.runtimeClasspath + val stableSemconvSuites = + testing.suites + .withType(JvmTestSuite::class) + .map { suite -> + register("${suite.name}StableSemconv") { + testClassesDirs = suite.sources.output.classesDirs + classpath = suite.sources.runtimeClasspath - jvmArgs("-Dotel.semconv-stability.opt-in=database") + jvmArgs("-Dotel.semconv-stability.opt-in=database") + } } - } check { dependsOn(testing.suites, testExperimental, stableSemconvSuites) diff --git a/instrumentation/hibernate/hibernate-3.3/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v3_3/QueryTest.java b/instrumentation/hibernate/hibernate-3.3/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v3_3/QueryTest.java index 377439d50dbb..80b9d3706653 100644 --- a/instrumentation/hibernate/hibernate-3.3/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v3_3/QueryTest.java +++ b/instrumentation/hibernate/hibernate-3.3/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v3_3/QueryTest.java @@ -80,7 +80,8 @@ private static Stream provideArguments() { sess -> { Query q = sess.createQuery( - "from io.opentelemetry.javaagent.instrumentation.hibernate.v3_3.Value where id = ?"); + "from io.opentelemetry.javaagent.instrumentation.hibernate.v3_3.Value" + + " where id = ?"); q.setParameter(0, 1L); q.list(); }))), @@ -93,7 +94,9 @@ private static Stream provideArguments() { sess -> { Query q = sess.createQuery( - "update io.opentelemetry.javaagent.instrumentation.hibernate.v3_3.Value set name = ?"); + "update" + + " io.opentelemetry.javaagent.instrumentation.hibernate.v3_3.Value" + + " set name = ?"); q.setParameter(0, "alyx"); q.executeUpdate(); }))), @@ -106,7 +109,8 @@ private static Stream provideArguments() { sess -> { Query q = sess.createQuery( - "from io.opentelemetry.javaagent.instrumentation.hibernate.v3_3.Value where id = ?"); + "from io.opentelemetry.javaagent.instrumentation.hibernate.v3_3.Value" + + " where id = ?"); q.setParameter(0, 1L); q.uniqueResult(); }))), diff --git a/instrumentation/hibernate/hibernate-3.3/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v3_3/SessionTest.java b/instrumentation/hibernate/hibernate-3.3/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v3_3/SessionTest.java index 69910687d84c..65405cf7d790 100644 --- a/instrumentation/hibernate/hibernate-3.3/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v3_3/SessionTest.java +++ b/instrumentation/hibernate/hibernate-3.3/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v3_3/SessionTest.java @@ -263,22 +263,26 @@ void testHibernateOverlappingSessions() { assertSessionSpan( span, trace.getSpan(0), - "Session.save io.opentelemetry.javaagent.instrumentation.hibernate.v3_3.Value"), + "Session.save" + + " io.opentelemetry.javaagent.instrumentation.hibernate.v3_3.Value"), span -> assertSessionSpan( span, trace.getSpan(0), - "Session.insert io.opentelemetry.javaagent.instrumentation.hibernate.v3_3.Value"), + "Session.insert" + + " io.opentelemetry.javaagent.instrumentation.hibernate.v3_3.Value"), span -> assertSessionSpan( span, trace.getSpan(0), - "Session.save io.opentelemetry.javaagent.instrumentation.hibernate.v3_3.Value"), + "Session.save" + + " io.opentelemetry.javaagent.instrumentation.hibernate.v3_3.Value"), span -> assertSpanWithSessionId( span, trace.getSpan(0), - "Session.delete io.opentelemetry.javaagent.instrumentation.hibernate.v3_3.Value", + "Session.delete" + + " io.opentelemetry.javaagent.instrumentation.hibernate.v3_3.Value", trace.getSpan(1).getAttributes().get(HIBERNATE_SESSION_ID)), span -> assertSpanWithSessionId( diff --git a/instrumentation/hibernate/hibernate-4.0/javaagent/build.gradle.kts b/instrumentation/hibernate/hibernate-4.0/javaagent/build.gradle.kts index 7675f89e5309..b8003935cb79 100644 --- a/instrumentation/hibernate/hibernate-4.0/javaagent/build.gradle.kts +++ b/instrumentation/hibernate/hibernate-4.0/javaagent/build.gradle.kts @@ -44,7 +44,10 @@ testing { targets.all { testTask.configure { jvmArgs("-Dotel.instrumentation.hibernate.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.hibernate.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.hibernate.experimental-span-attributes=true", + ) } } dependencies { @@ -90,23 +93,31 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.hibernate.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.hibernate.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.hibernate.experimental-span-attributes=true", + ) } - val stableSemconvSuites = testing.suites.withType(JvmTestSuite::class) - .map { suite -> - register("${suite.name}StableSemconv") { - testClassesDirs = suite.sources.output.classesDirs - classpath = suite.sources.runtimeClasspath + val stableSemconvSuites = + testing.suites + .withType(JvmTestSuite::class) + .map { suite -> + register("${suite.name}StableSemconv") { + testClassesDirs = suite.sources.output.classesDirs + classpath = suite.sources.runtimeClasspath - jvmArgs("-Dotel.semconv-stability.opt-in=database") - systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database") + jvmArgs("-Dotel.semconv-stability.opt-in=database") + systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database") + } } - } check { dependsOn(testing.suites, testExperimental, stableSemconvSuites) diff --git a/instrumentation/hibernate/hibernate-4.0/javaagent/src/test/java/spring/jpa/SpringJpaTest.java b/instrumentation/hibernate/hibernate-4.0/javaagent/src/test/java/spring/jpa/SpringJpaTest.java index 1b361c84c857..90492594f583 100644 --- a/instrumentation/hibernate/hibernate-4.0/javaagent/src/test/java/spring/jpa/SpringJpaTest.java +++ b/instrumentation/hibernate/hibernate-4.0/javaagent/src/test/java/spring/jpa/SpringJpaTest.java @@ -91,7 +91,8 @@ void testCrud() { val -> val.matches( Pattern.compile( - "select ([^.]+).id([^,]*), ([^.]+).firstName([^,]*), ([^.]+).lastName(.*)from Customer(.*)"))), + "select ([^.]+).id([^,]*), ([^.]+).firstName([^,]*)," + + " ([^.]+).lastName(.*)from Customer(.*)"))), equalTo( DB_QUERY_SUMMARY, emitStableDatabaseSemconv() ? "SELECT Customer" : null), @@ -159,7 +160,8 @@ void testCrud() { val -> val.matches( Pattern.compile( - "insert into Customer (.*) values \\(.*, \\?, \\?\\)"))), + "insert into Customer (.*) values \\(.*, \\?," + + " \\?\\)"))), equalTo( DB_QUERY_SUMMARY, emitStableDatabaseSemconv() ? "INSERT Customer" : null), @@ -307,7 +309,9 @@ void testCrud() { val -> val.matches( Pattern.compile( - "select ([^.]+).id([^,]*), ([^.]+).firstName([^,]*), ([^.]+).lastName (.*)from Customer (.*)where ([^.]+).id=\\?"))), + "select ([^.]+).id([^,]*), ([^.]+).firstName([^,]*)," + + " ([^.]+).lastName (.*)from Customer (.*)where" + + " ([^.]+).id=\\?"))), equalTo( DB_QUERY_SUMMARY, emitStableDatabaseSemconv() ? "SELECT Customer" : null), @@ -398,7 +402,9 @@ void testCrud() { val -> val.matches( Pattern.compile( - "select ([^.]+).id([^,]*), ([^.]+).firstName([^,]*), ([^.]+).lastName (.*)from Customer (.*)(where ([^.]+).lastName=\\?)"))), + "select ([^.]+).id([^,]*), ([^.]+).firstName([^,]*)," + + " ([^.]+).lastName (.*)from Customer (.*)(where" + + " ([^.]+).lastName=\\?)"))), equalTo( DB_QUERY_SUMMARY, emitStableDatabaseSemconv() ? "SELECT Customer" : null), @@ -448,7 +454,9 @@ void testCrud() { val -> val.matches( Pattern.compile( - "select ([^.]+).id([^,]*), ([^.]+).firstName([^,]*), ([^.]+).lastName (.*)from Customer (.*)where ([^.]+).id=\\?"))), + "select ([^.]+).id([^,]*), ([^.]+).firstName([^,]*)," + + " ([^.]+).lastName (.*)from Customer (.*)where" + + " ([^.]+).id=\\?"))), equalTo( DB_QUERY_SUMMARY, emitStableDatabaseSemconv() ? "SELECT Customer" : null), @@ -535,7 +543,9 @@ void testCrud() { val -> val.matches( Pattern.compile( - "select ([^.]+).id([^,]*), ([^.]+).firstName([^,]*), ([^.]+).lastName (.*)from Customer (.*)where ([^.]+).id=\\?"))), + "select ([^.]+).id([^,]*), ([^.]+).firstName([^,]*)," + + " ([^.]+).lastName (.*)from Customer (.*)where" + + " ([^.]+).id=\\?"))), equalTo( DB_QUERY_SUMMARY, emitStableDatabaseSemconv() ? "SELECT Customer" : null), diff --git a/instrumentation/hibernate/hibernate-6.0/javaagent/build.gradle.kts b/instrumentation/hibernate/hibernate-6.0/javaagent/build.gradle.kts index d705b26d69e0..0e8af8f9928f 100644 --- a/instrumentation/hibernate/hibernate-6.0/javaagent/build.gradle.kts +++ b/instrumentation/hibernate/hibernate-6.0/javaagent/build.gradle.kts @@ -42,7 +42,10 @@ testing { targets.all { testTask.configure { jvmArgs("-Dotel.instrumentation.hibernate.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.hibernate.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.hibernate.experimental-span-attributes=true", + ) } } dependencies { @@ -61,7 +64,10 @@ testing { targets.all { testTask.configure { jvmArgs("-Dotel.instrumentation.hibernate.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.hibernate.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.hibernate.experimental-span-attributes=true", + ) } } dependencies { @@ -94,23 +100,31 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.hibernate.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.hibernate.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.hibernate.experimental-span-attributes=true", + ) } - val stableSemconvSuites = testing.suites.withType(JvmTestSuite::class) - .map { suite -> - register("${suite.name}StableSemconv") { - testClassesDirs = suite.sources.output.classesDirs - classpath = suite.sources.runtimeClasspath + val stableSemconvSuites = + testing.suites + .withType(JvmTestSuite::class) + .map { suite -> + register("${suite.name}StableSemconv") { + testClassesDirs = suite.sources.output.classesDirs + classpath = suite.sources.runtimeClasspath - jvmArgs("-Dotel.semconv-stability.opt-in=database") - systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database") + jvmArgs("-Dotel.semconv-stability.opt-in=database") + systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database") + } } - } if (!testJavaVersion.isCompatibleWith(JavaVersion.VERSION_17)) { named("hibernate7TestStableSemconv", Test::class).configure { diff --git a/instrumentation/hibernate/hibernate-6.0/javaagent/src/hibernate6Test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v6_0/ProcedureCallTest.java b/instrumentation/hibernate/hibernate-6.0/javaagent/src/hibernate6Test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v6_0/ProcedureCallTest.java index c42828715149..b95e40b39407 100644 --- a/instrumentation/hibernate/hibernate-6.0/javaagent/src/hibernate6Test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v6_0/ProcedureCallTest.java +++ b/instrumentation/hibernate/hibernate-6.0/javaagent/src/hibernate6Test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v6_0/ProcedureCallTest.java @@ -70,7 +70,8 @@ static void setup() throws SQLException { Connection conn = DriverManager.getConnection("jdbc:hsqldb:mem:test", "sa", "1"); Statement stmt = conn.createStatement(); stmt.execute( - "CREATE PROCEDURE TEST_PROC() MODIFIES SQL DATA BEGIN ATOMIC INSERT INTO Value VALUES (420, 'fred'); END"); + "CREATE PROCEDURE TEST_PROC() MODIFIES SQL DATA BEGIN ATOMIC INSERT INTO Value VALUES (420," + + " 'fred'); END"); stmt.close(); conn.close(); } diff --git a/instrumentation/hibernate/hibernate-6.0/javaagent/src/hibernate6Test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v6_0/SessionTest.java b/instrumentation/hibernate/hibernate-6.0/javaagent/src/hibernate6Test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v6_0/SessionTest.java index 738654195dce..8c0d03157b32 100644 --- a/instrumentation/hibernate/hibernate-6.0/javaagent/src/hibernate6Test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v6_0/SessionTest.java +++ b/instrumentation/hibernate/hibernate-6.0/javaagent/src/hibernate6Test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v6_0/SessionTest.java @@ -304,7 +304,8 @@ void testHibernateOverlappingSessions() { assertSessionSpan( span, trace.getSpan(0), - "Session.save io.opentelemetry.javaagent.instrumentation.hibernate.v6_0.Value"); + "Session.save" + + " io.opentelemetry.javaagent.instrumentation.hibernate.v6_0.Value"); sessionId1.set( trace.getSpan(1).getAttributes().get(stringKey("hibernate.session_id"))); }, @@ -312,7 +313,8 @@ void testHibernateOverlappingSessions() { assertSessionSpan( span, trace.getSpan(0), - "Session.insert io.opentelemetry.javaagent.instrumentation.hibernate.v6_0.Value"); + "Session.insert" + + " io.opentelemetry.javaagent.instrumentation.hibernate.v6_0.Value"); sessionId2.set( trace.getSpan(2).getAttributes().get(stringKey("hibernate.session_id"))); }, @@ -321,7 +323,8 @@ void testHibernateOverlappingSessions() { assertSessionSpan( span, trace.getSpan(0), - "Session.save io.opentelemetry.javaagent.instrumentation.hibernate.v6_0.Value"); + "Session.save" + + " io.opentelemetry.javaagent.instrumentation.hibernate.v6_0.Value"); sessionId3.set( trace.getSpan(4).getAttributes().get(stringKey("hibernate.session_id"))); }, @@ -329,7 +332,8 @@ void testHibernateOverlappingSessions() { assertSpanWithSessionId( span, trace.getSpan(0), - "Session.delete io.opentelemetry.javaagent.instrumentation.hibernate.v6_0.Value", + "Session.delete" + + " io.opentelemetry.javaagent.instrumentation.hibernate.v6_0.Value", sessionId1.get()), span -> assertSpanWithSessionId( diff --git a/instrumentation/hibernate/hibernate-6.0/javaagent/src/hibernate7Test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v7_0/ProcedureCallTest.java b/instrumentation/hibernate/hibernate-6.0/javaagent/src/hibernate7Test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v7_0/ProcedureCallTest.java index c4bc48c8ee31..c62fed7045c9 100644 --- a/instrumentation/hibernate/hibernate-6.0/javaagent/src/hibernate7Test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v7_0/ProcedureCallTest.java +++ b/instrumentation/hibernate/hibernate-6.0/javaagent/src/hibernate7Test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v7_0/ProcedureCallTest.java @@ -70,7 +70,8 @@ static void setup() throws SQLException { Connection conn = DriverManager.getConnection("jdbc:hsqldb:mem:test", "sa", "1"); Statement stmt = conn.createStatement(); stmt.execute( - "CREATE PROCEDURE TEST_PROC() MODIFIES SQL DATA BEGIN ATOMIC INSERT INTO Value VALUES (420, 'fred'); END"); + "CREATE PROCEDURE TEST_PROC() MODIFIES SQL DATA BEGIN ATOMIC INSERT INTO Value VALUES (420," + + " 'fred'); END"); stmt.close(); conn.close(); } diff --git a/instrumentation/hibernate/hibernate-6.0/javaagent/src/hibernate7Test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v7_0/SessionTest.java b/instrumentation/hibernate/hibernate-6.0/javaagent/src/hibernate7Test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v7_0/SessionTest.java index b0650893d25c..58dd24b82608 100644 --- a/instrumentation/hibernate/hibernate-6.0/javaagent/src/hibernate7Test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v7_0/SessionTest.java +++ b/instrumentation/hibernate/hibernate-6.0/javaagent/src/hibernate7Test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v7_0/SessionTest.java @@ -315,7 +315,8 @@ void testHibernateOverlappingSessions() { assertSessionSpan( span, trace.getSpan(0), - "Session.merge io.opentelemetry.javaagent.instrumentation.hibernate.v7_0.Value"); + "Session.merge" + + " io.opentelemetry.javaagent.instrumentation.hibernate.v7_0.Value"); sessionId1.set( trace.getSpan(1).getAttributes().get(stringKey("hibernate.session_id"))); }, @@ -323,7 +324,8 @@ void testHibernateOverlappingSessions() { assertSessionSpan( span, trace.getSpan(0), - "Session.insert io.opentelemetry.javaagent.instrumentation.hibernate.v7_0.Value"); + "Session.insert" + + " io.opentelemetry.javaagent.instrumentation.hibernate.v7_0.Value"); sessionId2.set( trace.getSpan(2).getAttributes().get(stringKey("hibernate.session_id"))); }, @@ -332,7 +334,8 @@ void testHibernateOverlappingSessions() { assertSessionSpan( span, trace.getSpan(0), - "Session.merge io.opentelemetry.javaagent.instrumentation.hibernate.v7_0.Value"); + "Session.merge" + + " io.opentelemetry.javaagent.instrumentation.hibernate.v7_0.Value"); sessionId3.set( trace.getSpan(4).getAttributes().get(stringKey("hibernate.session_id"))); }, @@ -340,7 +343,8 @@ void testHibernateOverlappingSessions() { assertSpanWithSessionId( span, trace.getSpan(0), - "Session.remove io.opentelemetry.javaagent.instrumentation.hibernate.v7_0.Value", + "Session.remove" + + " io.opentelemetry.javaagent.instrumentation.hibernate.v7_0.Value", sessionId1.get()), span -> assertSpanWithSessionId( diff --git a/instrumentation/hibernate/hibernate-6.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v6_0/CriteriaTest.java b/instrumentation/hibernate/hibernate-6.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v6_0/CriteriaTest.java index 32bfcbc3590e..0788b1db46c5 100644 --- a/instrumentation/hibernate/hibernate-6.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v6_0/CriteriaTest.java +++ b/instrumentation/hibernate/hibernate-6.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v6_0/CriteriaTest.java @@ -78,7 +78,8 @@ void testCriteriaQuery(Consumer> interaction) { span -> span.hasName("parent").hasKind(SpanKind.INTERNAL).hasNoParent(), span -> span.hasName( - "SELECT io.opentelemetry.javaagent.instrumentation.hibernate.v6_0.Value") + "SELECT" + + " io.opentelemetry.javaagent.instrumentation.hibernate.v6_0.Value") .hasKind(SpanKind.INTERNAL) .hasParent(trace.getSpan(0)) .hasAttributesSatisfyingExactly( diff --git a/instrumentation/hibernate/hibernate-6.0/spring-testing/build.gradle.kts b/instrumentation/hibernate/hibernate-6.0/spring-testing/build.gradle.kts index db05f8d86b17..efa572c126cc 100644 --- a/instrumentation/hibernate/hibernate-6.0/spring-testing/build.gradle.kts +++ b/instrumentation/hibernate/hibernate-6.0/spring-testing/build.gradle.kts @@ -33,7 +33,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") diff --git a/instrumentation/hibernate/hibernate-6.0/spring-testing/src/test/java/spring/jpa/SpringJpaTest.java b/instrumentation/hibernate/hibernate-6.0/spring-testing/src/test/java/spring/jpa/SpringJpaTest.java index 580f60dfc151..48f76a7a0c66 100644 --- a/instrumentation/hibernate/hibernate-6.0/spring-testing/src/test/java/spring/jpa/SpringJpaTest.java +++ b/instrumentation/hibernate/hibernate-6.0/spring-testing/src/test/java/spring/jpa/SpringJpaTest.java @@ -94,7 +94,9 @@ void testCrud() { maybeStable(DB_STATEMENT), val -> val.matches( - "select ([^.]+)\\.id([^,]*),([^.]+)\\.firstName([^,]*),([^.]+)\\.lastName(.*)from Customer(.*)")), + "select" + + " ([^.]+)\\.id([^,]*),([^.]+)\\.firstName([^,]*),([^.]+)\\.lastName(.*)from" + + " Customer(.*)")), equalTo( DB_QUERY_SUMMARY, emitStableDatabaseSemconv() ? "SELECT Customer" : null), @@ -234,7 +236,10 @@ void testCrud() { maybeStable(DB_STATEMENT), val -> val.matches( - "select ([^.]+)\\.id([^,]*),([^.]+)\\.firstName([^,]*),([^.]+)\\.lastName (.*)from Customer (.*)where ([^.]+)\\.id( ?)=( ?)\\?")), + "select" + + " ([^.]+)\\.id([^,]*),([^.]+)\\.firstName([^,]*),([^.]+)\\.lastName" + + " (.*)from Customer (.*)where ([^.]+)\\.id( ?)=(" + + " ?)\\?")), equalTo( DB_QUERY_SUMMARY, emitStableDatabaseSemconv() ? "SELECT Customer" : null), @@ -272,7 +277,8 @@ void testCrud() { maybeStable(DB_STATEMENT), val -> val.matches( - "update Customer set firstName=\\?,(.*)lastName=\\? where id=\\?")), + "update Customer set firstName=\\?,(.*)lastName=\\? where" + + " id=\\?")), equalTo( DB_QUERY_SUMMARY, emitStableDatabaseSemconv() ? "UPDATE Customer" : null), @@ -329,7 +335,10 @@ void testCrud() { maybeStable(DB_STATEMENT), val -> val.matches( - "select ([^.]+)\\.id([^,]*),([^.]+)\\.firstName([^,]*),([^.]+)\\.lastName (.*)from Customer (.*)(where ([^.]+)\\.lastName( ?)=( ?)\\?|)")), + "select" + + " ([^.]+)\\.id([^,]*),([^.]+)\\.firstName([^,]*),([^.]+)\\.lastName" + + " (.*)from Customer (.*)(where ([^.]+)\\.lastName(" + + " ?)=( ?)\\?|)")), equalTo( DB_QUERY_SUMMARY, emitStableDatabaseSemconv() ? "SELECT Customer" : null), @@ -380,7 +389,10 @@ void testCrud() { maybeStable(DB_STATEMENT), val -> val.matches( - "select ([^.]+)\\.id([^,]*),([^.]+)\\.firstName([^,]*),([^.]+)\\.lastName (.*)from Customer (.*)(where ([^.]+)\\.lastName( ?)=( ?)\\?|)")), + "select" + + " ([^.]+)\\.id([^,]*),([^.]+)\\.firstName([^,]*),([^.]+)\\.lastName" + + " (.*)from Customer (.*)(where ([^.]+)\\.lastName(" + + " ?)=( ?)\\?|)")), equalTo( DB_QUERY_SUMMARY, emitStableDatabaseSemconv() ? "SELECT Customer" : null), diff --git a/instrumentation/hibernate/hibernate-procedure-call-4.3/javaagent/build.gradle.kts b/instrumentation/hibernate/hibernate-procedure-call-4.3/javaagent/build.gradle.kts index 0b277a20d30a..5dfb99b61264 100644 --- a/instrumentation/hibernate/hibernate-procedure-call-4.3/javaagent/build.gradle.kts +++ b/instrumentation/hibernate/hibernate-procedure-call-4.3/javaagent/build.gradle.kts @@ -38,15 +38,24 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.hibernate.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.hibernate.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.hibernate.experimental-span-attributes=true", + ) } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") diff --git a/instrumentation/hibernate/hibernate-procedure-call-4.3/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v4_3/ProcedureCallTest.java b/instrumentation/hibernate/hibernate-procedure-call-4.3/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v4_3/ProcedureCallTest.java index 572128fa31c3..184df95bcc4e 100644 --- a/instrumentation/hibernate/hibernate-procedure-call-4.3/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v4_3/ProcedureCallTest.java +++ b/instrumentation/hibernate/hibernate-procedure-call-4.3/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v4_3/ProcedureCallTest.java @@ -72,7 +72,8 @@ static void setUp() throws SQLException { try (Connection conn = DriverManager.getConnection("jdbc:hsqldb:mem:test", "sa", "1"); Statement stmt = conn.createStatement()) { stmt.execute( - "CREATE PROCEDURE TEST_PROC() MODIFIES SQL DATA BEGIN ATOMIC INSERT INTO Value VALUES (420, 'fred'); END"); + "CREATE PROCEDURE TEST_PROC() MODIFIES SQL DATA BEGIN ATOMIC INSERT INTO Value VALUES" + + " (420, 'fred'); END"); } } diff --git a/instrumentation/hibernate/hibernate-reactive-1.0/javaagent/build.gradle.kts b/instrumentation/hibernate/hibernate-reactive-1.0/javaagent/build.gradle.kts index aa66f27e936d..d145172e6270 100644 --- a/instrumentation/hibernate/hibernate-reactive-1.0/javaagent/build.gradle.kts +++ b/instrumentation/hibernate/hibernate-reactive-1.0/javaagent/build.gradle.kts @@ -15,8 +15,12 @@ dependencies { compileOnly("org.hibernate.reactive:hibernate-reactive-core:1.0.0.Final") testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent")) - testInstrumentation(project(":instrumentation:vertx:vertx-sql-client:vertx-sql-client-4.0:javaagent")) - testInstrumentation(project(":instrumentation:vertx:vertx-sql-client:vertx-sql-client-5.0:javaagent")) + testInstrumentation( + project(":instrumentation:vertx:vertx-sql-client:vertx-sql-client-4.0:javaagent"), + ) + testInstrumentation( + project(":instrumentation:vertx:vertx-sql-client:vertx-sql-client-5.0:javaagent"), + ) library("io.vertx:vertx-sql-client:4.4.2") compileOnly("io.vertx:vertx-codegen:4.4.2") @@ -44,7 +48,11 @@ testing { val hibernateReactive2Test by registering(JvmTestSuite::class) { dependencies { implementation("org.testcontainers:testcontainers") - implementation(project(":instrumentation:hibernate:hibernate-reactive-1.0:hibernate-reactive-2.0-testing")) + implementation( + project( + ":instrumentation:hibernate:hibernate-reactive-1.0:hibernate-reactive-2.0-testing", + ), + ) if (otelProps.testLatestDeps) { implementation("org.hibernate.reactive:hibernate-reactive-core:3.+") implementation("io.vertx:vertx-pg-client:4.+") @@ -59,7 +67,11 @@ testing { val hibernateReactive4Test by registering(JvmTestSuite::class) { dependencies { implementation("org.testcontainers:testcontainers") - implementation(project(":instrumentation:hibernate:hibernate-reactive-1.0:hibernate-reactive-2.0-testing")) + implementation( + project( + ":instrumentation:hibernate:hibernate-reactive-1.0:hibernate-reactive-2.0-testing", + ), + ) if (otelProps.testLatestDeps) { implementation("org.hibernate.reactive:hibernate-reactive-core:latest.release") implementation("io.vertx:vertx-pg-client:latest.release") @@ -100,15 +112,17 @@ tasks { } } - val stableSemconvSuites = testing.suites.withType(JvmTestSuite::class) - .map { suite -> - register("${suite.name}StableSemconv") { - testClassesDirs = suite.sources.output.classesDirs - classpath = suite.sources.runtimeClasspath + val stableSemconvSuites = + testing.suites + .withType(JvmTestSuite::class) + .map { suite -> + register("${suite.name}StableSemconv") { + testClassesDirs = suite.sources.output.classesDirs + classpath = suite.sources.runtimeClasspath - jvmArgs("-Dotel.semconv-stability.opt-in=database,service.peer") + jvmArgs("-Dotel.semconv-stability.opt-in=database,service.peer") + } } - } if (testJavaVersion.isJava8) { named("hibernateReactive2TestStableSemconv", Test::class).configure { diff --git a/instrumentation/hibernate/hibernate-reactive-1.0/javaagent/src/hibernateReactive1Test/java/io/opentelemetry/javaagent/instrumentation/hibernate/reactive/v1_0/HibernateReactiveTest.java b/instrumentation/hibernate/hibernate-reactive-1.0/javaagent/src/hibernateReactive1Test/java/io/opentelemetry/javaagent/instrumentation/hibernate/reactive/v1_0/HibernateReactiveTest.java index fbeab54a03ab..bc35aa191e2d 100644 --- a/instrumentation/hibernate/hibernate-reactive-1.0/javaagent/src/hibernateReactive1Test/java/io/opentelemetry/javaagent/instrumentation/hibernate/reactive/v1_0/HibernateReactiveTest.java +++ b/instrumentation/hibernate/hibernate-reactive-1.0/javaagent/src/hibernateReactive1Test/java/io/opentelemetry/javaagent/instrumentation/hibernate/reactive/v1_0/HibernateReactiveTest.java @@ -319,7 +319,8 @@ private static void assertTrace() { equalTo(DB_USER, emitStableDatabaseSemconv() ? null : USER_DB), equalTo( maybeStable(DB_STATEMENT), - "select value0_.id as id1_0_0_, value0_.name as name2_0_0_ from Value value0_ where value0_.id=$1"), + "select value0_.id as id1_0_0_, value0_.name as name2_0_0_ from" + + " Value value0_ where value0_.id=$1"), equalTo( DB_QUERY_SUMMARY, emitStableDatabaseSemconv() ? "SELECT Value" : null), diff --git a/instrumentation/hikaricp-3.0/javaagent/build.gradle.kts b/instrumentation/hikaricp-3.0/javaagent/build.gradle.kts index 566fefb502f9..4bb600d5605f 100644 --- a/instrumentation/hikaricp-3.0/javaagent/build.gradle.kts +++ b/instrumentation/hikaricp-3.0/javaagent/build.gradle.kts @@ -25,7 +25,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") diff --git a/instrumentation/hikaricp-3.0/library/build.gradle.kts b/instrumentation/hikaricp-3.0/library/build.gradle.kts index 5dee32325642..bb38db5e07a0 100644 --- a/instrumentation/hikaricp-3.0/library/build.gradle.kts +++ b/instrumentation/hikaricp-3.0/library/build.gradle.kts @@ -11,7 +11,10 @@ dependencies { tasks { val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") diff --git a/instrumentation/http-url-connection/javaagent/build.gradle.kts b/instrumentation/http-url-connection/javaagent/build.gradle.kts index 48d79688ee39..ae611a607c2a 100644 --- a/instrumentation/http-url-connection/javaagent/build.gradle.kts +++ b/instrumentation/http-url-connection/javaagent/build.gradle.kts @@ -14,7 +14,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/hystrix-1.4/javaagent/build.gradle.kts b/instrumentation/hystrix-1.4/javaagent/build.gradle.kts index fe84d134daa1..dcaa1cf0d5f9 100644 --- a/instrumentation/hystrix-1.4/javaagent/build.gradle.kts +++ b/instrumentation/hystrix-1.4/javaagent/build.gradle.kts @@ -33,11 +33,17 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.hystrix.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.hystrix.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.hystrix.experimental-span-attributes=true", + ) } check { diff --git a/instrumentation/influxdb-2.4/javaagent/build.gradle.kts b/instrumentation/influxdb-2.4/javaagent/build.gradle.kts index 0d1f76b10984..9c2f6efdb621 100644 --- a/instrumentation/influxdb-2.4/javaagent/build.gradle.kts +++ b/instrumentation/influxdb-2.4/javaagent/build.gradle.kts @@ -51,7 +51,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database") diff --git a/instrumentation/influxdb-2.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbClientTest.java b/instrumentation/influxdb-2.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbClientTest.java index a526f185c752..a721c37a50df 100644 --- a/instrumentation/influxdb-2.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbClientTest.java +++ b/instrumentation/influxdb-2.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbClientTest.java @@ -205,7 +205,8 @@ void testQueryWithTwoArguments() { void testQueryWithThreeArguments() throws InterruptedException { Query query = new Query( - "SELECT * FROM cpu_load where time >= '2022-01-01T08:00:00Z' AND time <= '2022-01-01T20:00:00Z'", + "SELECT * FROM cpu_load where time >= '2022-01-01T08:00:00Z' AND time <=" + + " '2022-01-01T20:00:00Z'", databaseName); BlockingQueue queue = new LinkedBlockingQueue<>(); @@ -273,7 +274,8 @@ void testQueryWithFiveArguments() throws InterruptedException { CountDownLatch countDownLatch = new CountDownLatch(1); Query query = new Query( - "SELECT MEAN(water_level) FROM h2o_feet where time = '2022-01-01T08:00:00Z'; SELECT water_level FROM h2o_feet LIMIT 2", + "SELECT MEAN(water_level) FROM h2o_feet where time = '2022-01-01T08:00:00Z'; SELECT" + + " water_level FROM h2o_feet LIMIT 2", databaseName); testing.runWithSpan( "parent", @@ -308,7 +310,8 @@ void testQueryWithFiveArguments() throws InterruptedException { emitStableDatabaseSemconv() ? null : "SELECT"), equalTo( maybeStable(DB_STATEMENT), - "SELECT MEAN(water_level) FROM h2o_feet where time = ?; SELECT water_level FROM h2o_feet LIMIT ?"), + "SELECT MEAN(water_level) FROM h2o_feet where time = ?; SELECT" + + " water_level FROM h2o_feet LIMIT ?"), equalTo( DB_QUERY_SUMMARY, emitStableDatabaseSemconv() diff --git a/instrumentation/internal/internal-application-logger/bootstrap/src/main/java/io/opentelemetry/javaagent/bootstrap/logging/ApplicationLoggerBridge.java b/instrumentation/internal/internal-application-logger/bootstrap/src/main/java/io/opentelemetry/javaagent/bootstrap/logging/ApplicationLoggerBridge.java index 065de4ccf209..6277e9f85de5 100644 --- a/instrumentation/internal/internal-application-logger/bootstrap/src/main/java/io/opentelemetry/javaagent/bootstrap/logging/ApplicationLoggerBridge.java +++ b/instrumentation/internal/internal-application-logger/bootstrap/src/main/java/io/opentelemetry/javaagent/bootstrap/logging/ApplicationLoggerBridge.java @@ -16,8 +16,9 @@ public abstract class ApplicationLoggerBridge { public static void set(ApplicationLoggerBridge bridge) { if (!applicationLoggerBridge.compareAndSet(null, bridge)) { throw new IllegalStateException( - "ApplicationLoggerBridge was already set earlier." - + " This should never happen in a properly built javaagent, and it's most likely a result of an error in the javaagent build."); + "ApplicationLoggerBridge was already set earlier. This should never happen in a properly" + + " built javaagent, and it's most likely a result of an error in the javaagent" + + " build."); } } @@ -25,8 +26,9 @@ public static void installApplicationLogger(InternalLogger.Factory applicationLo ApplicationLoggerBridge bridge = applicationLoggerBridge.get(); if (bridge == null) { throw new IllegalStateException( - "ApplicationLoggerBridge#set() was not called before an attempt to install a bridge was made." - + " This should never happen in a properly built javaagent, and it's most likely a result of an error in the javaagent build."); + "ApplicationLoggerBridge#set() was not called before an attempt to install a bridge was" + + " made. This should never happen in a properly built javaagent, and it's most" + + " likely a result of an error in the javaagent build."); } bridge.install(applicationLoggerFactory); } diff --git a/instrumentation/internal/internal-application-logger/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/internal/logging/ApplicationLoggerInstrumentationTest.java b/instrumentation/internal/internal-application-logger/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/internal/logging/ApplicationLoggerInstrumentationTest.java index d22548daab43..d039d022ca90 100644 --- a/instrumentation/internal/internal-application-logger/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/internal/logging/ApplicationLoggerInstrumentationTest.java +++ b/instrumentation/internal/internal-application-logger/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/internal/logging/ApplicationLoggerInstrumentationTest.java @@ -34,7 +34,8 @@ void shouldUseApplicationLogger(Class mainClass) throws Exception { .anyMatch( log -> log.startsWith( - "INFO io.opentelemetry.javaagent.tooling.VersionLogger :: opentelemetry-javaagent - version: ")); + "INFO io.opentelemetry.javaagent.tooling.VersionLogger ::" + + " opentelemetry-javaagent - version: ")); } private static List forkAndRun(String mainClassName) throws Exception { diff --git a/instrumentation/internal/internal-class-loader/javaagent-integration-tests/build.gradle.kts b/instrumentation/internal/internal-class-loader/javaagent-integration-tests/build.gradle.kts index 1a94bc8faf0d..0f136ae37601 100644 --- a/instrumentation/internal/internal-class-loader/javaagent-integration-tests/build.gradle.kts +++ b/instrumentation/internal/internal-class-loader/javaagent-integration-tests/build.gradle.kts @@ -6,5 +6,7 @@ dependencies { compileOnly("org.apache.commons:commons-lang3:3.12.0") testImplementation("org.apache.commons:commons-lang3:3.12.0") - testInstrumentation(project(":instrumentation:internal:internal-class-loader:javaagent", configuration = "shaded")) + testInstrumentation( + project(":instrumentation:internal:internal-class-loader:javaagent", configuration = "shaded"), + ) } diff --git a/instrumentation/java-http-client/javaagent/build.gradle.kts b/instrumentation/java-http-client/javaagent/build.gradle.kts index 903f212303df..587dcc163c9e 100644 --- a/instrumentation/java-http-client/javaagent/build.gradle.kts +++ b/instrumentation/java-http-client/javaagent/build.gradle.kts @@ -23,7 +23,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/java-http-client/library/build.gradle.kts b/instrumentation/java-http-client/library/build.gradle.kts index b102f6c844db..1873fd4e0847 100644 --- a/instrumentation/java-http-client/library/build.gradle.kts +++ b/instrumentation/java-http-client/library/build.gradle.kts @@ -13,7 +13,10 @@ dependencies { tasks { val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") } diff --git a/instrumentation/java-util-logging/javaagent/build.gradle.kts b/instrumentation/java-util-logging/javaagent/build.gradle.kts index 4428e5fd8203..ffc31cb929f7 100644 --- a/instrumentation/java-util-logging/javaagent/build.gradle.kts +++ b/instrumentation/java-util-logging/javaagent/build.gradle.kts @@ -8,12 +8,17 @@ dependencies { compileOnly(project(":javaagent-bootstrap")) // ensure no cross interference - testInstrumentation(project(":instrumentation:jboss-logmanager:jboss-logmanager-appender-1.1:javaagent")) + testInstrumentation( + project(":instrumentation:jboss-logmanager:jboss-logmanager-appender-1.1:javaagent"), + ) } tasks { val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.java-util-logging.experimental-log-attributes=true") diff --git a/instrumentation/jaxrs-client/jaxrs-client-2.0-testing/build.gradle.kts b/instrumentation/jaxrs-client/jaxrs-client-2.0-testing/build.gradle.kts index 8eaea3a468e3..fd3e7634c8cf 100644 --- a/instrumentation/jaxrs-client/jaxrs-client-2.0-testing/build.gradle.kts +++ b/instrumentation/jaxrs-client/jaxrs-client-2.0-testing/build.gradle.kts @@ -28,7 +28,10 @@ dependencies { } // Requires old Guava. Can't use enforcedPlatform since predates BOM -configurations.testRuntimeClasspath.get().resolutionStrategy.force("com.google.guava:guava:19.0") +configurations.testRuntimeClasspath + .get() + .resolutionStrategy + .force("com.google.guava:guava:19.0") tasks.withType().configureEach { // required on jdk17 diff --git a/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-cxf-3.2/javaagent/build.gradle.kts b/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-cxf-3.2/javaagent/build.gradle.kts index 939f75efb70b..e9271de1fc05 100644 --- a/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-cxf-3.2/javaagent/build.gradle.kts +++ b/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-cxf-3.2/javaagent/build.gradle.kts @@ -61,7 +61,10 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.jaxrs.experimental-span-attributes=true") diff --git a/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-jersey-2.0/javaagent/build.gradle.kts b/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-jersey-2.0/javaagent/build.gradle.kts index 773da4b46556..356419a52b0a 100644 --- a/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-jersey-2.0/javaagent/build.gradle.kts +++ b/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-jersey-2.0/javaagent/build.gradle.kts @@ -48,7 +48,9 @@ dependencies { if (!otelProps.testLatestDeps) { // early jersey versions require old guava - configurations.testRuntimeClasspath.get().resolutionStrategy.force("com.google.guava:guava:14.0.1") + configurations.testRuntimeClasspath.get().resolutionStrategy.force( + "com.google.guava:guava:14.0.1", + ) configurations { // early jersey versions bundle asm without shading @@ -72,7 +74,10 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.jaxrs.experimental-span-attributes=true") diff --git a/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-resteasy-3.0/javaagent/build.gradle.kts b/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-resteasy-3.0/javaagent/build.gradle.kts index 9324c3325c44..7147e9fb98d5 100644 --- a/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-resteasy-3.0/javaagent/build.gradle.kts +++ b/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-resteasy-3.0/javaagent/build.gradle.kts @@ -61,7 +61,8 @@ dependencies { latestDepTestLibrary("org.jboss.resteasy:resteasy-servlet-initializer:3.0.+") // see jaxrs-3.0-resteasy-3.1 module latestDepTestLibrary("org.jboss.resteasy:resteasy-jaxrs:3.0.+") // see jaxrs-3.0-resteasy-3.1 module - latestDepTestLibrary("org.jboss.resteasy:resteasy-undertow:3.0.+") { // see jaxrs-3.0-resteasy-3.1 module + latestDepTestLibrary("org.jboss.resteasy:resteasy-undertow:3.0.+") { + // see jaxrs-3.0-resteasy-3.1 module exclude("org.jboss.resteasy", "resteasy-client") } latestDepTestLibrary("io.undertow:undertow-servlet:2.2.24.Final") // see jaxrs-3.0-resteasy-3.1 module @@ -76,7 +77,10 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.jaxrs.experimental-span-attributes=true") diff --git a/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-resteasy-3.1/javaagent/build.gradle.kts b/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-resteasy-3.1/javaagent/build.gradle.kts index 0f257371610f..83bca879a617 100644 --- a/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-resteasy-3.1/javaagent/build.gradle.kts +++ b/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-resteasy-3.1/javaagent/build.gradle.kts @@ -61,7 +61,8 @@ dependencies { // artifact name changed from 'resteasy-jaxrs' to 'resteasy-core' starting from version 4.0.0 latestDepTestLibrary("org.jboss.resteasy:resteasy-core:5.+") // documented limitation latestDepTestLibrary("org.jboss.resteasy:resteasy-servlet-initializer:5.+") // documented limitation - latestDepTestLibrary("org.jboss.resteasy:resteasy-undertow:5.+") { // documented limitation + latestDepTestLibrary("org.jboss.resteasy:resteasy-undertow:5.+") { + // documented limitation exclude("org.jboss.resteasy", "resteasy-client") } } @@ -75,7 +76,10 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.jaxrs.experimental-span-attributes=true") diff --git a/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-wildfly-testing/build.gradle.kts b/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-wildfly-testing/build.gradle.kts index 981d44605897..3731c3b44e51 100644 --- a/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-wildfly-testing/build.gradle.kts +++ b/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-wildfly-testing/build.gradle.kts @@ -57,9 +57,11 @@ tasks { jvmArgs("-Djboss.socket.binding.port-offset=400") // remove logback-classic from classpath and add modified copy - classpath = classpath.filter { - !it.absolutePath.contains("logback-classic") - }.plus(files(layout.buildDirectory.file("tmp/logback-classic-modified.jar"))) + classpath = + classpath + .filter { + !it.absolutePath.contains("logback-classic") + }.plus(files(layout.buildDirectory.file("tmp/logback-classic-modified.jar"))) } } diff --git a/instrumentation/jaxrs/jaxrs-3.0/jaxrs-3.0-jersey-3.0/javaagent/build.gradle.kts b/instrumentation/jaxrs/jaxrs-3.0/jaxrs-3.0-jersey-3.0/javaagent/build.gradle.kts index 4c92bf624f74..beee644b116d 100644 --- a/instrumentation/jaxrs/jaxrs-3.0/jaxrs-3.0-jersey-3.0/javaagent/build.gradle.kts +++ b/instrumentation/jaxrs/jaxrs-3.0/jaxrs-3.0-jersey-3.0/javaagent/build.gradle.kts @@ -47,7 +47,10 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.jaxrs.experimental-span-attributes=true") diff --git a/instrumentation/jaxrs/jaxrs-3.0/jaxrs-3.0-resteasy-6.0/javaagent/build.gradle.kts b/instrumentation/jaxrs/jaxrs-3.0/jaxrs-3.0-resteasy-6.0/javaagent/build.gradle.kts index 52976c26ac95..3cf3f100843e 100644 --- a/instrumentation/jaxrs/jaxrs-3.0/jaxrs-3.0-resteasy-6.0/javaagent/build.gradle.kts +++ b/instrumentation/jaxrs/jaxrs-3.0/jaxrs-3.0-resteasy-6.0/javaagent/build.gradle.kts @@ -47,7 +47,10 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.jaxrs.experimental-span-attributes=true") diff --git a/instrumentation/jaxws/jaxws-2.0-arquillian-testing/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxws/v2_0/AbstractArquillianJaxWsTest.java b/instrumentation/jaxws/jaxws-2.0-arquillian-testing/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxws/v2_0/AbstractArquillianJaxWsTest.java index e83118309671..b112330ac67f 100644 --- a/instrumentation/jaxws/jaxws-2.0-arquillian-testing/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxws/v2_0/AbstractArquillianJaxWsTest.java +++ b/instrumentation/jaxws/jaxws-2.0-arquillian-testing/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxws/v2_0/AbstractArquillianJaxWsTest.java @@ -79,14 +79,10 @@ void testEjbHelloService() { // thrown from the test method are ignored private void testHelloRequest(String service) { String soapMessage = - "" - + " " - + " " - + " " - + " Test" - + " " - + " " - + ""; + " " + + " Test " + + " "; AggregatedHttpResponse response = client.post(getAddress(service), soapMessage).aggregate().join(); diff --git a/instrumentation/jaxws/jaxws-2.0-axis2-1.6/javaagent/build.gradle.kts b/instrumentation/jaxws/jaxws-2.0-axis2-1.6/javaagent/build.gradle.kts index 0c5b4e986be2..ec09ef9c7753 100644 --- a/instrumentation/jaxws/jaxws-2.0-axis2-1.6/javaagent/build.gradle.kts +++ b/instrumentation/jaxws/jaxws-2.0-axis2-1.6/javaagent/build.gradle.kts @@ -60,5 +60,8 @@ tasks.withType().configureEach { jvmArgs("-XX:+IgnoreUnrecognizedVMOptions") jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true") systemProperty("collectMetadata", otelProps.collectMetadata) - systemProperty("metadataConfig", "otel.instrumentation.common.experimental.controller-telemetry.enabled=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.common.experimental.controller-telemetry.enabled=true", + ) } diff --git a/instrumentation/jaxws/jaxws-2.0-wildfly-testing/build.gradle.kts b/instrumentation/jaxws/jaxws-2.0-wildfly-testing/build.gradle.kts index 8b79a494ca77..680367c060e7 100644 --- a/instrumentation/jaxws/jaxws-2.0-wildfly-testing/build.gradle.kts +++ b/instrumentation/jaxws/jaxws-2.0-wildfly-testing/build.gradle.kts @@ -58,9 +58,11 @@ tasks { jvmArgs("-Djboss.socket.binding.port-offset=200") // remove logback-classic from classpath and add modified copy - classpath = classpath.filter { - !it.absolutePath.contains("logback-classic") - }.plus(files(layout.buildDirectory.file("tmp/logback-classic-modified.jar"))) + classpath = + classpath + .filter { + !it.absolutePath.contains("logback-classic") + }.plus(files(layout.buildDirectory.file("tmp/logback-classic-modified.jar"))) } } diff --git a/instrumentation/jaxws/jaxws-2.0/javaagent/build.gradle.kts b/instrumentation/jaxws/jaxws-2.0/javaagent/build.gradle.kts index b13b2364df2a..fc3fcd31263b 100644 --- a/instrumentation/jaxws/jaxws-2.0/javaagent/build.gradle.kts +++ b/instrumentation/jaxws/jaxws-2.0/javaagent/build.gradle.kts @@ -19,5 +19,8 @@ dependencies { tasks.withType().configureEach { jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true") systemProperty("collectMetadata", otelProps.collectMetadata) - systemProperty("metadataConfig", "otel.instrumentation.common.experimental.controller-telemetry.enabled=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.common.experimental.controller-telemetry.enabled=true", + ) } diff --git a/instrumentation/jaxws/jaxws-cxf-3.0/javaagent/build.gradle.kts b/instrumentation/jaxws/jaxws-cxf-3.0/javaagent/build.gradle.kts index 308da98668dc..a24fc6c00c21 100644 --- a/instrumentation/jaxws/jaxws-cxf-3.0/javaagent/build.gradle.kts +++ b/instrumentation/jaxws/jaxws-cxf-3.0/javaagent/build.gradle.kts @@ -51,5 +51,8 @@ tasks.withType().configureEach { jvmArgs("-XX:+IgnoreUnrecognizedVMOptions") jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true") systemProperty("collectMetadata", otelProps.collectMetadata) - systemProperty("metadataConfig", "otel.instrumentation.common.experimental.controller-telemetry.enabled=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.common.experimental.controller-telemetry.enabled=true", + ) } diff --git a/instrumentation/jaxws/jaxws-jws-api-1.1/javaagent/build.gradle.kts b/instrumentation/jaxws/jaxws-jws-api-1.1/javaagent/build.gradle.kts index e612cb9fa021..53a6ce5c73a6 100644 --- a/instrumentation/jaxws/jaxws-jws-api-1.1/javaagent/build.gradle.kts +++ b/instrumentation/jaxws/jaxws-jws-api-1.1/javaagent/build.gradle.kts @@ -19,5 +19,8 @@ dependencies { tasks.withType().configureEach { jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true") systemProperty("collectMetadata", otelProps.collectMetadata) - systemProperty("metadataConfig", "otel.instrumentation.common.experimental.controller-telemetry.enabled=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.common.experimental.controller-telemetry.enabled=true", + ) } diff --git a/instrumentation/jaxws/jaxws-metro-2.2/javaagent/build.gradle.kts b/instrumentation/jaxws/jaxws-metro-2.2/javaagent/build.gradle.kts index 6ac835fe0732..752f90a82ff7 100644 --- a/instrumentation/jaxws/jaxws-metro-2.2/javaagent/build.gradle.kts +++ b/instrumentation/jaxws/jaxws-metro-2.2/javaagent/build.gradle.kts @@ -43,5 +43,8 @@ tasks.withType().configureEach { jvmArgs("-XX:+IgnoreUnrecognizedVMOptions") jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true") systemProperty("collectMetadata", otelProps.collectMetadata) - systemProperty("metadataConfig", "otel.instrumentation.common.experimental.controller-telemetry.enabled=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.common.experimental.controller-telemetry.enabled=true", + ) } diff --git a/instrumentation/jdbc/javaagent/build.gradle.kts b/instrumentation/jdbc/javaagent/build.gradle.kts index 5519ca1231b7..ae78336ec08b 100644 --- a/instrumentation/jdbc/javaagent/build.gradle.kts +++ b/instrumentation/jdbc/javaagent/build.gradle.kts @@ -53,7 +53,10 @@ sourceSets { tasks { val testSlick by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { @@ -63,7 +66,10 @@ tasks { } val testSqlCommenter by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { @@ -77,7 +83,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { @@ -91,7 +100,10 @@ tasks { } val testSlickStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { @@ -102,7 +114,10 @@ tasks { } val testCaptureParameters by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { diff --git a/instrumentation/jdbc/library/build.gradle.kts b/instrumentation/jdbc/library/build.gradle.kts index 4531a2f11823..4379e226f558 100644 --- a/instrumentation/jdbc/library/build.gradle.kts +++ b/instrumentation/jdbc/library/build.gradle.kts @@ -43,7 +43,10 @@ tasks { include(project(":instrumentation:jdbc:library")) } // rename classes that are included in :instrumentation:jdbc:bootstrap - relocate("io.opentelemetry.instrumentation.jdbc.internal.dbinfo", "io.opentelemetry.javaagent.bootstrap.jdbc") + relocate( + "io.opentelemetry.instrumentation.jdbc.internal.dbinfo", + "io.opentelemetry.javaagent.bootstrap.jdbc", + ) } // this will be included in javaagent module @@ -64,7 +67,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") diff --git a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/OpenTelemetryDriver.java b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/OpenTelemetryDriver.java index 416d66f3652f..390b7943e787 100644 --- a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/OpenTelemetryDriver.java +++ b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/OpenTelemetryDriver.java @@ -140,7 +140,8 @@ public static void register() throws SQLException { public static void deregister() throws SQLException { if (!REGISTERED.compareAndSet(true, false)) { throw new IllegalStateException( - "Driver is not registered (or it has not been registered using Driver.register() method)"); + "Driver is not registered (or it has not been registered using Driver.register()" + + " method)"); } DriverManager.deregisterDriver(INSTANCE); } diff --git a/instrumentation/jdbc/library/src/test/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcConnectionUrlParserTest.java b/instrumentation/jdbc/library/src/test/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcConnectionUrlParserTest.java index 2503c7c4b9a8..4179d43b4fe9 100644 --- a/instrumentation/jdbc/library/src/test/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcConnectionUrlParserTest.java +++ b/instrumentation/jdbc/library/src/test/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcConnectionUrlParserTest.java @@ -780,7 +780,13 @@ private static Stream oracleArguments() { .setPort(666) .setName("orclsn") .build(), - arg("jdbc:oracle:thin:@ ( description = (connect_timeout=90)(retry_count=20)(retry_delay=3) (transport_connect_timeout=3000) (address_list = (load_balance = on) (failover = on) (address = (protocol = tcp)(host = orcl.host1 )(port = 1521 )) (address = (protocol = tcp)(host = orcl.host2)(port = 1521)) (address = (protocol = tcp)(host = orcl.host3)(port = 1521)) (address = (protocol = tcp)(host = orcl.host4)(port = 1521)) ) (connect_data = (server = dedicated) (service_name = orclsn)))") + arg("jdbc:oracle:thin:@ ( description = (connect_timeout=90)(retry_count=20)(retry_delay=3)" + + " (transport_connect_timeout=3000) (address_list = (load_balance = on) (failover" + + " = on) (address = (protocol = tcp)(host = orcl.host1 )(port = 1521 )) (address =" + + " (protocol = tcp)(host = orcl.host2)(port = 1521)) (address = (protocol =" + + " tcp)(host = orcl.host3)(port = 1521)) (address = (protocol = tcp)(host =" + + " orcl.host4)(port = 1521)) ) (connect_data = (server = dedicated) (service_name" + + " = orclsn)))") .setShortUrl("oracle:thin://orcl.host1:1521") .setSystem("oracle.db") .setOldSystem("oracle") diff --git a/instrumentation/jedis/jedis-1.4/javaagent/build.gradle.kts b/instrumentation/jedis/jedis-1.4/javaagent/build.gradle.kts index 93d6e31eef63..88f838f5a8e0 100644 --- a/instrumentation/jedis/jedis-1.4/javaagent/build.gradle.kts +++ b/instrumentation/jedis/jedis-1.4/javaagent/build.gradle.kts @@ -45,7 +45,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database,service.peer") diff --git a/instrumentation/jedis/jedis-3.0/javaagent/build.gradle.kts b/instrumentation/jedis/jedis-3.0/javaagent/build.gradle.kts index 1a24d3eb0d95..9fc28134a3d1 100644 --- a/instrumentation/jedis/jedis-3.0/javaagent/build.gradle.kts +++ b/instrumentation/jedis/jedis-3.0/javaagent/build.gradle.kts @@ -35,7 +35,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database,service.peer") diff --git a/instrumentation/jedis/jedis-4.0/javaagent/build.gradle.kts b/instrumentation/jedis/jedis-4.0/javaagent/build.gradle.kts index 460c00d1c13b..dc9c32723e4e 100644 --- a/instrumentation/jedis/jedis-4.0/javaagent/build.gradle.kts +++ b/instrumentation/jedis/jedis-4.0/javaagent/build.gradle.kts @@ -32,7 +32,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") diff --git a/instrumentation/jetty-httpclient/jetty-httpclient-12.0/javaagent/build.gradle.kts b/instrumentation/jetty-httpclient/jetty-httpclient-12.0/javaagent/build.gradle.kts index 4b4a260445e2..fb83852542be 100644 --- a/instrumentation/jetty-httpclient/jetty-httpclient-12.0/javaagent/build.gradle.kts +++ b/instrumentation/jetty-httpclient/jetty-httpclient-12.0/javaagent/build.gradle.kts @@ -31,7 +31,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/jetty-httpclient/jetty-httpclient-12.0/library/build.gradle.kts b/instrumentation/jetty-httpclient/jetty-httpclient-12.0/library/build.gradle.kts index 3d8c0cfad319..7d4b2b36485c 100644 --- a/instrumentation/jetty-httpclient/jetty-httpclient-12.0/library/build.gradle.kts +++ b/instrumentation/jetty-httpclient/jetty-httpclient-12.0/library/build.gradle.kts @@ -14,7 +14,10 @@ dependencies { tasks { val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") } diff --git a/instrumentation/jetty-httpclient/jetty-httpclient-9.2/javaagent/build.gradle.kts b/instrumentation/jetty-httpclient/jetty-httpclient-9.2/javaagent/build.gradle.kts index c5de5b079680..0376d86785ca 100644 --- a/instrumentation/jetty-httpclient/jetty-httpclient-9.2/javaagent/build.gradle.kts +++ b/instrumentation/jetty-httpclient/jetty-httpclient-9.2/javaagent/build.gradle.kts @@ -32,7 +32,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/build.gradle.kts b/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/build.gradle.kts index de12e69470fc..fa05c9c4642a 100644 --- a/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/build.gradle.kts +++ b/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/build.gradle.kts @@ -34,7 +34,10 @@ testing { tasks { val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") } diff --git a/instrumentation/jms/jms-1.1/javaagent/build.gradle.kts b/instrumentation/jms/jms-1.1/javaagent/build.gradle.kts index 20f4bd032259..2646baf9fa87 100644 --- a/instrumentation/jms/jms-1.1/javaagent/build.gradle.kts +++ b/instrumentation/jms/jms-1.1/javaagent/build.gradle.kts @@ -56,7 +56,10 @@ tasks { } val testReceiveSpansDisabled by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service) diff --git a/instrumentation/jms/jms-3.0/javaagent/build.gradle.kts b/instrumentation/jms/jms-3.0/javaagent/build.gradle.kts index c5ac82b4b669..4408d895a18c 100644 --- a/instrumentation/jms/jms-3.0/javaagent/build.gradle.kts +++ b/instrumentation/jms/jms-3.0/javaagent/build.gradle.kts @@ -42,7 +42,10 @@ tasks { } val testReceiveSpansDisabled by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { diff --git a/instrumentation/jmx-metrics/library/build.gradle.kts b/instrumentation/jmx-metrics/library/build.gradle.kts index 9c8a12d8bac4..d08df224d9f3 100644 --- a/instrumentation/jmx-metrics/library/build.gradle.kts +++ b/instrumentation/jmx-metrics/library/build.gradle.kts @@ -22,8 +22,14 @@ tasks { test { val shadowTask = project(":javaagent").tasks.named("shadowJar") - val testAppTask = project(":instrumentation:jmx-metrics:testing-apps:testing-webapp").tasks.named("war") - val camelTestAppTask = project(":instrumentation:jmx-metrics:testing-apps:camel-testing-app").tasks.named("camelTestAppJar") + val testAppTask = + project( + ":instrumentation:jmx-metrics:testing-apps:testing-webapp", + ).tasks.named("war") + val camelTestAppTask = + project( + ":instrumentation:jmx-metrics:testing-apps:camel-testing-app", + ).tasks.named("camelTestAppJar") dependsOn(shadowTask) dependsOn(testAppTask) @@ -33,22 +39,26 @@ tasks { val testAppWar = testAppTask.flatMap { it.archiveFile } val camelTestAppJar = camelTestAppTask.flatMap { it.archiveFile } - inputs.file(agentJar) + inputs + .file(agentJar) .withPropertyName("javaagent") .withNormalizer(ClasspathNormalizer::class) - inputs.file(testAppWar) + inputs + .file(testAppWar) .withPropertyName("testWebApp") .withNormalizer(ClasspathNormalizer::class) - inputs.file(camelTestAppJar) + inputs + .file(camelTestAppJar) .withPropertyName("camelTestApp") .withNormalizer(ClasspathNormalizer::class) - jvmArgumentProviders += CommandLineArgumentProvider { - listOf( - "-Dio.opentelemetry.javaagent.path=${agentJar.get().asFile.absolutePath}", - "-Dio.opentelemetry.testapp.path=${testAppWar.get().asFile.absolutePath}", - "-Dio.opentelemetry.cameltestapp.path=${camelTestAppJar.get().asFile.absolutePath}", - ) - } + jvmArgumentProviders += + CommandLineArgumentProvider { + listOf( + "-Dio.opentelemetry.javaagent.path=${agentJar.get().asFile.absolutePath}", + "-Dio.opentelemetry.testapp.path=${testAppWar.get().asFile.absolutePath}", + "-Dio.opentelemetry.cameltestapp.path=${camelTestAppJar.get().asFile.absolutePath}", + ) + } } } diff --git a/instrumentation/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/internal/engine/BeanAttributeExtractor.java b/instrumentation/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/internal/engine/BeanAttributeExtractor.java index 62b07533a846..79e195dff6ce 100644 --- a/instrumentation/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/internal/engine/BeanAttributeExtractor.java +++ b/instrumentation/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/internal/engine/BeanAttributeExtractor.java @@ -231,7 +231,8 @@ private Object extractAttributeValue( if (logger != null) { logger.log( FINE, - "Encountered a value of {0} while extracting attribute {1} for ObjectName {2}; unable to extract metric value", + "Encountered a value of {0} while extracting attribute {1} for ObjectName {2};" + + " unable to extract metric value", new Object[] { (value == null ? "NULL" : value.getClass().getName()), getAttributeName(), @@ -248,7 +249,8 @@ private Object extractAttributeValue( if (logger != null) { logger.log( FINE, - "Encountered {0} while extracting attribute {1} for ObjectName {2}; unable to extract metric value", + "Encountered {0} while extracting attribute {1} for ObjectName {2}; unable to extract" + + " metric value", new Object[] {e, getAttributeName(), objectName}); } } diff --git a/instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/internal/yaml/MetricStructureTest.java b/instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/internal/yaml/MetricStructureTest.java index e1b8f251f866..e55fb80dd472 100644 --- a/instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/internal/yaml/MetricStructureTest.java +++ b/instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/internal/yaml/MetricStructureTest.java @@ -91,7 +91,8 @@ void invalidTargetSyntax(String target) { assertThatThrownBy(() -> MetricStructure.buildMetricAttribute("metric_attribute", target)) .isInstanceOf(IllegalArgumentException.class) .describedAs( - "exception should be thrown with original expression to help end-user understand the syntax error") + "exception should be thrown with original expression to help end-user understand the" + + " syntax error") .hasMessageContaining(target); } } diff --git a/instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/rules/ActiveMqTest.java b/instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/rules/ActiveMqTest.java index 80d3f7aaf4d6..47663c9aab9e 100644 --- a/instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/rules/ActiveMqTest.java +++ b/instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/rules/ActiveMqTest.java @@ -156,7 +156,8 @@ private static MetricsVerifier createMetricsVerifier() { .hasUnit("By") .hasDataPointsWithAttributes(topicAttributes) .hasDescription( - "The amount of configured non-persistent storage limit for this destination")) + "The amount of configured non-persistent storage limit for this" + + " destination")) // broker metrics .add( "activemq.connection.count", diff --git a/instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/rules/CamelTest.java b/instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/rules/CamelTest.java index daac0263756e..b383df9c85e2 100644 --- a/instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/rules/CamelTest.java +++ b/instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/rules/CamelTest.java @@ -100,7 +100,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isUpDownCounter() .hasDescription( - "Indicates the number of routes started successfully since context start-up or the last reset operation.") + "Indicates the number of routes started successfully since context start-up" + + " or the last reset operation.") .hasUnit("{route}") .hasDataPointsWithIntValues(value -> value.isEqualTo(numberOfTestRoutes)) .hasDataPointsWithAttributes(contextAttributes)) @@ -110,7 +111,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isCounter() .hasDescription( - "Indicates the total number of routes added successfully since context start-up or the last reset operation.") + "Indicates the total number of routes added successfully since context" + + " start-up or the last reset operation.") .hasUnit("{route}") .hasDataPointsWithIntValues(value -> value.isEqualTo(numberOfTestRoutes)) .hasDataPointsWithAttributes(contextAttributes)) @@ -120,7 +122,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isCounter() .hasDescription( - "Indicates the total number of exchanges, passed or failed, processed since context start-up or the last reset operation.") + "Indicates the total number of exchanges, passed or failed, processed since" + + " context start-up or the last reset operation.") .hasUnit("{exchange}") .hasDataPointsWithIntValues(value -> value.isGreaterThanOrEqualTo(1)) .hasDataPointsWithAttributes(contextAttributes)) @@ -130,7 +133,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isCounter() .hasDescription( - "Indicates the total number of exchanges processed successfully since context start-up or the last reset operation.") + "Indicates the total number of exchanges processed successfully since" + + " context start-up or the last reset operation.") .hasUnit("{exchange}") .hasDataPointsWithIntValues(value -> value.isGreaterThanOrEqualTo(1)) .hasDataPointsWithAttributes(contextAttributes)) @@ -140,7 +144,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isCounter() .hasDescription( - "Indicates the total number of exchanges that failed to process since context start-up or the last reset operation.") + "Indicates the total number of exchanges that failed to process since" + + " context start-up or the last reset operation.") .hasUnit("{exchange}") .hasDataPointsWithIntValues(value -> value.isEqualTo(0)) .hasDataPointsWithAttributes(contextAttributes)) @@ -150,7 +155,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isCounter() .hasDescription( - "Indicates the number of exchanges failed and handled by an ExceptionHandler in the context.") + "Indicates the number of exchanges failed and handled by an" + + " ExceptionHandler in the context.") .hasUnit("{exchange}") .hasDataPointsWithIntValues(value -> value.isEqualTo(0)) .hasDataPointsWithAttributes(contextAttributes)) @@ -170,7 +176,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isCounter() .hasDescription( - "Number of exchanges redelivered (internal only) since context start-up or the last reset operation.") + "Number of exchanges redelivered (internal only) since context start-up or" + + " the last reset operation.") .hasUnit("{exchange}") .hasDataPointsWithIntValues(value -> value.isEqualTo(0)) .hasDataPointsWithAttributes(contextAttributes)) @@ -180,7 +187,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isCounter() .hasDescription( - "The total number of all external initiated redeliveries (such as from JMS broker) since context start-up or the last reset operation.") + "The total number of all external initiated redeliveries (such as from JMS" + + " broker) since context start-up or the last reset operation.") .hasUnit("{exchange}") .hasDataPointsWithIntValues(value -> value.isEqualTo(0)) .hasDataPointsWithAttributes(contextAttributes)) @@ -190,7 +198,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isGauge() .hasDescription( - "Indicates the longest time to process an exchange since context start-up or the last reset operation.") + "Indicates the longest time to process an exchange since context start-up" + + " or the last reset operation.") .hasUnit("s") .hasDataPointsWithDoubleValues(value -> value.isGreaterThan(0.0)) .hasDataPointsWithAttributes(contextAttributes)) @@ -200,7 +209,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isGauge() .hasDescription( - "Indicates the mean processing time for all exchanges processed since context start-up or the last reset operation.") + "Indicates the mean processing time for all exchanges processed since" + + " context start-up or the last reset operation.") .hasUnit("s") .hasDataPointsWithDoubleValues(value -> value.isGreaterThan(0.0)) .hasDataPointsWithAttributes(contextAttributes)) @@ -210,7 +220,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isGauge() .hasDescription( - "Indicates the shortest time to process an exchange since context start-up or the last reset operation.") + "Indicates the shortest time to process an exchange since context start-up" + + " or the last reset operation.") .hasUnit("s") .hasDataPointsWithDoubleValues(value -> value.isBetween(0.0, 1.0)) .hasDataPointsWithAttributes(contextAttributes)) @@ -229,7 +240,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isGauge() .hasDescription( - "Indicates the difference of the Processing Time of the last two exchanges transited the context.") + "Indicates the difference of the Processing Time of the last two exchanges" + + " transited the context.") .hasUnit("s") .hasDataPointsWithAttributes(contextAttributes)) .add( @@ -238,7 +250,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isCounter() .hasDescription( - "Indicates the total processing time to process all exchanges since context start-up or the last reset operation.") + "Indicates the total processing time to process all exchanges since context" + + " start-up or the last reset operation.") .hasUnit("s") .hasDataPointsWithDoubleValues(value -> value.isGreaterThan(0.0)) .hasDataPointsWithAttributes(contextAttributes)) @@ -249,7 +262,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isCounter() .hasDescription( - "Indicates the total number of exchanges, passed or failed, that the route has processed since route start-up or the last reset operation.") + "Indicates the total number of exchanges, passed or failed, that the route" + + " has processed since route start-up or the last reset operation.") .hasUnit("{exchange}") .hasDataPointsWithIntValues(value -> value.isGreaterThanOrEqualTo(1)) .hasDataPointsWithAttributes(routeAttributes)) @@ -259,7 +273,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isCounter() .hasDescription( - "Indicates the total number of exchanges the route has processed successfully since route start-up or the last reset operation.") + "Indicates the total number of exchanges the route has processed" + + " successfully since route start-up or the last reset operation.") .hasUnit("{exchange}") .hasDataPointsWithIntValues(value -> value.isGreaterThanOrEqualTo(1)) .hasDataPointsWithAttributes(routeAttributes)) @@ -269,7 +284,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isCounter() .hasDescription( - "Indicates the total number of exchanges that the route has failed to process since route start-up or the last reset operation.") + "Indicates the total number of exchanges that the route has failed to" + + " process since route start-up or the last reset operation.") .hasUnit("{exchange}") .hasDataPointsWithIntValues(value -> value.isEqualTo(0)) .hasDataPointsWithAttributes(routeAttributes)) @@ -279,7 +295,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isCounter() .hasDescription( - "Indicates the number of exchanges failed and handled by an ExceptionHandler in the route.") + "Indicates the number of exchanges failed and handled by an" + + " ExceptionHandler in the route.") .hasUnit("{exchange}") .hasDataPointsWithIntValues(value -> value.isEqualTo(0)) .hasDataPointsWithAttributes(routeAttributes)) @@ -299,7 +316,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isCounter() .hasDescription( - "Number of exchanges redelivered (internal only) since route start-up or the last reset operation.") + "Number of exchanges redelivered (internal only) since route start-up or" + + " the last reset operation.") .hasUnit("{exchange}") .hasDataPointsWithIntValues(value -> value.isEqualTo(0)) .hasDataPointsWithAttributes(routeAttributes)) @@ -309,7 +327,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isCounter() .hasDescription( - "The total number of all external initiated redeliveries (such as from JMS broker) since the route start-up or the last reset operation.") + "The total number of all external initiated redeliveries (such as from JMS" + + " broker) since the route start-up or the last reset operation.") .hasUnit("{exchange}") .hasDataPointsWithIntValues(value -> value.isEqualTo(0)) .hasDataPointsWithAttributes(routeAttributes)) @@ -323,7 +342,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isGauge() .hasDescription( - "Indicates the longest time to process an exchange since the route start-up or the last reset operation.") + "Indicates the longest time to process an exchange since the route start-up" + + " or the last reset operation.") .hasUnit("s") .hasDataPointsWithDoubleValues(value -> value.isBetween(0.0, 1.0)) .hasDataPointsWithAttributes(routeAttributes)) @@ -333,7 +353,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isGauge() .hasDescription( - "Indicates the mean processing time for all exchanges processed since the route start-up or the last reset operation.") + "Indicates the mean processing time for all exchanges processed since the" + + " route start-up or the last reset operation.") .hasUnit("s") .hasDataPointsWithDoubleValues( value -> value.isGreaterThanOrEqualTo(defaultTestRouteProcessingTime)) @@ -344,7 +365,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isGauge() .hasDescription( - "Indicates the shortest time to process an exchange since the route start-up or the last reset operation.") + "Indicates the shortest time to process an exchange since the route" + + " start-up or the last reset operation.") .hasUnit("s") .hasDataPointsWithDoubleValues( value -> value.isGreaterThanOrEqualTo(defaultTestRouteProcessingTime)) @@ -366,7 +388,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isGauge() .hasDescription( - "Indicates the difference of the Processing Time of the last two exchanges transited the route.") + "Indicates the difference of the Processing Time of the last two exchanges" + + " transited the route.") .hasUnit("s") .hasDataPointsWithDoubleValues(value -> value.isBetween(-1.0, 1.0)) .hasDataPointsWithAttributes(routeAttributes)) @@ -376,7 +399,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isCounter() .hasDescription( - "Indicates the total processing time of all exchanges the selected processed since route start-up or the last reset operation.") + "Indicates the total processing time of all exchanges the selected" + + " processed since route start-up or the last reset operation.") .hasUnit("s") .hasDataPointsWithDoubleValues(value -> value.isGreaterThan(0.0)) .hasDataPointsWithAttributes(routeAttributes)) @@ -387,7 +411,9 @@ private static MetricsVerifier createMetricsVerifier() { metric .isCounter() .hasDescription( - "Indicates the total number of exchanges, passed or failed, that the selected processor has processed since processor start-up or the last reset operation.") + "Indicates the total number of exchanges, passed or failed, that the" + + " selected processor has processed since processor start-up or the" + + " last reset operation.") .hasUnit("{exchange}") .hasDataPointsWithIntValues(value -> value.isGreaterThanOrEqualTo(1)) .hasDataPointsWithAttributes( @@ -398,7 +424,9 @@ private static MetricsVerifier createMetricsVerifier() { metric .isCounter() .hasDescription( - "Indicates the total number of exchanges the selected processor has processed successfully since processor start-up or the last reset operation.") + "Indicates the total number of exchanges the selected processor has" + + " processed successfully since processor start-up or the last reset" + + " operation.") .hasUnit("{exchange}") .hasDataPointsWithIntValues(value -> value.isGreaterThanOrEqualTo(1)) .hasDataPointsWithAttributes( @@ -409,7 +437,9 @@ private static MetricsVerifier createMetricsVerifier() { metric .isCounter() .hasDescription( - "Indicates the total number of exchanges that the selected processor has failed to process since processor start-up or the last reset operation.") + "Indicates the total number of exchanges that the selected processor has" + + " failed to process since processor start-up or the last reset" + + " operation.") .hasUnit("{exchange}") .hasDataPointsWithIntValues(value -> value.isEqualTo(0)) .hasDataPointsWithAttributes( @@ -420,7 +450,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isCounter() .hasDescription( - "Indicates the number of exchanges failed and handled by an ExceptionHandler in the context.") + "Indicates the number of exchanges failed and handled by an" + + " ExceptionHandler in the context.") .hasUnit("{exchange}") .hasDataPointsWithIntValues(value -> value.isEqualTo(0)) .hasDataPointsWithAttributes( @@ -442,7 +473,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isCounter() .hasDescription( - "Number of exchanges redelivered (internal only) since selected processor start-up or the last reset operation.") + "Number of exchanges redelivered (internal only) since selected processor" + + " start-up or the last reset operation.") .hasUnit("{exchange}") .hasDataPointsWithIntValues(value -> value.isEqualTo(0)) .hasDataPointsWithAttributes( @@ -453,7 +485,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isCounter() .hasDescription( - "The total number of all external initiated redeliveries (such as from JMS broker) since processor start-up or the last reset operation.") + "The total number of all external initiated redeliveries (such as from JMS" + + " broker) since processor start-up or the last reset operation.") .hasUnit("{exchange}") .hasDataPointsWithIntValues(value -> value.isEqualTo(0)) .hasDataPointsWithAttributes( @@ -464,7 +497,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isGauge() .hasDescription( - "Indicates the longest time to process an exchange since processor start-up or the last reset operation.") + "Indicates the longest time to process an exchange since processor start-up" + + " or the last reset operation.") .hasUnit("s") .hasDataPointsWithDoubleValues(value -> value.isGreaterThanOrEqualTo(0.0)) .hasDataPointsWithAttributes( @@ -475,7 +509,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isGauge() .hasDescription( - "Indicates the mean processing time for all exchanges processed since processor start-up or the last reset operation.") + "Indicates the mean processing time for all exchanges processed since" + + " processor start-up or the last reset operation.") .hasUnit("s") .hasDataPointsWithDoubleValues(value -> value.isGreaterThanOrEqualTo(0.0)) .hasDataPointsWithAttributes( @@ -486,7 +521,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isGauge() .hasDescription( - "Indicates the shortest time to process an exchange since processor start-up or the last reset operation.") + "Indicates the shortest time to process an exchange since processor" + + " start-up or the last reset operation.") .hasUnit("s") .hasDataPointsWithDoubleValues(value -> value.isGreaterThanOrEqualTo(0.0)) .hasDataPointsWithAttributes( @@ -497,7 +533,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isGauge() .hasDescription( - "Indicates the time it took the selected processor to process the last exchange.") + "Indicates the time it took the selected processor to process the last" + + " exchange.") .hasUnit("s") .hasDataPointsWithDoubleValues(value -> value.isGreaterThanOrEqualTo(0.0)) .hasDataPointsWithAttributes( @@ -508,7 +545,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isGauge() .hasDescription( - "Indicates the difference of the Processing Time of the last two exchanges transited the selected processor.") + "Indicates the difference of the Processing Time of the last two exchanges" + + " transited the selected processor.") .hasUnit("s") .hasDataPointsWithAttributes( processorAttributes, destinationAwareProcessorAttributes)) @@ -518,7 +556,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isCounter() .hasDescription( - "Indicates the total processing time to process all exchanges since start-up or the last reset operation.") + "Indicates the total processing time to process all exchanges since" + + " start-up or the last reset operation.") .hasUnit("s") .hasDataPointsWithDoubleValues(value -> value.isGreaterThanOrEqualTo(0.0)) .hasDataPointsWithAttributes( @@ -530,7 +569,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isCounter() .hasDescription( - "The approximate total number of tasks that have ever been scheduled for execution.") + "The approximate total number of tasks that have ever been scheduled for" + + " execution.") .hasUnit("{task}") .hasDataPointsWithAttributes( threadPoolAttributes, routeRelatedThreadPoolAttributes)) @@ -550,7 +590,10 @@ private static MetricsVerifier createMetricsVerifier() { metric .isCounter() .hasDescription( - "The approximate total number of tasks that have completed execution. Because the states of tasks and threads may change dynamically during computation, the returned value is only an approximation, but one that does not ever decrease across successive calls.") + "The approximate total number of tasks that have completed execution." + + " Because the states of tasks and threads may change dynamically" + + " during computation, the returned value is only an approximation," + + " but one that does not ever decrease across successive calls.") .hasUnit("{task}") .hasDataPointsWithAttributes( threadPoolAttributes, routeRelatedThreadPoolAttributes)) @@ -569,7 +612,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isGauge() .hasDescription( - "The largest number of threads that have ever simultaneously been in the pool.") + "The largest number of threads that have ever simultaneously been in the" + + " pool.") .hasUnit("{thread}") .hasDataPointsWithAttributes( threadPoolAttributes, routeRelatedThreadPoolAttributes)) @@ -588,7 +632,8 @@ private static MetricsVerifier createMetricsVerifier() { metric .isUpDownCounter() .hasDescription( - "The number of threads that are always kept in the pool, even if they are idle.") + "The number of threads that are always kept in the pool, even if they are" + + " idle.") .hasUnit("{thread}") .hasDataPointsWithAttributes( threadPoolAttributes, routeRelatedThreadPoolAttributes)) diff --git a/instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/rules/JvmTest.java b/instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/rules/JvmTest.java index 3869fc786e8e..574becb0790c 100644 --- a/instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/rules/JvmTest.java +++ b/instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/rules/JvmTest.java @@ -100,7 +100,8 @@ void testJvmMetrics(String image) { metric -> metric .hasDescription( - "Measure of memory used, as measured after the most recent garbage collection event on this pool.") + "Measure of memory used, as measured after the most recent garbage" + + " collection event on this pool.") .hasUnit("By") .isUpDownCounter() // note: there is no GC for non-heap memory @@ -185,7 +186,8 @@ void testJvmMetrics(String image) { metric -> metric .hasDescription( - "Average CPU load of the whole system for the last minute as reported by the JVM.") + "Average CPU load of the whole system for the last minute as reported" + + " by the JVM.") .hasUnit("{run_queue_item}") .isGauge() .hasDataPointsWithoutAttributes()) diff --git a/instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/rules/KafkaConnectTest.java b/instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/rules/KafkaConnectTest.java index e34fe7421bb5..0c655b758686 100644 --- a/instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/rules/KafkaConnectTest.java +++ b/instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/rules/KafkaConnectTest.java @@ -144,7 +144,8 @@ void metricsAreReportedFromKafkaConnectContainer() throws Exception { Set registeredMetrics = ConcurrentHashMap.newKeySet(); String kafkaCommand = - "/opt/kafka/bin/kafka-storage.sh format -t $(/opt/kafka/bin/kafka-storage.sh random-uuid) -c " + "/opt/kafka/bin/kafka-storage.sh format -t $(/opt/kafka/bin/kafka-storage.sh random-uuid)" + + " -c " + KAFKA_SERVER_PROPERTIES_PATH + " && /opt/kafka/bin/kafka-server-start.sh " + KAFKA_SERVER_PROPERTIES_PATH; @@ -406,7 +407,8 @@ private static MetricsVerifier createKafkaConnectMetricsVerifier() { metric -> metric .hasDescription( - "Connector lifecycle state indicator (1 when the state matches the attribute value). Supports Apache and Confluent status values.") + "Connector lifecycle state indicator (1 when the state matches the" + + " attribute value). Supports Apache and Confluent status values.") .hasUnit("1") .isUpDownCounter() .hasDataPointsWithAttributes( @@ -419,7 +421,8 @@ private static MetricsVerifier createKafkaConnectMetricsVerifier() { metric -> metric .hasDescription( - "The average number of records in the batches the task has processed so far.") + "The average number of records in the batches the task has processed so" + + " far.") .hasUnit("{record}") .isGauge() .hasDataPointsWithAttributes( @@ -467,7 +470,9 @@ private static MetricsVerifier createKafkaConnectMetricsVerifier() { metric -> metric .hasDescription( - "The status of the connector task. Supports Apache (unassigned, running, paused, failed, restarting) and Confluent (unassigned, running, paused, failed, destroyed) values.") + "The status of the connector task. Supports Apache (unassigned, running," + + " paused, failed, restarting) and Confluent (unassigned, running," + + " paused, failed, destroyed) values.") .hasUnit("1") .isUpDownCounter() .hasDataPointsWithAttributes( @@ -504,7 +509,8 @@ private static MetricsVerifier createKafkaConnectMetricsVerifier() { metric -> metric .hasDescription( - "The number of offset commit completions that were received too late and skipped/ignored.") + "The number of offset commit completions that were received too late and" + + " skipped/ignored.") .hasUnit("{commit}") .isCounter() .hasDataPointsWithAttributes( @@ -516,7 +522,8 @@ private static MetricsVerifier createKafkaConnectMetricsVerifier() { metric -> metric .hasDescription( - "The number of topic partitions assigned to this task belonging to the named sink connector in this worker.") + "The number of topic partitions assigned to this task belonging to the" + + " named sink connector in this worker.") .hasUnit("{partition}") .isUpDownCounter() .hasDataPointsWithAttributes( @@ -552,7 +559,8 @@ private static MetricsVerifier createKafkaConnectMetricsVerifier() { metric -> metric .hasDescription( - "The number of records that have been read from Kafka but not yet completely committed/flushed/acknowledged by the sink task.") + "The number of records that have been read from Kafka but not yet" + + " completely committed/flushed/acknowledged by the sink task.") .hasUnit("{record}") .isUpDownCounter() .hasDataPointsWithAttributes( @@ -564,7 +572,9 @@ private static MetricsVerifier createKafkaConnectMetricsVerifier() { metric -> metric .hasDescription( - "The count number of records read from Kafka by this task belonging to the named sink connector in this worker, since the task was last restarted.") + "The count number of records read from Kafka by this task belonging to the" + + " named sink connector in this worker, since the task was last" + + " restarted.") .hasUnit("{record}") .isCounter() .hasDataPointsWithAttributes( @@ -576,7 +586,9 @@ private static MetricsVerifier createKafkaConnectMetricsVerifier() { metric -> metric .hasDescription( - "The number of records output from the transformations and sent/put to this task belonging to the named sink connector in this worker, since the task was last restarted.") + "The number of records output from the transformations and sent/put to this" + + " task belonging to the named sink connector in this worker, since" + + " the task was last restarted.") .hasUnit("{record}") .isCounter() .hasDataPointsWithAttributes( @@ -589,7 +601,8 @@ private static MetricsVerifier createKafkaConnectMetricsVerifier() { metric -> metric .hasDescription( - "The average time in seconds taken by this task to poll for a batch of source records.") + "The average time in seconds taken by this task to poll for a batch of" + + " source records.") .hasUnit("s") .isGauge() .hasDataPointsWithAttributes( @@ -601,7 +614,8 @@ private static MetricsVerifier createKafkaConnectMetricsVerifier() { metric -> metric .hasDescription( - "The maximum time in seconds taken by this task to poll for a batch of source records.") + "The maximum time in seconds taken by this task to poll for a batch of" + + " source records.") .hasUnit("s") .isGauge() .hasDataPointsWithAttributes( @@ -613,7 +627,8 @@ private static MetricsVerifier createKafkaConnectMetricsVerifier() { metric -> metric .hasDescription( - "The number of records that have been produced by this task but not yet completely written to Kafka.") + "The number of records that have been produced by this task but not yet" + + " completely written to Kafka.") .hasUnit("{record}") .isUpDownCounter() .hasDataPointsWithAttributes( @@ -625,7 +640,8 @@ private static MetricsVerifier createKafkaConnectMetricsVerifier() { metric -> metric .hasDescription( - "The number of records produced/polled (before transformation) by this task belonging to the named source connector in this worker.") + "The number of records produced/polled (before transformation) by this task" + + " belonging to the named source connector in this worker.") .hasUnit("{record}") .isCounter() .hasDataPointsWithAttributes( @@ -637,7 +653,10 @@ private static MetricsVerifier createKafkaConnectMetricsVerifier() { metric -> metric .hasDescription( - "The number of records output written to Kafka for this task belonging to the named source connector in this worker, since the task was last restarted. This is after transformations are applied, and excludes any records filtered out by the transformations.") + "The number of records output written to Kafka for this task belonging to" + + " the named source connector in this worker, since the task was last" + + " restarted. This is after transformations are applied, and excludes" + + " any records filtered out by the transformations.") .hasUnit("{record}") .isCounter() .hasDataPointsWithAttributes( diff --git a/instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/rules/assertions/MetricAssert.java b/instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/rules/assertions/MetricAssert.java index a1f26a295ba6..aea3116e0eba 100644 --- a/instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/rules/assertions/MetricAssert.java +++ b/instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/rules/assertions/MetricAssert.java @@ -209,7 +209,8 @@ public final MetricAssert hasDataPointsWithDoubleValues( } info.description( - "for metric '%s' exactly one value assertion must be satisfied by the data point:\n%s", + "for metric '%s' exactly one value assertion must be satisfied by the data point:\n" + + "%s", actual.getName(), dataPoint); integers.assertEqual(info, matchCount, 1); } @@ -342,7 +343,9 @@ public MetricAssert hasDataPointsWithAttributes(AttributeMatcherGroup... matcher } info.description( - "data point attributes '%s' for metric '%s' must match exactly one of the attribute sets '%s'.\nActual data points: %s", + "data point attributes '%s' for metric '%s' must match exactly one of the" + + " attribute sets '%s'.\n" + + "Actual data points: %s", dataPointAttributes, actual.getName(), Arrays.asList(matcherGroups), diff --git a/instrumentation/jmx-metrics/testing-apps/camel-testing-app/build.gradle.kts b/instrumentation/jmx-metrics/testing-apps/camel-testing-app/build.gradle.kts index 48829dca98d9..ef0860501436 100644 --- a/instrumentation/jmx-metrics/testing-apps/camel-testing-app/build.gradle.kts +++ b/instrumentation/jmx-metrics/testing-apps/camel-testing-app/build.gradle.kts @@ -24,11 +24,14 @@ tasks { archiveClassifier.set("") duplicatesStrategy = DuplicatesStrategy.EXCLUDE manifest { - attributes("Main-Class" to "io.opentelemetry.instrumentation.jmx.cameltest.CamelTestApplication") + attributes( + "Main-Class" to "io.opentelemetry.instrumentation.jmx.cameltest.CamelTestApplication", + ) } from(sourceSets.main.get().output) from({ - configurations.runtimeClasspath.get() + configurations.runtimeClasspath + .get() .filter { it.name.endsWith(".jar") } .map { zipTree(it) } }) diff --git a/instrumentation/jodd-http-4.2/javaagent/build.gradle.kts b/instrumentation/jodd-http-4.2/javaagent/build.gradle.kts index 4c581415a3db..15b2f4df6f33 100644 --- a/instrumentation/jodd-http-4.2/javaagent/build.gradle.kts +++ b/instrumentation/jodd-http-4.2/javaagent/build.gradle.kts @@ -25,7 +25,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/jsf/jsf-mojarra-1.2/javaagent/build.gradle.kts b/instrumentation/jsf/jsf-mojarra-1.2/javaagent/build.gradle.kts index 50511ead7898..72adcdc05129 100644 --- a/instrumentation/jsf/jsf-mojarra-1.2/javaagent/build.gradle.kts +++ b/instrumentation/jsf/jsf-mojarra-1.2/javaagent/build.gradle.kts @@ -88,6 +88,9 @@ tasks { withType().configureEach { jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true") systemProperty("collectMetadata", otelProps.collectMetadata) - systemProperty("metadataConfig", "otel.instrumentation.common.experimental.controller-telemetry.enabled=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.common.experimental.controller-telemetry.enabled=true", + ) } } diff --git a/instrumentation/jsf/jsf-mojarra-3.0/javaagent/build.gradle.kts b/instrumentation/jsf/jsf-mojarra-3.0/javaagent/build.gradle.kts index e1b9c28468b3..76e3df3efd60 100644 --- a/instrumentation/jsf/jsf-mojarra-3.0/javaagent/build.gradle.kts +++ b/instrumentation/jsf/jsf-mojarra-3.0/javaagent/build.gradle.kts @@ -41,6 +41,9 @@ tasks { withType().configureEach { jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true") systemProperty("collectMetadata", otelProps.collectMetadata) - systemProperty("metadataConfig", "otel.instrumentation.common.experimental.controller-telemetry.enabled=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.common.experimental.controller-telemetry.enabled=true", + ) } } diff --git a/instrumentation/jsf/jsf-myfaces-1.2/javaagent/build.gradle.kts b/instrumentation/jsf/jsf-myfaces-1.2/javaagent/build.gradle.kts index 80b019d33d0c..fef8eda1a52a 100644 --- a/instrumentation/jsf/jsf-myfaces-1.2/javaagent/build.gradle.kts +++ b/instrumentation/jsf/jsf-myfaces-1.2/javaagent/build.gradle.kts @@ -58,5 +58,8 @@ tasks { tasks.withType().configureEach { jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true") systemProperty("collectMetadata", otelProps.collectMetadata) - systemProperty("metadataConfig", "otel.instrumentation.common.experimental.controller-telemetry.enabled=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.common.experimental.controller-telemetry.enabled=true", + ) } diff --git a/instrumentation/jsf/jsf-myfaces-3.0/javaagent/build.gradle.kts b/instrumentation/jsf/jsf-myfaces-3.0/javaagent/build.gradle.kts index 6a552c76dffa..0965a12c20d0 100644 --- a/instrumentation/jsf/jsf-myfaces-3.0/javaagent/build.gradle.kts +++ b/instrumentation/jsf/jsf-myfaces-3.0/javaagent/build.gradle.kts @@ -41,6 +41,9 @@ tasks { withType().configureEach { jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true") systemProperty("collectMetadata", otelProps.collectMetadata) - systemProperty("metadataConfig", "otel.instrumentation.common.experimental.controller-telemetry.enabled=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.common.experimental.controller-telemetry.enabled=true", + ) } } diff --git a/instrumentation/jsp-2.3/javaagent/build.gradle.kts b/instrumentation/jsp-2.3/javaagent/build.gradle.kts index 5d7a143b0697..7973139a93c4 100644 --- a/instrumentation/jsp-2.3/javaagent/build.gradle.kts +++ b/instrumentation/jsp-2.3/javaagent/build.gradle.kts @@ -61,15 +61,24 @@ tasks { } test { - systemProperty("metadataConfig", "otel.instrumentation.common.experimental.view-telemetry.enabled=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.common.experimental.view-telemetry.enabled=true", + ) } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.jsp.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.common.experimental.view-telemetry.enabled=true,otel.instrumentation.jsp.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.common.experimental.view-telemetry.enabled=true,otel.instrumentation.jsp.experimental-span-attributes=true", + ) } check { diff --git a/instrumentation/kafka/kafka-clients/kafka-clients-0.11/javaagent/build.gradle.kts b/instrumentation/kafka/kafka-clients/kafka-clients-0.11/javaagent/build.gradle.kts index 42e58d34f7fd..1b045745dc36 100644 --- a/instrumentation/kafka/kafka-clients/kafka-clients-0.11/javaagent/build.gradle.kts +++ b/instrumentation/kafka/kafka-clients/kafka-clients-0.11/javaagent/build.gradle.kts @@ -34,7 +34,10 @@ tasks { } val testPropagationDisabled by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { includeTestsMatching("KafkaClientPropagationDisabledTest") @@ -44,7 +47,10 @@ tasks { } val testReceiveSpansDisabled by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { includeTestsMatching("KafkaClientSuppressReceiveSpansTest") @@ -53,7 +59,10 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { @@ -67,7 +76,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { excludeTestsMatching("KafkaClientPropagationDisabledTest") diff --git a/instrumentation/kafka/kafka-clients/kafka-clients-0.11/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/kafkaclients/v0_11/OpenTelemetryMetricsReporterTest.java b/instrumentation/kafka/kafka-clients/kafka-clients-0.11/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/kafkaclients/v0_11/OpenTelemetryMetricsReporterTest.java index 36b12f82031d..e4713fe55fde 100644 --- a/instrumentation/kafka/kafka-clients/kafka-clients-0.11/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/kafkaclients/v0_11/OpenTelemetryMetricsReporterTest.java +++ b/instrumentation/kafka/kafka-clients/kafka-clients-0.11/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/kafkaclients/v0_11/OpenTelemetryMetricsReporterTest.java @@ -23,7 +23,8 @@ named = "testLatestDeps", matches = "true", disabledReason = - "kafka-clients 0.11 emits a significantly different set of metrics; it's probably fine to just test the latest version") + "kafka-clients 0.11 emits a significantly different set of metrics; it's probably fine to" + + " just test the latest version") class OpenTelemetryMetricsReporterTest extends AbstractOpenTelemetryMetricsReporterTest { @RegisterExtension diff --git a/instrumentation/kafka/kafka-clients/kafka-clients-0.11/testing/src/main/java/io/opentelemetry/instrumentation/kafkaclients/common/v0_11/internal/AbstractOpenTelemetryMetricsReporterTest.java b/instrumentation/kafka/kafka-clients/kafka-clients-0.11/testing/src/main/java/io/opentelemetry/instrumentation/kafkaclients/common/v0_11/internal/AbstractOpenTelemetryMetricsReporterTest.java index 86cea4aa4417..57f2cbd063a8 100644 --- a/instrumentation/kafka/kafka-clients/kafka-clients-0.11/testing/src/main/java/io/opentelemetry/instrumentation/kafkaclients/common/v0_11/internal/AbstractOpenTelemetryMetricsReporterTest.java +++ b/instrumentation/kafka/kafka-clients/kafka-clients-0.11/testing/src/main/java/io/opentelemetry/instrumentation/kafkaclients/common/v0_11/internal/AbstractOpenTelemetryMetricsReporterTest.java @@ -414,7 +414,8 @@ private static void printMappingTable() { StringBuilder sb = new StringBuilder(); // Append table headers sb.append( - "| Metric Group | Metric Name | Attribute Keys | Instrument Name | Instrument Description | Instrument Type |") + "| Metric Group | Metric Name | Attribute Keys | Instrument Name | Instrument" + + " Description | Instrument Type |") .append(lineSeparator()) .append( "|--------------|-------------|----------------|-----------------|------------------------|-----------------|") diff --git a/instrumentation/kafka/kafka-clients/kafka-clients-2.6/library/src/test/java/io/opentelemetry/instrumentation/kafkaclients/v2_6/internal/OpenTelemetryConsumerInterceptorTest.java b/instrumentation/kafka/kafka-clients/kafka-clients-2.6/library/src/test/java/io/opentelemetry/instrumentation/kafkaclients/v2_6/internal/OpenTelemetryConsumerInterceptorTest.java index ce5e9014c773..f0c2e74668f9 100644 --- a/instrumentation/kafka/kafka-clients/kafka-clients-2.6/library/src/test/java/io/opentelemetry/instrumentation/kafkaclients/v2_6/internal/OpenTelemetryConsumerInterceptorTest.java +++ b/instrumentation/kafka/kafka-clients/kafka-clients-2.6/library/src/test/java/io/opentelemetry/instrumentation/kafkaclients/v2_6/internal/OpenTelemetryConsumerInterceptorTest.java @@ -49,7 +49,8 @@ void badConfig() { }) .hasRootCauseInstanceOf(IllegalStateException.class) .hasRootCauseMessage( - "Configuration property opentelemetry.kafka-consumer-telemetry.supplier is not instance of KafkaConsumerTelemetrySupplier"); + "Configuration property opentelemetry.kafka-consumer-telemetry.supplier is not instance" + + " of KafkaConsumerTelemetrySupplier"); // Bad config - supplier returns wrong type assertThatThrownBy( @@ -62,7 +63,8 @@ void badConfig() { }) .hasRootCauseInstanceOf(IllegalStateException.class) .hasRootCauseMessage( - "Configuration property opentelemetry.kafka-consumer-telemetry.supplier is not instance of KafkaConsumerTelemetrySupplier"); + "Configuration property opentelemetry.kafka-consumer-telemetry.supplier is not instance" + + " of KafkaConsumerTelemetrySupplier"); } @Test diff --git a/instrumentation/kafka/kafka-clients/kafka-clients-2.6/library/src/test/java/io/opentelemetry/instrumentation/kafkaclients/v2_6/internal/OpenTelemetryMetricsReporterTest.java b/instrumentation/kafka/kafka-clients/kafka-clients-2.6/library/src/test/java/io/opentelemetry/instrumentation/kafkaclients/v2_6/internal/OpenTelemetryMetricsReporterTest.java index e92666d90755..8199cba6b790 100644 --- a/instrumentation/kafka/kafka-clients/kafka-clients-2.6/library/src/test/java/io/opentelemetry/instrumentation/kafkaclients/v2_6/internal/OpenTelemetryMetricsReporterTest.java +++ b/instrumentation/kafka/kafka-clients/kafka-clients-2.6/library/src/test/java/io/opentelemetry/instrumentation/kafkaclients/v2_6/internal/OpenTelemetryMetricsReporterTest.java @@ -54,7 +54,8 @@ void badConfig() { }) .hasRootCauseInstanceOf(IllegalStateException.class) .hasRootCauseMessage( - "Configuration property opentelemetry.supplier is not instance of OpenTelemetrySupplier"); + "Configuration property opentelemetry.supplier is not instance of" + + " OpenTelemetrySupplier"); assertThatThrownBy( () -> { Map producerConfig = producerConfig(); @@ -94,7 +95,8 @@ void badConfig() { }) .hasRootCauseInstanceOf(IllegalStateException.class) .hasRootCauseMessage( - "Configuration property opentelemetry.supplier is not instance of OpenTelemetrySupplier"); + "Configuration property opentelemetry.supplier is not instance of" + + " OpenTelemetrySupplier"); assertThatThrownBy( () -> { Map consumerConfig = consumerConfig(); diff --git a/instrumentation/kafka/kafka-clients/kafka-clients-2.6/library/src/test/java/io/opentelemetry/instrumentation/kafkaclients/v2_6/internal/OpenTelemetryProducerInterceptorTest.java b/instrumentation/kafka/kafka-clients/kafka-clients-2.6/library/src/test/java/io/opentelemetry/instrumentation/kafkaclients/v2_6/internal/OpenTelemetryProducerInterceptorTest.java index 860007c9cad5..4b5508c29b25 100644 --- a/instrumentation/kafka/kafka-clients/kafka-clients-2.6/library/src/test/java/io/opentelemetry/instrumentation/kafkaclients/v2_6/internal/OpenTelemetryProducerInterceptorTest.java +++ b/instrumentation/kafka/kafka-clients/kafka-clients-2.6/library/src/test/java/io/opentelemetry/instrumentation/kafkaclients/v2_6/internal/OpenTelemetryProducerInterceptorTest.java @@ -48,7 +48,8 @@ void badConfig() { }) .hasRootCauseInstanceOf(IllegalStateException.class) .hasRootCauseMessage( - "Configuration property opentelemetry.kafka-producer-telemetry.supplier is not instance of KafkaProducerTelemetrySupplier"); + "Configuration property opentelemetry.kafka-producer-telemetry.supplier is not instance" + + " of KafkaProducerTelemetrySupplier"); // Bad config - supplier returns wrong type assertThatThrownBy( @@ -61,7 +62,8 @@ void badConfig() { }) .hasRootCauseInstanceOf(IllegalStateException.class) .hasRootCauseMessage( - "Configuration property opentelemetry.kafka-producer-telemetry.supplier is not instance of KafkaProducerTelemetrySupplier"); + "Configuration property opentelemetry.kafka-producer-telemetry.supplier is not instance" + + " of KafkaProducerTelemetrySupplier"); } @Test diff --git a/instrumentation/kafka/kafka-connect-2.6/testing/build.gradle.kts b/instrumentation/kafka/kafka-connect-2.6/testing/build.gradle.kts index 825b831f2855..b29b0ff489d9 100644 --- a/instrumentation/kafka/kafka-connect-2.6/testing/build.gradle.kts +++ b/instrumentation/kafka/kafka-connect-2.6/testing/build.gradle.kts @@ -34,13 +34,23 @@ dependencies { tasks.withType().configureEach { dependsOn(agentShadowJar) usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service) - systemProperty("io.opentelemetry.smoketest.agent.shadowJar.path", agentShadowJar.get().archiveFile.get().toString()) + systemProperty( + "io.opentelemetry.smoketest.agent.shadowJar.path", + agentShadowJar + .get() + .archiveFile + .get() + .toString(), + ) systemProperty("collectMetadata", otelProps.collectMetadata) } tasks { val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database") diff --git a/instrumentation/kafka/kafka-connect-2.6/testing/src/test/java/io/opentelemetry/instrumentation/kafkaconnect/v2_6/KafkaConnectSinkTaskBaseTest.java b/instrumentation/kafka/kafka-connect-2.6/testing/src/test/java/io/opentelemetry/instrumentation/kafkaconnect/v2_6/KafkaConnectSinkTaskBaseTest.java index fe80feed24fb..9bf39b8039e7 100644 --- a/instrumentation/kafka/kafka-connect-2.6/testing/src/test/java/io/opentelemetry/instrumentation/kafkaconnect/v2_6/KafkaConnectSinkTaskBaseTest.java +++ b/instrumentation/kafka/kafka-connect-2.6/testing/src/test/java/io/opentelemetry/instrumentation/kafkaconnect/v2_6/KafkaConnectSinkTaskBaseTest.java @@ -303,9 +303,9 @@ private void setupKafkaConnect() { "-c", "mkdir -p /var/log/kafka-connect && " + getConnectorInstallCommand() - + " && " - + "echo 'Starting Kafka Connect with logging to /var/log/kafka-connect/' && " - + "/etc/confluent/docker/run 2>&1 | tee /var/log/kafka-connect/kafka-connect.log"); + + " && echo 'Starting Kafka Connect with logging to /var/log/kafka-connect/' &&" + + " /etc/confluent/docker/run 2>&1 | tee" + + " /var/log/kafka-connect/kafka-connect.log"); } @BeforeEach diff --git a/instrumentation/kafka/kafka-streams-0.11/javaagent/build.gradle.kts b/instrumentation/kafka/kafka-streams-0.11/javaagent/build.gradle.kts index 6eff1731b3c5..e5e73615cc54 100644 --- a/instrumentation/kafka/kafka-streams-0.11/javaagent/build.gradle.kts +++ b/instrumentation/kafka/kafka-streams-0.11/javaagent/build.gradle.kts @@ -33,7 +33,10 @@ tasks { } val testReceiveSpansDisabled by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { includeTestsMatching("KafkaStreamsSuppressReceiveSpansTest") @@ -42,7 +45,10 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { diff --git a/instrumentation/kotlinx-coroutines/kotlinx-coroutines-1.0/javaagent/build.gradle.kts b/instrumentation/kotlinx-coroutines/kotlinx-coroutines-1.0/javaagent/build.gradle.kts index 3e1be05c41ff..aeb9ac263676 100644 --- a/instrumentation/kotlinx-coroutines/kotlinx-coroutines-1.0/javaagent/build.gradle.kts +++ b/instrumentation/kotlinx-coroutines/kotlinx-coroutines-1.0/javaagent/build.gradle.kts @@ -26,11 +26,18 @@ muzzle { dependencies { compileOnly("io.opentelemetry:opentelemetry-extension-kotlin") compileOnly("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - compileOnly(project(":opentelemetry-instrumentation-annotations-shaded-for-instrumenting", configuration = "shadow")) + compileOnly( + project( + ":opentelemetry-instrumentation-annotations-shaded-for-instrumenting", + configuration = "shadow", + ), + ) implementation("org.ow2.asm:asm-tree") implementation("org.ow2.asm:asm-util") - implementation(project(":instrumentation:opentelemetry-instrumentation-annotations-1.16:javaagent")) + implementation( + project(":instrumentation:opentelemetry-instrumentation-annotations-1.16:javaagent"), + ) testInstrumentation(project(":instrumentation:opentelemetry-extension-kotlin-1.0:javaagent")) testInstrumentation(project(":instrumentation:reactor:reactor-3.1:javaagent")) diff --git a/instrumentation/kotlinx-coroutines/kotlinx-coroutines-1.0/javaagent/src/test/kotlin/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/ClazzWithDefaultConstructorArguments.kt b/instrumentation/kotlinx-coroutines/kotlinx-coroutines-1.0/javaagent/src/test/kotlin/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/ClazzWithDefaultConstructorArguments.kt index 5be13c6958a9..cec12c28fb7d 100644 --- a/instrumentation/kotlinx-coroutines/kotlinx-coroutines-1.0/javaagent/src/test/kotlin/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/ClazzWithDefaultConstructorArguments.kt +++ b/instrumentation/kotlinx-coroutines/kotlinx-coroutines-1.0/javaagent/src/test/kotlin/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/ClazzWithDefaultConstructorArguments.kt @@ -8,8 +8,9 @@ package io.opentelemetry.javaagent.instrumentation.kotlinxcoroutines import io.opentelemetry.instrumentation.annotations.WithSpan import kotlinx.coroutines.delay -class ClazzWithDefaultConstructorArguments(val name: String = "Ktor") { - +class ClazzWithDefaultConstructorArguments( + val name: String = "Ktor" +) { @WithSpan suspend fun sayHello(): String { delay(10) diff --git a/instrumentation/kotlinx-coroutines/kotlinx-coroutines-1.0/javaagent/src/test/kotlin/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/KotlinCoroutinesInstrumentationTest.kt b/instrumentation/kotlinx-coroutines/kotlinx-coroutines-1.0/javaagent/src/test/kotlin/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/KotlinCoroutinesInstrumentationTest.kt index bf0f2951a902..fa633451e064 100644 --- a/instrumentation/kotlinx-coroutines/kotlinx-coroutines-1.0/javaagent/src/test/kotlin/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/KotlinCoroutinesInstrumentationTest.kt +++ b/instrumentation/kotlinx-coroutines/kotlinx-coroutines-1.0/javaagent/src/test/kotlin/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/KotlinCoroutinesInstrumentationTest.kt @@ -60,7 +60,6 @@ import kotlin.coroutines.CoroutineContext @TestInstance(TestInstance.Lifecycle.PER_CLASS) @ExperimentalCoroutinesApi class KotlinCoroutinesInstrumentationTest { - companion object { val threadPool = Executors.newFixedThreadPool(2) val singleThread = Executors.newSingleThreadExecutor() @@ -101,11 +100,13 @@ class KotlinCoroutinesInstrumentationTest { { trace -> trace.hasSpansSatisfyingExactly( { - it.hasName("parent") + it + .hasName("parent") .hasNoParent() }, { - it.hasName("preLaunch") + it + .hasName("preLaunch") .hasParent(trace.getSpan(0)) }, ) @@ -129,11 +130,13 @@ class KotlinCoroutinesInstrumentationTest { { trace -> trace.hasSpansSatisfyingExactly( { - it.hasName("parent") + it + .hasName("parent") .hasNoParent() }, { - it.hasName("nested") + it + .hasName("nested") .hasParent(trace.getSpan(0)) }, ) @@ -146,19 +149,22 @@ class KotlinCoroutinesInstrumentationTest { runTest(Dispatchers.Default) { val keptPromise = CompletableDeferred() val brokenPromise = CompletableDeferred() - val afterPromise = async { - keptPromise.await() - tracedChild("keptPromise") - } - val afterPromise2 = async { - listOf(afterPromise, keptPromise).awaitAll() - tracedChild("keptPromise2") - } - val failedAfterPromise = async { - brokenPromise - .runCatching { await() } - .onFailure { tracedChild("brokenPromise") } - } + val afterPromise = + async { + keptPromise.await() + tracedChild("keptPromise") + } + val afterPromise2 = + async { + listOf(afterPromise, keptPromise).awaitAll() + tracedChild("keptPromise2") + } + val failedAfterPromise = + async { + brokenPromise + .runCatching { await() } + .onFailure { tracedChild("brokenPromise") } + } launch { tracedChild("future1") @@ -173,23 +179,28 @@ class KotlinCoroutinesInstrumentationTest { { trace -> trace.hasSpansSatisfyingExactlyInAnyOrder( { - it.hasName("parent") + it + .hasName("parent") .hasNoParent() }, { - it.hasName("future1") + it + .hasName("future1") .hasParent(trace.getSpan(0)) }, { - it.hasName("keptPromise") + it + .hasName("keptPromise") .hasParent(trace.getSpan(0)) }, { - it.hasName("keptPromise2") + it + .hasName("keptPromise2") .hasParent(trace.getSpan(0)) }, { - it.hasName("brokenPromise") + it + .hasName("brokenPromise") .hasParent(trace.getSpan(0)) }, ) @@ -200,20 +211,21 @@ class KotlinCoroutinesInstrumentationTest { @Test fun `first completed deferred`() { runTest(Dispatchers.Default) { - val children = listOf( - async { - tracedChild("timeout1") - false - }, - async { - tracedChild("timeout2") - false - }, - async { - tracedChild("timeout3") - true - }, - ) + val children = + listOf( + async { + tracedChild("timeout1") + false + }, + async { + tracedChild("timeout2") + false + }, + async { + tracedChild("timeout3") + true + }, + ) withTimeout(TimeUnit.SECONDS.toMillis(30)) { select { @@ -276,11 +288,13 @@ class KotlinCoroutinesInstrumentationTest { assertions.add { trace -> trace.hasSpansSatisfyingExactly( { - it.hasName("a") + it + .hasName("a") .hasNoParent() }, { - it.hasName("a2") + it + .hasName("a2") .hasParent(trace.getSpan(0)) }, ) @@ -290,11 +304,13 @@ class KotlinCoroutinesInstrumentationTest { assertions.add { trace -> trace.hasSpansSatisfyingExactly( { - it.hasName("b") + it + .hasName("b") .hasNoParent() }, { - it.hasName("b2") + it + .hasName("b2") .hasParent(trace.getSpan(0)) }, ) @@ -320,11 +336,13 @@ class KotlinCoroutinesInstrumentationTest { { trace -> trace.hasSpansSatisfyingExactly( { - it.hasName("parent") + it + .hasName("parent") .hasNoParent() }, { - it.hasName("child") + it + .hasName("child") .hasParent(trace.getSpan(0)) }, ) @@ -355,15 +373,18 @@ class KotlinCoroutinesInstrumentationTest { { trace -> trace.hasSpansSatisfyingExactly( { - it.hasName("parent") + it + .hasName("parent") .hasNoParent() }, { - it.hasName("nested1") + it + .hasName("nested1") .hasParent(trace.getSpan(0)) }, { - it.hasName("nested2") + it + .hasName("nested2") .hasParent(trace.getSpan(0)) }, ) @@ -393,14 +414,16 @@ class KotlinCoroutinesInstrumentationTest { { trace -> trace.hasSpansSatisfyingExactly( { - it.hasName("a1") + it + .hasName("a1") .hasNoParent() .hasAttributesSatisfyingExactly( codeFunctionAssertions(this.javaClass, "annotated1") ) }, { - it.hasName("KotlinCoroutinesInstrumentationTest.annotated2") + it + .hasName("KotlinCoroutinesInstrumentationTest.annotated2") .hasParent(trace.getSpan(0)) .hasAttributesSatisfyingExactly(assertions) } @@ -443,7 +466,8 @@ class KotlinCoroutinesInstrumentationTest { { trace -> trace.hasSpansSatisfyingExactly( { - it.hasName("ClazzWithDefaultConstructorArguments.sayHello") + it + .hasName("ClazzWithDefaultConstructorArguments.sayHello") .hasNoParent() .hasAttributesSatisfyingExactly( codeFunctionAssertions(ClazzWithDefaultConstructorArguments::class.qualifiedName, "sayHello") @@ -458,9 +482,15 @@ class KotlinCoroutinesInstrumentationTest { tracer.spanBuilder(opName).startSpan().end() } - private fun runTest(dispatcherWrapper: DispatcherWrapper, block: suspend CoroutineScope.() -> T): T = runTest(dispatcherWrapper.dispatcher, block) + private fun runTest( + dispatcherWrapper: DispatcherWrapper, + block: suspend CoroutineScope.() -> T + ): T = runTest(dispatcherWrapper.dispatcher, block) - private fun runTest(dispatcher: CoroutineDispatcher, block: suspend CoroutineScope.() -> T): T { + private fun runTest( + dispatcher: CoroutineDispatcher, + block: suspend CoroutineScope.() -> T + ): T { val parentSpan = tracer.spanBuilder("parent").startSpan() val parentScope = parentSpan.makeCurrent() try { @@ -509,18 +539,21 @@ class KotlinCoroutinesInstrumentationTest { span.end() } - private fun dispatchersSourceArguments(): Stream = Stream.of( - // Wrap dispatchers since it seems that ParameterizedTest tries to automatically close - // Closeable arguments with no way to avoid it. - arguments(DispatcherWrapper(Dispatchers.Default)), - arguments(DispatcherWrapper(Dispatchers.IO)), - arguments(DispatcherWrapper(Dispatchers.Unconfined)), - arguments(DispatcherWrapper(threadPool.asCoroutineDispatcher())), - arguments(DispatcherWrapper(singleThread.asCoroutineDispatcher())), - arguments(DispatcherWrapper(vertx.dispatcher())) - ) - - class DispatcherWrapper(val dispatcher: CoroutineDispatcher) { + private fun dispatchersSourceArguments(): Stream = + Stream.of( + // Wrap dispatchers since it seems that ParameterizedTest tries to automatically close + // Closeable arguments with no way to avoid it. + arguments(DispatcherWrapper(Dispatchers.Default)), + arguments(DispatcherWrapper(Dispatchers.IO)), + arguments(DispatcherWrapper(Dispatchers.Unconfined)), + arguments(DispatcherWrapper(threadPool.asCoroutineDispatcher())), + arguments(DispatcherWrapper(singleThread.asCoroutineDispatcher())), + arguments(DispatcherWrapper(vertx.dispatcher())) + ) + + class DispatcherWrapper( + val dispatcher: CoroutineDispatcher + ) { override fun toString(): String = dispatcher.toString() } @@ -544,14 +577,19 @@ class KotlinCoroutinesInstrumentationTest { } } - class TestContextElement(private val otelContext: Context) : ThreadContextElement { + class TestContextElement( + private val otelContext: Context + ) : ThreadContextElement { companion object Key : CoroutineContext.Key { } override val key: CoroutineContext.Key get() = Key - override fun restoreThreadContext(context: CoroutineContext, oldState: Scope) { + override fun restoreThreadContext( + context: CoroutineContext, + oldState: Scope + ) { oldState.close() } @@ -574,13 +612,15 @@ class KotlinCoroutinesInstrumentationTest { testing.waitAndAssertTraces( { trace -> trace.hasSpansSatisfyingExactly({ - it.hasName("parent") + it + .hasName("parent") .hasNoParent() }) }, { trace -> trace.hasSpansSatisfyingExactly({ - it.hasName("dispatched") + it + .hasName("dispatched") .hasNoParent() }) } diff --git a/instrumentation/kotlinx-coroutines/kotlinx-coroutines-flow-1.3/javaagent-kotlin/src/main/kotlin/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/flow/FlowUtil.kt b/instrumentation/kotlinx-coroutines/kotlinx-coroutines-flow-1.3/javaagent-kotlin/src/main/kotlin/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/flow/FlowUtil.kt index 402251782cba..e33be77875ed 100644 --- a/instrumentation/kotlinx-coroutines/kotlinx-coroutines-flow-1.3/javaagent-kotlin/src/main/kotlin/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/flow/FlowUtil.kt +++ b/instrumentation/kotlinx-coroutines/kotlinx-coroutines-flow-1.3/javaagent-kotlin/src/main/kotlin/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/flow/FlowUtil.kt @@ -10,6 +10,12 @@ import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.onCompletion -fun onComplete(flow: Flow<*>, instrumenter: Instrumenter, context: Context, request: REQUEST & Any): Flow<*> = flow.onCompletion { cause: Throwable? -> - instrumenter.end(context, request, null, cause) -} +fun onComplete( + flow: Flow<*>, + instrumenter: Instrumenter, + context: Context, + request: REQUEST & Any +): Flow<*> = + flow.onCompletion { cause: Throwable? -> + instrumenter.end(context, request, null, cause) + } diff --git a/instrumentation/kotlinx-coroutines/kotlinx-coroutines-flow-1.3/javaagent/build.gradle.kts b/instrumentation/kotlinx-coroutines/kotlinx-coroutines-flow-1.3/javaagent/build.gradle.kts index 1d4320aefda6..607a16d0400b 100644 --- a/instrumentation/kotlinx-coroutines/kotlinx-coroutines-flow-1.3/javaagent/build.gradle.kts +++ b/instrumentation/kotlinx-coroutines/kotlinx-coroutines-flow-1.3/javaagent/build.gradle.kts @@ -22,9 +22,13 @@ muzzle { dependencies { library("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0") compileOnly(project(":instrumentation-annotations-support")) - implementation(project(":instrumentation:kotlinx-coroutines:kotlinx-coroutines-flow-1.3:javaagent-kotlin")) + implementation( + project(":instrumentation:kotlinx-coroutines:kotlinx-coroutines-flow-1.3:javaagent-kotlin"), + ) - testInstrumentation(project(":instrumentation:kotlinx-coroutines:kotlinx-coroutines-1.0:javaagent")) + testInstrumentation( + project(":instrumentation:kotlinx-coroutines:kotlinx-coroutines-1.0:javaagent"), + ) testInstrumentation(project(":instrumentation:opentelemetry-extension-kotlin-1.0:javaagent")) testInstrumentation(project(":instrumentation:reactor:reactor-3.1:javaagent")) diff --git a/instrumentation/kotlinx-coroutines/kotlinx-coroutines-flow-1.3/javaagent/src/test/kotlin/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/KotlinCoroutines13InstrumentationTest.kt b/instrumentation/kotlinx-coroutines/kotlinx-coroutines-flow-1.3/javaagent/src/test/kotlin/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/KotlinCoroutines13InstrumentationTest.kt index 11acbd446894..46044a590e0b 100644 --- a/instrumentation/kotlinx-coroutines/kotlinx-coroutines-flow-1.3/javaagent/src/test/kotlin/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/KotlinCoroutines13InstrumentationTest.kt +++ b/instrumentation/kotlinx-coroutines/kotlinx-coroutines-flow-1.3/javaagent/src/test/kotlin/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/KotlinCoroutines13InstrumentationTest.kt @@ -38,7 +38,6 @@ import java.util.stream.Stream @TestInstance(TestInstance.Lifecycle.PER_CLASS) @ExperimentalCoroutinesApi class KotlinCoroutines13InstrumentationTest { - companion object { val threadPool = Executors.newFixedThreadPool(2) val singleThread = Executors.newSingleThreadExecutor() @@ -59,47 +58,57 @@ class KotlinCoroutines13InstrumentationTest { @MethodSource("dispatchersSourceArguments") fun `traced across channels`(dispatcher: DispatcherWrapper) { runTest(dispatcher) { - val producer = produce { - repeat(3) { - tracedChild("produce_$it") - send(it) + val producer = + produce { + repeat(3) { + tracedChild("produce_$it") + send(it) + } } - } - producer.consumeAsFlow().onEach { - tracedChild("consume_$it") - }.collect() + producer + .consumeAsFlow() + .onEach { + tracedChild("consume_$it") + }.collect() } testing.waitAndAssertTraces( { trace -> trace.hasSpansSatisfyingExactlyInAnyOrder( { - it.hasName("parent") + it + .hasName("parent") .hasNoParent() }, { - it.hasName("produce_0") + it + .hasName("produce_0") .hasParent(trace.getSpan(0)) }, { - it.hasName("consume_0") + it + .hasName("consume_0") .hasParent(trace.getSpan(0)) }, { - it.hasName("produce_1") + it + .hasName("produce_1") .hasParent(trace.getSpan(0)) }, { - it.hasName("consume_1") + it + .hasName("consume_1") .hasParent(trace.getSpan(0)) }, { - it.hasName("produce_2") + it + .hasName("produce_2") .hasParent(trace.getSpan(0)) }, { - it.hasName("consume_2") + it + .hasName("consume_2") .hasParent(trace.getSpan(0)) }, ) @@ -114,14 +123,15 @@ class KotlinCoroutines13InstrumentationTest { val currentContext = Context.current() // clear current context to ensure that ContextPropagationOperator is used for context propagation withContext(Context.root().asContextElement()) { - val mono = mono(dispatcherWrapper.dispatcher) { - // extract context from reactor and propagate it into coroutine - val reactorContext = coroutineContext[ReactorContext.Key]?.context - val otelContext = ContextPropagationOperator.getOpenTelemetryContext(reactorContext, Context.current()) - withContext(otelContext.asContextElement()) { - tracedChild("child") + val mono = + mono(dispatcherWrapper.dispatcher) { + // extract context from reactor and propagate it into coroutine + val reactorContext = coroutineContext[ReactorContext.Key]?.context + val otelContext = ContextPropagationOperator.getOpenTelemetryContext(reactorContext, Context.current()) + withContext(otelContext.asContextElement()) { + tracedChild("child") + } } - } ContextPropagationOperator.runWithContext(mono, currentContext).awaitSingle() } } @@ -130,11 +140,13 @@ class KotlinCoroutines13InstrumentationTest { { trace -> trace.hasSpansSatisfyingExactly( { - it.hasName("parent") + it + .hasName("parent") .hasNoParent() }, { - it.hasName("child") + it + .hasName("child") .hasParent(trace.getSpan(0)) }, ) @@ -159,19 +171,23 @@ class KotlinCoroutines13InstrumentationTest { { trace -> trace.hasSpansSatisfyingExactly( { - it.hasName("parent") + it + .hasName("parent") .hasNoParent() }, { - it.hasName("child_0") + it + .hasName("child_0") .hasParent(trace.getSpan(0)) }, { - it.hasName("child_1") + it + .hasName("child_1") .hasParent(trace.getSpan(0)) }, { - it.hasName("child_2") + it + .hasName("child_2") .hasParent(trace.getSpan(0)) }, ) @@ -183,9 +199,15 @@ class KotlinCoroutines13InstrumentationTest { tracer.spanBuilder(opName).startSpan().end() } - private fun runTest(dispatcherWrapper: DispatcherWrapper, block: suspend CoroutineScope.() -> T): T = runTest(dispatcherWrapper.dispatcher, block) + private fun runTest( + dispatcherWrapper: DispatcherWrapper, + block: suspend CoroutineScope.() -> T + ): T = runTest(dispatcherWrapper.dispatcher, block) - private fun runTest(dispatcher: CoroutineDispatcher, block: suspend CoroutineScope.() -> T): T { + private fun runTest( + dispatcher: CoroutineDispatcher, + block: suspend CoroutineScope.() -> T + ): T { val parentSpan = tracer.spanBuilder("parent").startSpan() val parentScope = parentSpan.makeCurrent() try { @@ -196,17 +218,20 @@ class KotlinCoroutines13InstrumentationTest { } } - private fun dispatchersSourceArguments(): Stream = Stream.of( - // Wrap dispatchers since it seems that ParameterizedTest tries to automatically close - // Closeable arguments with no way to avoid it. - arguments(DispatcherWrapper(Dispatchers.Default)), - arguments(DispatcherWrapper(Dispatchers.IO)), - arguments(DispatcherWrapper(Dispatchers.Unconfined)), - arguments(DispatcherWrapper(threadPool.asCoroutineDispatcher())), - arguments(DispatcherWrapper(singleThread.asCoroutineDispatcher())), - ) - - class DispatcherWrapper(val dispatcher: CoroutineDispatcher) { + private fun dispatchersSourceArguments(): Stream = + Stream.of( + // Wrap dispatchers since it seems that ParameterizedTest tries to automatically close + // Closeable arguments with no way to avoid it. + arguments(DispatcherWrapper(Dispatchers.Default)), + arguments(DispatcherWrapper(Dispatchers.IO)), + arguments(DispatcherWrapper(Dispatchers.Unconfined)), + arguments(DispatcherWrapper(threadPool.asCoroutineDispatcher())), + arguments(DispatcherWrapper(singleThread.asCoroutineDispatcher())), + ) + + class DispatcherWrapper( + val dispatcher: CoroutineDispatcher + ) { override fun toString(): String = dispatcher.toString() } } diff --git a/instrumentation/kotlinx-coroutines/kotlinx-coroutines-flow-1.3/javaagent/src/test/kotlin/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/flow/FlowWithSpanTest.kt b/instrumentation/kotlinx-coroutines/kotlinx-coroutines-flow-1.3/javaagent/src/test/kotlin/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/flow/FlowWithSpanTest.kt index 47b6527eac85..87bc6e2079dd 100644 --- a/instrumentation/kotlinx-coroutines/kotlinx-coroutines-flow-1.3/javaagent/src/test/kotlin/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/flow/FlowWithSpanTest.kt +++ b/instrumentation/kotlinx-coroutines/kotlinx-coroutines-flow-1.3/javaagent/src/test/kotlin/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/flow/FlowWithSpanTest.kt @@ -24,7 +24,6 @@ import java.util.concurrent.TimeUnit @TestInstance(TestInstance.Lifecycle.PER_CLASS) @ExperimentalCoroutinesApi class FlowWithSpanTest { - @RegisterExtension val testing = AgentInstrumentationExtension.create() @@ -42,12 +41,12 @@ class FlowWithSpanTest { { trace -> trace.hasSpansSatisfyingExactly( { - it.hasName("FlowWithSpanTest.simple") + it + .hasName("FlowWithSpanTest.simple") .hasNoParent() .hasAttributesSatisfyingExactly( SemconvCodeStabilityUtil.codeFunctionAssertions(this.javaClass, "simple") - ) - .has(Condition({ spanData -> spanData.endEpochNanos > flowStartTime }, "end time after $flowStartTime")) + ).has(Condition({ spanData -> spanData.endEpochNanos > flowStartTime }, "end time after $flowStartTime")) } ) } @@ -55,10 +54,11 @@ class FlowWithSpanTest { } @WithSpan - fun simple(): Flow = flow { - for (i in 1..3) { - delay(100) - emit(i) + fun simple(): Flow = + flow { + for (i in 1..3) { + delay(100) + emit(i) + } } - } } diff --git a/instrumentation/ktor/ktor-1.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v1_0/ApplicationRequestGetter.kt b/instrumentation/ktor/ktor-1.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v1_0/ApplicationRequestGetter.kt index 6347b8f4a9b9..5779ac493613 100644 --- a/instrumentation/ktor/ktor-1.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v1_0/ApplicationRequestGetter.kt +++ b/instrumentation/ktor/ktor-1.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v1_0/ApplicationRequestGetter.kt @@ -12,7 +12,13 @@ import java.util.Collections internal object ApplicationRequestGetter : TextMapGetter { override fun keys(carrier: ApplicationRequest): Iterable = carrier.headers.names() - override fun get(carrier: ApplicationRequest?, name: String): String? = carrier?.headers?.get(name) + override fun get( + carrier: ApplicationRequest?, + name: String + ): String? = carrier?.headers?.get(name) - override fun getAll(carrier: ApplicationRequest?, name: String): Iterator = carrier?.headers?.getAll(name)?.iterator() ?: Collections.emptyIterator() + override fun getAll( + carrier: ApplicationRequest?, + name: String + ): Iterator = carrier?.headers?.getAll(name)?.iterator() ?: Collections.emptyIterator() } diff --git a/instrumentation/ktor/ktor-1.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v1_0/KtorHttpServerAttributesGetter.kt b/instrumentation/ktor/ktor-1.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v1_0/KtorHttpServerAttributesGetter.kt index e726e4ae8292..c7232622997e 100644 --- a/instrumentation/ktor/ktor-1.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v1_0/KtorHttpServerAttributesGetter.kt +++ b/instrumentation/ktor/ktor-1.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v1_0/KtorHttpServerAttributesGetter.kt @@ -11,14 +11,24 @@ import io.ktor.response.* import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesGetter internal object KtorHttpServerAttributesGetter : HttpServerAttributesGetter { - override fun getHttpRequestMethod(request: ApplicationRequest): String = request.httpMethod.value - override fun getHttpRequestHeader(request: ApplicationRequest, name: String): List = request.headers.getAll(name) ?: emptyList() + override fun getHttpRequestHeader( + request: ApplicationRequest, + name: String + ): List = request.headers.getAll(name) ?: emptyList() - override fun getHttpResponseStatusCode(request: ApplicationRequest, response: ApplicationResponse, error: Throwable?): Int? = response.status()?.value + override fun getHttpResponseStatusCode( + request: ApplicationRequest, + response: ApplicationResponse, + error: Throwable? + ): Int? = response.status()?.value - override fun getHttpResponseHeader(request: ApplicationRequest, response: ApplicationResponse, name: String): List = response.headers.allValues().getAll(name) ?: emptyList() + override fun getHttpResponseHeader( + request: ApplicationRequest, + response: ApplicationResponse, + name: String + ): List = response.headers.allValues().getAll(name) ?: emptyList() override fun getUrlScheme(request: ApplicationRequest): String = request.origin.scheme @@ -26,7 +36,13 @@ internal object KtorHttpServerAttributesGetter : HttpServerAttributesGetter, ) { - class Configuration { internal lateinit var builder: DefaultHttpServerInstrumenterBuilder @@ -51,10 +50,10 @@ class KtorServerTelemetry private constructor( ) { builder.setSpanStatusExtractorCustomizer { prevExtractor -> SpanStatusExtractor { - spanStatusBuilder: SpanStatusBuilder, - request: ApplicationRequest, - response: ApplicationResponse?, - throwable: Throwable? + spanStatusBuilder: SpanStatusBuilder, + request: ApplicationRequest, + response: ApplicationResponse?, + throwable: Throwable? -> extractor(prevExtractor).extract(spanStatusBuilder, request, response, throwable) } @@ -97,7 +96,11 @@ class KtorServerTelemetry private constructor( return instrumenter.start(parentContext, call.request) } - private fun end(context: Context, call: ApplicationCall, error: Throwable?) { + private fun end( + context: Context, + call: ApplicationCall, + error: Throwable? + ) { instrumenter.end(context, call.request, call.response, error) } @@ -109,18 +112,22 @@ class KtorServerTelemetry private constructor( override val key: AttributeKey = AttributeKey("OpenTelemetry") - override fun install(pipeline: Application, configure: Configuration.() -> Unit): KtorServerTelemetry { + override fun install( + pipeline: Application, + configure: Configuration.() -> Unit + ): KtorServerTelemetry { val configuration = Configuration().apply(configure) if (!configuration.isOpenTelemetryInitialized()) { throw IllegalArgumentException("OpenTelemetry must be set") } - val instrumenter = InstrumenterUtil.buildUpstreamInstrumenter( - configuration.builder.instrumenterBuilder(), - ApplicationRequestGetter, - configuration.spanKindExtractor(SpanKindExtractor.alwaysServer()) - ) + val instrumenter = + InstrumenterUtil.buildUpstreamInstrumenter( + configuration.builder.instrumenterBuilder(), + ApplicationRequestGetter, + configuration.spanKindExtractor(SpanKindExtractor.alwaysServer()) + ) val feature = KtorServerTelemetry(instrumenter) diff --git a/instrumentation/ktor/ktor-1.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v1_0/KtorHttpServerTest.kt b/instrumentation/ktor/ktor-1.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v1_0/KtorHttpServerTest.kt index cef203c3a85e..4368df467c2f 100644 --- a/instrumentation/ktor/ktor-1.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v1_0/KtorHttpServerTest.kt +++ b/instrumentation/ktor/ktor-1.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v1_0/KtorHttpServerTest.kt @@ -28,85 +28,93 @@ import java.util.concurrent.ExecutionException import java.util.concurrent.TimeUnit class KtorHttpServerTest : AbstractHttpServerTest() { - companion object { @JvmStatic @RegisterExtension val testing = HttpServerInstrumentationExtension.forLibrary() } - override fun setupServer(): ApplicationEngine = embeddedServer(Netty, port = port) { - KtorTestUtil.installOpenTelemetry(this, testing.openTelemetry) + override fun setupServer(): ApplicationEngine = + embeddedServer(Netty, port = port) { + KtorTestUtil.installOpenTelemetry(this, testing.openTelemetry) - routing { - get(ServerEndpoint.SUCCESS.path) { - controller(ServerEndpoint.SUCCESS) { - call.respondText(ServerEndpoint.SUCCESS.body, status = HttpStatusCode.fromValue(ServerEndpoint.SUCCESS.status)) + routing { + get(ServerEndpoint.SUCCESS.path) { + controller(ServerEndpoint.SUCCESS) { + call.respondText(ServerEndpoint.SUCCESS.body, status = HttpStatusCode.fromValue(ServerEndpoint.SUCCESS.status)) + } } - } - get(ServerEndpoint.REDIRECT.path) { - controller(ServerEndpoint.REDIRECT) { - call.respondRedirect(ServerEndpoint.REDIRECT.body) + get(ServerEndpoint.REDIRECT.path) { + controller(ServerEndpoint.REDIRECT) { + call.respondRedirect(ServerEndpoint.REDIRECT.body) + } } - } - get(ServerEndpoint.ERROR.path) { - controller(ServerEndpoint.ERROR) { - call.respondText(ServerEndpoint.ERROR.body, status = HttpStatusCode.fromValue(ServerEndpoint.ERROR.status)) + get(ServerEndpoint.ERROR.path) { + controller(ServerEndpoint.ERROR) { + call.respondText(ServerEndpoint.ERROR.body, status = HttpStatusCode.fromValue(ServerEndpoint.ERROR.status)) + } } - } - get(ServerEndpoint.EXCEPTION.path) { - controller(ServerEndpoint.EXCEPTION) { - throw IllegalStateException(ServerEndpoint.EXCEPTION.body) + get(ServerEndpoint.EXCEPTION.path) { + controller(ServerEndpoint.EXCEPTION) { + throw IllegalStateException(ServerEndpoint.EXCEPTION.body) + } } - } - get("/query") { - controller(ServerEndpoint.QUERY_PARAM) { - call.respondText("some=${call.request.queryParameters["some"]}", status = HttpStatusCode.fromValue(ServerEndpoint.QUERY_PARAM.status)) + get("/query") { + controller(ServerEndpoint.QUERY_PARAM) { + call.respondText("some=${call.request.queryParameters["some"]}", status = HttpStatusCode.fromValue(ServerEndpoint.QUERY_PARAM.status)) + } } - } - get("/path/{id}/param") { - controller(ServerEndpoint.PATH_PARAM) { - call.respondText( - call.parameters["id"] - ?: "", - status = HttpStatusCode.fromValue(ServerEndpoint.PATH_PARAM.status), - ) + get("/path/{id}/param") { + controller(ServerEndpoint.PATH_PARAM) { + call.respondText( + call.parameters["id"] + ?: "", + status = HttpStatusCode.fromValue(ServerEndpoint.PATH_PARAM.status), + ) + } } - } - get("/child") { - controller(ServerEndpoint.INDEXED_CHILD) { - ServerEndpoint.INDEXED_CHILD.collectSpanAttributes { call.request.queryParameters[it] } - call.respondText(ServerEndpoint.INDEXED_CHILD.body, status = HttpStatusCode.fromValue(ServerEndpoint.INDEXED_CHILD.status)) + get("/child") { + controller(ServerEndpoint.INDEXED_CHILD) { + ServerEndpoint.INDEXED_CHILD.collectSpanAttributes { call.request.queryParameters[it] } + call.respondText(ServerEndpoint.INDEXED_CHILD.body, status = HttpStatusCode.fromValue(ServerEndpoint.INDEXED_CHILD.status)) + } } - } - get("/captureHeaders") { - controller(ServerEndpoint.CAPTURE_HEADERS) { - call.response.header("X-Test-Response", call.request.header("X-Test-Request") ?: "") - call.respondText(ServerEndpoint.CAPTURE_HEADERS.body, status = HttpStatusCode.fromValue(ServerEndpoint.CAPTURE_HEADERS.status)) + get("/captureHeaders") { + controller(ServerEndpoint.CAPTURE_HEADERS) { + call.response.header("X-Test-Response", call.request.header("X-Test-Request") ?: "") + call.respondText(ServerEndpoint.CAPTURE_HEADERS.body, status = HttpStatusCode.fromValue(ServerEndpoint.CAPTURE_HEADERS.status)) + } } } - } - }.start() + }.start() override fun stopServer(server: ApplicationEngine) { server.stop(0, 10, TimeUnit.SECONDS) } // Copy in HttpServerTest.controller but make it a suspending function - private suspend fun controller(endpoint: ServerEndpoint, wrapped: suspend () -> Unit) { + private suspend fun controller( + endpoint: ServerEndpoint, + wrapped: suspend () -> Unit + ) { assert(Span.current().spanContext.isValid, { "Controller should have a parent span. " }) if (endpoint == ServerEndpoint.NOT_FOUND) { wrapped() return } - val span = testing.openTelemetry.getTracer("test").spanBuilder("controller").setSpanKind(SpanKind.INTERNAL).startSpan() + val span = + testing.openTelemetry + .getTracer("test") + .spanBuilder("controller") + .setSpanKind(SpanKind.INTERNAL) + .startSpan() try { withContext(Context.current().with(span).asContextElement()) { wrapped() diff --git a/instrumentation/ktor/ktor-1.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v1_0/KtorServerSpanKindExtractorTest.kt b/instrumentation/ktor/ktor-1.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v1_0/KtorServerSpanKindExtractorTest.kt index 6e6380722359..3dd3a91bd3bc 100644 --- a/instrumentation/ktor/ktor-1.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v1_0/KtorServerSpanKindExtractorTest.kt +++ b/instrumentation/ktor/ktor-1.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v1_0/KtorServerSpanKindExtractorTest.kt @@ -34,7 +34,6 @@ import java.util.function.Consumer import java.util.stream.Stream class KtorServerSpanKindExtractorTest : AbstractHttpServerUsingTest() { - private val consumerKindEndpoint = ServerEndpoint("consumerKindEndpoint", "from-pubsub/run", 200, "") private val serverKindEndpoint = ServerEndpoint("serverKindEndpoint", "from-client/run", 200, "") @@ -56,30 +55,31 @@ class KtorServerSpanKindExtractorTest : AbstractHttpServerUsingTest - if (req.uri.startsWith("/from-pubsub/")) { - SpanKind.CONSUMER - } else { - SpanKind.SERVER + override fun setupServer(): ApplicationEngine = + embeddedServer(Netty, port = port) { + install(KtorServerTelemetry) { + setOpenTelemetry(testing.openTelemetry) + setSpanKindExtractor { + SpanKindExtractor { req -> + if (req.uri.startsWith("/from-pubsub/")) { + SpanKind.CONSUMER + } else { + SpanKind.SERVER + } } } } - } - routing { - post(consumerKindEndpoint.path) { - call.respondText(consumerKindEndpoint.body, status = HttpStatusCode.fromValue(consumerKindEndpoint.status)) - } + routing { + post(consumerKindEndpoint.path) { + call.respondText(consumerKindEndpoint.body, status = HttpStatusCode.fromValue(consumerKindEndpoint.status)) + } - post(serverKindEndpoint.path) { - call.respondText(serverKindEndpoint.body, status = HttpStatusCode.fromValue(serverKindEndpoint.status)) + post(serverKindEndpoint.path) { + call.respondText(serverKindEndpoint.body, status = HttpStatusCode.fromValue(serverKindEndpoint.status)) + } } - } - }.start() + }.start() override fun stopServer(server: ApplicationEngine) { server.stop(0, 10, TimeUnit.SECONDS) @@ -87,7 +87,10 @@ class KtorServerSpanKindExtractorTest : AbstractHttpServerUsingTest = Stream.of( - arguments(consumerKindEndpoint, SpanKind.CONSUMER), - arguments(serverKindEndpoint, SpanKind.SERVER), - ) + private fun provideArguments(): Stream = + Stream.of( + arguments(consumerKindEndpoint, SpanKind.CONSUMER), + arguments(serverKindEndpoint, SpanKind.SERVER), + ) } diff --git a/instrumentation/ktor/ktor-1.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v1_0/KtorTestUtil.kt b/instrumentation/ktor/ktor-1.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v1_0/KtorTestUtil.kt index 85fd9d6b78fa..3dec8c6c68c7 100644 --- a/instrumentation/ktor/ktor-1.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v1_0/KtorTestUtil.kt +++ b/instrumentation/ktor/ktor-1.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v1_0/KtorTestUtil.kt @@ -11,7 +11,10 @@ import io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpServerTes class KtorTestUtil { companion object { - fun installOpenTelemetry(application: Application, openTelemetry: OpenTelemetry) { + fun installOpenTelemetry( + application: Application, + openTelemetry: OpenTelemetry + ) { application.install(KtorServerTelemetry) { setOpenTelemetry(openTelemetry) setCapturedRequestHeaders(listOf(AbstractHttpServerTest.TEST_REQUEST_HEADER)) diff --git a/instrumentation/ktor/ktor-2.0/javaagent/build.gradle.kts b/instrumentation/ktor/ktor-2.0/javaagent/build.gradle.kts index d44d14cc1fda..181997bc7a82 100644 --- a/instrumentation/ktor/ktor-2.0/javaagent/build.gradle.kts +++ b/instrumentation/ktor/ktor-2.0/javaagent/build.gradle.kts @@ -34,7 +34,9 @@ dependencies { testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent")) testInstrumentation(project(":instrumentation:ktor:ktor-3.0:javaagent")) - testInstrumentation(project(":instrumentation:kotlinx-coroutines:kotlinx-coroutines-1.0:javaagent")) + testInstrumentation( + project(":instrumentation:kotlinx-coroutines:kotlinx-coroutines-1.0:javaagent"), + ) testInstrumentation(project(":instrumentation:opentelemetry-extension-kotlin-1.0:javaagent")) testImplementation(project(":instrumentation:ktor:ktor-2.0:testing")) @@ -64,7 +66,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/ktor/ktor-2.0/javaagent/src/test/java/io/opentelemetry/instrumentation/ktor/v2_0/KtorHttpClientTest.kt b/instrumentation/ktor/ktor-2.0/javaagent/src/test/java/io/opentelemetry/instrumentation/ktor/v2_0/KtorHttpClientTest.kt index ba9c459b76cb..cbeb07456041 100644 --- a/instrumentation/ktor/ktor-2.0/javaagent/src/test/java/io/opentelemetry/instrumentation/ktor/v2_0/KtorHttpClientTest.kt +++ b/instrumentation/ktor/ktor-2.0/javaagent/src/test/java/io/opentelemetry/instrumentation/ktor/v2_0/KtorHttpClientTest.kt @@ -10,7 +10,6 @@ import io.opentelemetry.instrumentation.testing.junit.http.HttpClientInstrumenta import org.junit.jupiter.api.extension.RegisterExtension class KtorHttpClientTest : AbstractKtorHttpClientTest() { - companion object { @JvmStatic @RegisterExtension diff --git a/instrumentation/ktor/ktor-2.0/javaagent/src/test/java/io/opentelemetry/instrumentation/ktor/v2_0/KtorHttpServerTest.kt b/instrumentation/ktor/ktor-2.0/javaagent/src/test/java/io/opentelemetry/instrumentation/ktor/v2_0/KtorHttpServerTest.kt index 4507b4ca0feb..010509231047 100644 --- a/instrumentation/ktor/ktor-2.0/javaagent/src/test/java/io/opentelemetry/instrumentation/ktor/v2_0/KtorHttpServerTest.kt +++ b/instrumentation/ktor/ktor-2.0/javaagent/src/test/java/io/opentelemetry/instrumentation/ktor/v2_0/KtorHttpServerTest.kt @@ -12,7 +12,6 @@ import io.opentelemetry.instrumentation.testing.junit.http.HttpServerTestOptions import org.junit.jupiter.api.extension.RegisterExtension class KtorHttpServerTest : AbstractKtorHttpServerTest() { - companion object { @JvmStatic @RegisterExtension diff --git a/instrumentation/ktor/ktor-2.0/library/build.gradle.kts b/instrumentation/ktor/ktor-2.0/library/build.gradle.kts index ff45675874d5..0ebaae346bad 100644 --- a/instrumentation/ktor/ktor-2.0/library/build.gradle.kts +++ b/instrumentation/ktor/ktor-2.0/library/build.gradle.kts @@ -43,7 +43,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/ktor/ktor-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/InstrumentationProperties.kt b/instrumentation/ktor/ktor-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/InstrumentationProperties.kt index 510450713e1b..7ec511740904 100644 --- a/instrumentation/ktor/ktor-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/InstrumentationProperties.kt +++ b/instrumentation/ktor/ktor-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/InstrumentationProperties.kt @@ -9,6 +9,5 @@ package io.opentelemetry.instrumentation.ktor.v2_0 * Common properties for both client and server instrumentations */ internal object InstrumentationProperties { - internal const val INSTRUMENTATION_NAME = "io.opentelemetry.ktor-2.0" } diff --git a/instrumentation/ktor/ktor-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorClientTelemetry.kt b/instrumentation/ktor/ktor-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorClientTelemetry.kt index b8c029f991e5..63514ec4d730 100644 --- a/instrumentation/ktor/ktor-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorClientTelemetry.kt +++ b/instrumentation/ktor/ktor-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorClientTelemetry.kt @@ -19,14 +19,15 @@ class KtorClientTelemetry internal constructor( instrumenter: Instrumenter, propagators: ContextPropagators ) : AbstractKtorClientTelemetry(instrumenter, propagators) { - companion object : HttpClientPlugin { - override val key = AttributeKey("OpenTelemetry") override fun prepare(block: KtorClientTelemetryBuilder.() -> Unit) = KtorClientTelemetryBuilder().apply(block).build() - override fun install(plugin: KtorClientTelemetry, scope: HttpClient) { + override fun install( + plugin: KtorClientTelemetry, + scope: HttpClient + ) { KtorClientTelemetryUtil.install(plugin, scope) } } diff --git a/instrumentation/ktor/ktor-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorClientTelemetryBuilder.kt b/instrumentation/ktor/ktor-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorClientTelemetryBuilder.kt index b4ed1cb33e7a..7336421f92c4 100644 --- a/instrumentation/ktor/ktor-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorClientTelemetryBuilder.kt +++ b/instrumentation/ktor/ktor-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorClientTelemetryBuilder.kt @@ -9,9 +9,9 @@ import io.opentelemetry.instrumentation.ktor.common.v2_0.AbstractKtorClientTelem import io.opentelemetry.instrumentation.ktor.v2_0.InstrumentationProperties.INSTRUMENTATION_NAME class KtorClientTelemetryBuilder : AbstractKtorClientTelemetryBuilder(INSTRUMENTATION_NAME) { - - internal fun build(): KtorClientTelemetry = KtorClientTelemetry( - instrumenter = builder.build(), - propagators = getOpenTelemetry().propagators, - ) + internal fun build(): KtorClientTelemetry = + KtorClientTelemetry( + instrumenter = builder.build(), + propagators = getOpenTelemetry().propagators, + ) } diff --git a/instrumentation/ktor/ktor-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorServerTelemetryBuilder.kt b/instrumentation/ktor/ktor-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorServerTelemetryBuilder.kt index b3b11d009d2c..73958ccf3b2a 100644 --- a/instrumentation/ktor/ktor-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorServerTelemetryBuilder.kt +++ b/instrumentation/ktor/ktor-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorServerTelemetryBuilder.kt @@ -17,16 +17,16 @@ import io.opentelemetry.instrumentation.ktor.v2_0.InstrumentationProperties.INST class KtorServerTelemetryBuilder internal constructor( instrumentationName: String ) : AbstractKtorServerTelemetryBuilder(instrumentationName) { - internal fun isOpenTelemetrySet(): Boolean = isOpenTelemetryInitialized() } -val KtorServerTelemetry = createRouteScopedPlugin("OpenTelemetry", { KtorServerTelemetryBuilder(INSTRUMENTATION_NAME) }) { - require(pluginConfig.isOpenTelemetrySet()) { "OpenTelemetry must be set" } +val KtorServerTelemetry = + createRouteScopedPlugin("OpenTelemetry", { KtorServerTelemetryBuilder(INSTRUMENTATION_NAME) }) { + require(pluginConfig.isOpenTelemetrySet()) { "OpenTelemetry must be set" } - configureTelemetry(pluginConfig, application) + configureTelemetry(pluginConfig, application) - application.environment.monitor.subscribe(Routing.RoutingCallStarted) { call -> - HttpServerRoute.update(Context.current(), HttpServerRouteSource.SERVER, { _, arg -> arg!!.route.parent.toString() }, call) + application.environment.monitor.subscribe(Routing.RoutingCallStarted) { call -> + HttpServerRoute.update(Context.current(), HttpServerRouteSource.SERVER, { _, arg -> arg!!.route.parent.toString() }, call) + } } -} diff --git a/instrumentation/ktor/ktor-2.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorHttpClientTest.kt b/instrumentation/ktor/ktor-2.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorHttpClientTest.kt index 6eac7443e164..c1f646bd5b67 100644 --- a/instrumentation/ktor/ktor-2.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorHttpClientTest.kt +++ b/instrumentation/ktor/ktor-2.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorHttpClientTest.kt @@ -10,7 +10,6 @@ import io.opentelemetry.instrumentation.testing.junit.http.HttpClientInstrumenta import org.junit.jupiter.api.extension.RegisterExtension class KtorHttpClientTest : AbstractKtorHttpClientTest() { - companion object { @JvmStatic @RegisterExtension diff --git a/instrumentation/ktor/ktor-2.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorHttpServerTest.kt b/instrumentation/ktor/ktor-2.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorHttpServerTest.kt index 15439f937022..5f8a74129b46 100644 --- a/instrumentation/ktor/ktor-2.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorHttpServerTest.kt +++ b/instrumentation/ktor/ktor-2.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorHttpServerTest.kt @@ -11,7 +11,6 @@ import io.opentelemetry.instrumentation.testing.junit.http.HttpServerInstrumenta import org.junit.jupiter.api.extension.RegisterExtension class KtorHttpServerTest : AbstractKtorHttpServerTest() { - companion object { @JvmStatic @RegisterExtension diff --git a/instrumentation/ktor/ktor-2.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorServerSpanKindExtractorTest.kt b/instrumentation/ktor/ktor-2.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorServerSpanKindExtractorTest.kt index 4798a485014d..170b0697bd24 100644 --- a/instrumentation/ktor/ktor-2.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorServerSpanKindExtractorTest.kt +++ b/instrumentation/ktor/ktor-2.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorServerSpanKindExtractorTest.kt @@ -33,7 +33,6 @@ import java.util.function.Consumer import java.util.stream.Stream class KtorServerSpanKindExtractorTest : AbstractHttpServerUsingTest() { - private val consumerKindEndpoint = ServerEndpoint("consumerKindEndpoint", "from-pubsub/run", 200, "") private val serverKindEndpoint = ServerEndpoint("serverKindEndpoint", "from-client/run", 200, "") @@ -55,28 +54,29 @@ class KtorServerSpanKindExtractorTest : AbstractHttpServerUsingTest = Stream.of( - arguments(consumerKindEndpoint, SpanKind.CONSUMER), - arguments(serverKindEndpoint, SpanKind.SERVER), - ) + private fun provideArguments(): Stream = + Stream.of( + arguments(consumerKindEndpoint, SpanKind.CONSUMER), + arguments(serverKindEndpoint, SpanKind.SERVER), + ) } diff --git a/instrumentation/ktor/ktor-2.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorTestUtil.kt b/instrumentation/ktor/ktor-2.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorTestUtil.kt index 7fc9150ce734..d224f2ed8abf 100644 --- a/instrumentation/ktor/ktor-2.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorTestUtil.kt +++ b/instrumentation/ktor/ktor-2.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorTestUtil.kt @@ -10,7 +10,10 @@ import io.opentelemetry.api.OpenTelemetry import io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpServerTest internal object KtorTestUtil { - fun installOpenTelemetry(application: Application, openTelemetry: OpenTelemetry) { + fun installOpenTelemetry( + application: Application, + openTelemetry: OpenTelemetry + ) { application.install(KtorServerTelemetry) { setOpenTelemetry(openTelemetry) capturedRequestHeaders(AbstractHttpServerTest.TEST_REQUEST_HEADER) diff --git a/instrumentation/ktor/ktor-2.0/testing/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/AbstractKtorHttpClientTest.kt b/instrumentation/ktor/ktor-2.0/testing/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/AbstractKtorHttpClientTest.kt index 38124f0dc338..1799f7a82d0e 100644 --- a/instrumentation/ktor/ktor-2.0/testing/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/AbstractKtorHttpClientTest.kt +++ b/instrumentation/ktor/ktor-2.0/testing/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/AbstractKtorHttpClientTest.kt @@ -25,19 +25,20 @@ import org.junit.jupiter.api.AfterAll import java.net.URI abstract class AbstractKtorHttpClientTest : AbstractHttpClientTest() { + private val client = + HttpClient(CIO) { + install(HttpRedirect) - private val client = HttpClient(CIO) { - install(HttpRedirect) - - installTracing() - } - private val singleConnectionClient = HttpClient(CIO) { - engine { - maxConnectionsCount = 1 + installTracing() } + private val singleConnectionClient = + HttpClient(CIO) { + engine { + maxConnectionsCount = 1 + } - installTracing() - } + installTracing() + } @AfterAll fun tearDown() { @@ -47,13 +48,22 @@ abstract class AbstractKtorHttpClientTest : AbstractHttpClientTest.installTracing() - override fun buildRequest(requestMethod: String, uri: URI, requestHeaders: MutableMap) = HttpRequestBuilder(uri.toURL()).apply { + override fun buildRequest( + requestMethod: String, + uri: URI, + requestHeaders: MutableMap + ) = HttpRequestBuilder(uri.toURL()).apply { method = HttpMethod.parse(requestMethod) requestHeaders.forEach { (header, value) -> headers.append(header, value) } } - override fun sendRequest(request: HttpRequestBuilder, method: String, uri: URI, headers: MutableMap) = runBlocking { + override fun sendRequest( + request: HttpRequestBuilder, + method: String, + uri: URI, + headers: MutableMap + ) = runBlocking { client.request(request).status.value } diff --git a/instrumentation/ktor/ktor-2.0/testing/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/AbstractKtorHttpServerTest.kt b/instrumentation/ktor/ktor-2.0/testing/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/AbstractKtorHttpServerTest.kt index 3d72d2b0025a..79f866c1a6a6 100644 --- a/instrumentation/ktor/ktor-2.0/testing/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/AbstractKtorHttpServerTest.kt +++ b/instrumentation/ktor/ktor-2.0/testing/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/AbstractKtorHttpServerTest.kt @@ -27,83 +27,92 @@ import java.util.concurrent.ExecutionException import java.util.concurrent.TimeUnit abstract class AbstractKtorHttpServerTest : AbstractHttpServerTest() { - abstract fun getTesting(): InstrumentationExtension abstract fun installOpenTelemetry(application: Application) - override fun setupServer(): ApplicationEngine = embeddedServer(Netty, port = port) { - installOpenTelemetry(this) + override fun setupServer(): ApplicationEngine = + embeddedServer(Netty, port = port) { + installOpenTelemetry(this) - routing { - get(ServerEndpoint.SUCCESS.path) { - controller(ServerEndpoint.SUCCESS) { - call.respondText(ServerEndpoint.SUCCESS.body, status = HttpStatusCode.fromValue(ServerEndpoint.SUCCESS.status)) + routing { + get(ServerEndpoint.SUCCESS.path) { + controller(ServerEndpoint.SUCCESS) { + call.respondText(ServerEndpoint.SUCCESS.body, status = HttpStatusCode.fromValue(ServerEndpoint.SUCCESS.status)) + } } - } - get(ServerEndpoint.REDIRECT.path) { - controller(ServerEndpoint.REDIRECT) { - call.respondRedirect(ServerEndpoint.REDIRECT.body) + get(ServerEndpoint.REDIRECT.path) { + controller(ServerEndpoint.REDIRECT) { + call.respondRedirect(ServerEndpoint.REDIRECT.body) + } } - } - get(ServerEndpoint.ERROR.path) { - controller(ServerEndpoint.ERROR) { - call.respondText(ServerEndpoint.ERROR.body, status = HttpStatusCode.fromValue(ServerEndpoint.ERROR.status)) + get(ServerEndpoint.ERROR.path) { + controller(ServerEndpoint.ERROR) { + call.respondText(ServerEndpoint.ERROR.body, status = HttpStatusCode.fromValue(ServerEndpoint.ERROR.status)) + } } - } - get(ServerEndpoint.EXCEPTION.path) { - controller(ServerEndpoint.EXCEPTION) { - throw IllegalStateException(ServerEndpoint.EXCEPTION.body) + get(ServerEndpoint.EXCEPTION.path) { + controller(ServerEndpoint.EXCEPTION) { + throw IllegalStateException(ServerEndpoint.EXCEPTION.body) + } } - } - get("/query") { - controller(ServerEndpoint.QUERY_PARAM) { - call.respondText("some=${call.request.queryParameters["some"]}", status = HttpStatusCode.fromValue(ServerEndpoint.QUERY_PARAM.status)) + get("/query") { + controller(ServerEndpoint.QUERY_PARAM) { + call.respondText("some=${call.request.queryParameters["some"]}", status = HttpStatusCode.fromValue(ServerEndpoint.QUERY_PARAM.status)) + } } - } - get("/path/{id}/param") { - controller(ServerEndpoint.PATH_PARAM) { - call.respondText( - call.parameters["id"] - ?: "", - status = HttpStatusCode.fromValue(ServerEndpoint.PATH_PARAM.status), - ) + get("/path/{id}/param") { + controller(ServerEndpoint.PATH_PARAM) { + call.respondText( + call.parameters["id"] + ?: "", + status = HttpStatusCode.fromValue(ServerEndpoint.PATH_PARAM.status), + ) + } } - } - get("/child") { - controller(ServerEndpoint.INDEXED_CHILD) { - ServerEndpoint.INDEXED_CHILD.collectSpanAttributes { call.request.queryParameters[it] } - call.respondText(ServerEndpoint.INDEXED_CHILD.body, status = HttpStatusCode.fromValue(ServerEndpoint.INDEXED_CHILD.status)) + get("/child") { + controller(ServerEndpoint.INDEXED_CHILD) { + ServerEndpoint.INDEXED_CHILD.collectSpanAttributes { call.request.queryParameters[it] } + call.respondText(ServerEndpoint.INDEXED_CHILD.body, status = HttpStatusCode.fromValue(ServerEndpoint.INDEXED_CHILD.status)) + } } - } - get("/captureHeaders") { - controller(ServerEndpoint.CAPTURE_HEADERS) { - call.response.header("X-Test-Response", call.request.header("X-Test-Request") ?: "") - call.respondText(ServerEndpoint.CAPTURE_HEADERS.body, status = HttpStatusCode.fromValue(ServerEndpoint.CAPTURE_HEADERS.status)) + get("/captureHeaders") { + controller(ServerEndpoint.CAPTURE_HEADERS) { + call.response.header("X-Test-Response", call.request.header("X-Test-Request") ?: "") + call.respondText(ServerEndpoint.CAPTURE_HEADERS.body, status = HttpStatusCode.fromValue(ServerEndpoint.CAPTURE_HEADERS.status)) + } } } - } - }.start() + }.start() override fun stopServer(server: ApplicationEngine) { server.stop(0, 10, TimeUnit.SECONDS) } // Copy in HttpServerTest.controller but make it a suspending function - private suspend fun controller(endpoint: ServerEndpoint, wrapped: suspend () -> Unit) { + private suspend fun controller( + endpoint: ServerEndpoint, + wrapped: suspend () -> Unit + ) { assert(Span.current().spanContext.isValid, { "Controller should have a parent span. " }) if (endpoint == ServerEndpoint.NOT_FOUND) { wrapped() return } - val span = getTesting().openTelemetry.getTracer("test").spanBuilder("controller").setSpanKind(SpanKind.INTERNAL).startSpan() + val span = + getTesting() + .openTelemetry + .getTracer("test") + .spanBuilder("controller") + .setSpanKind(SpanKind.INTERNAL) + .startSpan() try { withContext(Context.current().with(span).asContextElement()) { wrapped() diff --git a/instrumentation/ktor/ktor-2.0/testing/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorHttpClientSingleConnection.kt b/instrumentation/ktor/ktor-2.0/testing/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorHttpClientSingleConnection.kt index 2d0de2d6e800..d31905e73d3c 100644 --- a/instrumentation/ktor/ktor-2.0/testing/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorHttpClientSingleConnection.kt +++ b/instrumentation/ktor/ktor-2.0/testing/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/KtorHttpClientSingleConnection.kt @@ -15,16 +15,19 @@ class KtorHttpClientSingleConnection( private val host: String, private val port: Int ) : SingleConnection { - - override fun doRequest(path: String, requestHeaders: MutableMap) = runBlocking { - val request = HttpRequestBuilder( - scheme = "http", - host = host, - port = port, - path = path, - ).apply { - requestHeaders.forEach { (name, value) -> headers.append(name, value) } - } + override fun doRequest( + path: String, + requestHeaders: MutableMap + ) = runBlocking { + val request = + HttpRequestBuilder( + scheme = "http", + host = host, + port = port, + path = path, + ).apply { + requestHeaders.forEach { (name, value) -> headers.append(name, value) } + } client.request(request).status.value } diff --git a/instrumentation/ktor/ktor-3.0/javaagent/build.gradle.kts b/instrumentation/ktor/ktor-3.0/javaagent/build.gradle.kts index 2806b09673e4..c136917676e2 100644 --- a/instrumentation/ktor/ktor-3.0/javaagent/build.gradle.kts +++ b/instrumentation/ktor/ktor-3.0/javaagent/build.gradle.kts @@ -34,7 +34,9 @@ dependencies { testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent")) testInstrumentation(project(":instrumentation:ktor:ktor-2.0:javaagent")) - testInstrumentation(project(":instrumentation:kotlinx-coroutines:kotlinx-coroutines-1.0:javaagent")) + testInstrumentation( + project(":instrumentation:kotlinx-coroutines:kotlinx-coroutines-1.0:javaagent"), + ) testInstrumentation(project(":instrumentation:opentelemetry-extension-kotlin-1.0:javaagent")) testImplementation(project(":instrumentation:ktor:ktor-3.0:testing")) @@ -55,14 +57,20 @@ kotlin { tasks { val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.http.server.emit-experimental-telemetry=true") } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/ktor/ktor-3.0/javaagent/src/test/java/io/opentelemetry/instrumentation/ktor/v3_0/KtorHttpClientTest.kt b/instrumentation/ktor/ktor-3.0/javaagent/src/test/java/io/opentelemetry/instrumentation/ktor/v3_0/KtorHttpClientTest.kt index 337ec8ed4267..8f35732d66e4 100644 --- a/instrumentation/ktor/ktor-3.0/javaagent/src/test/java/io/opentelemetry/instrumentation/ktor/v3_0/KtorHttpClientTest.kt +++ b/instrumentation/ktor/ktor-3.0/javaagent/src/test/java/io/opentelemetry/instrumentation/ktor/v3_0/KtorHttpClientTest.kt @@ -10,7 +10,6 @@ import io.opentelemetry.instrumentation.testing.junit.http.HttpClientInstrumenta import org.junit.jupiter.api.extension.RegisterExtension class KtorHttpClientTest : AbstractKtorHttpClientTest() { - companion object { @JvmStatic @RegisterExtension diff --git a/instrumentation/ktor/ktor-3.0/javaagent/src/test/java/io/opentelemetry/instrumentation/ktor/v3_0/KtorHttpServerTest.kt b/instrumentation/ktor/ktor-3.0/javaagent/src/test/java/io/opentelemetry/instrumentation/ktor/v3_0/KtorHttpServerTest.kt index 22dfc71c3997..37605aa0fea0 100644 --- a/instrumentation/ktor/ktor-3.0/javaagent/src/test/java/io/opentelemetry/instrumentation/ktor/v3_0/KtorHttpServerTest.kt +++ b/instrumentation/ktor/ktor-3.0/javaagent/src/test/java/io/opentelemetry/instrumentation/ktor/v3_0/KtorHttpServerTest.kt @@ -12,7 +12,6 @@ import io.opentelemetry.instrumentation.testing.junit.http.HttpServerTestOptions import org.junit.jupiter.api.extension.RegisterExtension class KtorHttpServerTest : AbstractKtorHttpServerTest() { - companion object { @JvmStatic @RegisterExtension diff --git a/instrumentation/ktor/ktor-3.0/library/build.gradle.kts b/instrumentation/ktor/ktor-3.0/library/build.gradle.kts index 1826c3b388aa..0c810f4206c0 100644 --- a/instrumentation/ktor/ktor-3.0/library/build.gradle.kts +++ b/instrumentation/ktor/ktor-3.0/library/build.gradle.kts @@ -39,16 +39,25 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath // this is used for enabling/disabling tests, library instrumentation doesn't use this flag jvmArgs("-Dotel.instrumentation.http.server.emit-experimental-telemetry=true") - systemProperty("metadataConfig", "otel.instrumentation.http.server.emit-experimental-telemetry=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.http.server.emit-experimental-telemetry=true", + ) } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/ktor/ktor-3.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/InstrumentationProperties.kt b/instrumentation/ktor/ktor-3.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/InstrumentationProperties.kt index 722f27ca21e7..9cb3f6bf5727 100644 --- a/instrumentation/ktor/ktor-3.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/InstrumentationProperties.kt +++ b/instrumentation/ktor/ktor-3.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/InstrumentationProperties.kt @@ -9,6 +9,5 @@ package io.opentelemetry.instrumentation.ktor.v3_0 * Common properties for both client and server instrumentations */ internal object InstrumentationProperties { - internal const val INSTRUMENTATION_NAME = "io.opentelemetry.ktor-3.0" } diff --git a/instrumentation/ktor/ktor-3.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/KtorClientTelemetry.kt b/instrumentation/ktor/ktor-3.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/KtorClientTelemetry.kt index 5d7fc4699c5a..ae1aa4aa374b 100644 --- a/instrumentation/ktor/ktor-3.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/KtorClientTelemetry.kt +++ b/instrumentation/ktor/ktor-3.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/KtorClientTelemetry.kt @@ -19,14 +19,15 @@ class KtorClientTelemetry internal constructor( instrumenter: Instrumenter, propagators: ContextPropagators ) : AbstractKtorClientTelemetry(instrumenter, propagators) { - companion object : HttpClientPlugin { - override val key = AttributeKey("OpenTelemetry") override fun prepare(block: KtorClientTelemetryBuilder.() -> Unit) = KtorClientTelemetryBuilder().apply(block).build() - override fun install(plugin: KtorClientTelemetry, scope: HttpClient) { + override fun install( + plugin: KtorClientTelemetry, + scope: HttpClient + ) { KtorClientTelemetryUtil.install(plugin, scope) } } diff --git a/instrumentation/ktor/ktor-3.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/KtorClientTelemetryBuilder.kt b/instrumentation/ktor/ktor-3.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/KtorClientTelemetryBuilder.kt index 45dc0e6e0b7c..c9bcd5067124 100644 --- a/instrumentation/ktor/ktor-3.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/KtorClientTelemetryBuilder.kt +++ b/instrumentation/ktor/ktor-3.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/KtorClientTelemetryBuilder.kt @@ -9,9 +9,9 @@ import io.opentelemetry.instrumentation.ktor.common.v2_0.AbstractKtorClientTelem import io.opentelemetry.instrumentation.ktor.v3_0.InstrumentationProperties.INSTRUMENTATION_NAME class KtorClientTelemetryBuilder : AbstractKtorClientTelemetryBuilder(INSTRUMENTATION_NAME) { - - internal fun build(): KtorClientTelemetry = KtorClientTelemetry( - instrumenter = builder.build(), - propagators = getOpenTelemetry().propagators, - ) + internal fun build(): KtorClientTelemetry = + KtorClientTelemetry( + instrumenter = builder.build(), + propagators = getOpenTelemetry().propagators, + ) } diff --git a/instrumentation/ktor/ktor-3.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/KtorServerTelemetryBuilder.kt b/instrumentation/ktor/ktor-3.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/KtorServerTelemetryBuilder.kt index 6402cb5680f3..1a873d8abb29 100644 --- a/instrumentation/ktor/ktor-3.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/KtorServerTelemetryBuilder.kt +++ b/instrumentation/ktor/ktor-3.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/KtorServerTelemetryBuilder.kt @@ -17,16 +17,16 @@ import io.opentelemetry.instrumentation.ktor.v3_0.InstrumentationProperties.INST class KtorServerTelemetryBuilder internal constructor( instrumentationName: String ) : AbstractKtorServerTelemetryBuilder(instrumentationName) { - internal fun isOpenTelemetrySet(): Boolean = isOpenTelemetryInitialized() } -val KtorServerTelemetry = createRouteScopedPlugin("OpenTelemetry", { KtorServerTelemetryBuilder(INSTRUMENTATION_NAME) }) { - require(pluginConfig.isOpenTelemetrySet()) { "OpenTelemetry must be set" } +val KtorServerTelemetry = + createRouteScopedPlugin("OpenTelemetry", { KtorServerTelemetryBuilder(INSTRUMENTATION_NAME) }) { + require(pluginConfig.isOpenTelemetrySet()) { "OpenTelemetry must be set" } - configureTelemetry(pluginConfig, application) + configureTelemetry(pluginConfig, application) - application.monitor.subscribe(RoutingRoot.RoutingCallStarted) { call -> - HttpServerRoute.update(Context.current(), HttpServerRouteSource.SERVER, { _, arg -> arg!!.route.parent.toString() }, call) + application.monitor.subscribe(RoutingRoot.RoutingCallStarted) { call -> + HttpServerRoute.update(Context.current(), HttpServerRouteSource.SERVER, { _, arg -> arg!!.route.parent.toString() }, call) + } } -} diff --git a/instrumentation/ktor/ktor-3.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/KtorHttpClientTest.kt b/instrumentation/ktor/ktor-3.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/KtorHttpClientTest.kt index dc0cc880c9e8..c16ecc00021d 100644 --- a/instrumentation/ktor/ktor-3.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/KtorHttpClientTest.kt +++ b/instrumentation/ktor/ktor-3.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/KtorHttpClientTest.kt @@ -10,7 +10,6 @@ import io.opentelemetry.instrumentation.testing.junit.http.HttpClientInstrumenta import org.junit.jupiter.api.extension.RegisterExtension class KtorHttpClientTest : AbstractKtorHttpClientTest() { - companion object { @JvmStatic @RegisterExtension diff --git a/instrumentation/ktor/ktor-3.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/KtorHttpServerTest.kt b/instrumentation/ktor/ktor-3.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/KtorHttpServerTest.kt index ae84c111a830..63ca7b7b2177 100644 --- a/instrumentation/ktor/ktor-3.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/KtorHttpServerTest.kt +++ b/instrumentation/ktor/ktor-3.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/KtorHttpServerTest.kt @@ -15,7 +15,6 @@ import io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint import org.junit.jupiter.api.extension.RegisterExtension class KtorHttpServerTest : AbstractKtorHttpServerTest() { - companion object { @JvmStatic @RegisterExtension @@ -32,11 +31,13 @@ class KtorHttpServerTest : AbstractKtorHttpServerTest() { capturedResponseHeaders(TEST_RESPONSE_HEADER) } - install(createRouteScopedPlugin("Failure handler, that can mask exceptions if exception handling is in the wrong phase", ServerEndpoint.EXCEPTION.path, {}) { - on(CallFailed) { call, cause -> - call.respondText("failure: ${cause.message}", status = HttpStatusCode.InternalServerError) + install( + createRouteScopedPlugin("Failure handler, that can mask exceptions if exception handling is in the wrong phase", ServerEndpoint.EXCEPTION.path, {}) { + on(CallFailed) { call, cause -> + call.respondText("failure: ${cause.message}", status = HttpStatusCode.InternalServerError) + } } - }) + ) } } } diff --git a/instrumentation/ktor/ktor-3.0/testing/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/AbstractKtorHttpClientTest.kt b/instrumentation/ktor/ktor-3.0/testing/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/AbstractKtorHttpClientTest.kt index 086b15d66ae5..eeb4e3051532 100644 --- a/instrumentation/ktor/ktor-3.0/testing/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/AbstractKtorHttpClientTest.kt +++ b/instrumentation/ktor/ktor-3.0/testing/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/AbstractKtorHttpClientTest.kt @@ -25,19 +25,20 @@ import org.junit.jupiter.api.AfterAll import java.net.URI abstract class AbstractKtorHttpClientTest : AbstractHttpClientTest() { + private val client = + HttpClient(CIO) { + install(HttpRedirect) - private val client = HttpClient(CIO) { - install(HttpRedirect) - - installTracing() - } - private val singleConnectionClient = HttpClient(CIO) { - engine { - maxConnectionsCount = 1 + installTracing() } + private val singleConnectionClient = + HttpClient(CIO) { + engine { + maxConnectionsCount = 1 + } - installTracing() - } + installTracing() + } @AfterAll fun tearDown() { @@ -47,13 +48,22 @@ abstract class AbstractKtorHttpClientTest : AbstractHttpClientTest.installTracing() - override fun buildRequest(requestMethod: String, uri: URI, requestHeaders: MutableMap) = HttpRequestBuilder(uri.toURL()).apply { + override fun buildRequest( + requestMethod: String, + uri: URI, + requestHeaders: MutableMap + ) = HttpRequestBuilder(uri.toURL()).apply { method = HttpMethod.parse(requestMethod) requestHeaders.forEach { (header, value) -> headers.append(header, value) } } - override fun sendRequest(request: HttpRequestBuilder, method: String, uri: URI, headers: MutableMap) = runBlocking { + override fun sendRequest( + request: HttpRequestBuilder, + method: String, + uri: URI, + headers: MutableMap + ) = runBlocking { client.request(request).status.value } diff --git a/instrumentation/ktor/ktor-3.0/testing/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/AbstractKtorHttpServerTest.kt b/instrumentation/ktor/ktor-3.0/testing/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/AbstractKtorHttpServerTest.kt index 78d0406dfb12..8a692fcbac4f 100644 --- a/instrumentation/ktor/ktor-3.0/testing/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/AbstractKtorHttpServerTest.kt +++ b/instrumentation/ktor/ktor-3.0/testing/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/AbstractKtorHttpServerTest.kt @@ -30,87 +30,96 @@ import java.util.concurrent.TimeUnit import kotlin.time.Duration.Companion.milliseconds abstract class AbstractKtorHttpServerTest : AbstractHttpServerTest>() { - abstract fun getTesting(): InstrumentationExtension abstract fun installOpenTelemetry(application: Application) - override fun setupServer(): EmbeddedServer<*, *> = embeddedServer(Netty, port = port) { - installOpenTelemetry(this) + override fun setupServer(): EmbeddedServer<*, *> = + embeddedServer(Netty, port = port) { + installOpenTelemetry(this) - routing { - get(ServerEndpoint.SUCCESS.path) { - controller(ServerEndpoint.SUCCESS) { - call.respondText(ServerEndpoint.SUCCESS.body, status = HttpStatusCode.fromValue(ServerEndpoint.SUCCESS.status)) + routing { + get(ServerEndpoint.SUCCESS.path) { + controller(ServerEndpoint.SUCCESS) { + call.respondText(ServerEndpoint.SUCCESS.body, status = HttpStatusCode.fromValue(ServerEndpoint.SUCCESS.status)) + } } - } - get(ServerEndpoint.REDIRECT.path) { - controller(ServerEndpoint.REDIRECT) { - call.respondRedirect(ServerEndpoint.REDIRECT.body) + get(ServerEndpoint.REDIRECT.path) { + controller(ServerEndpoint.REDIRECT) { + call.respondRedirect(ServerEndpoint.REDIRECT.body) + } } - } - get(ServerEndpoint.ERROR.path) { - controller(ServerEndpoint.ERROR) { - call.respondText(ServerEndpoint.ERROR.body, status = HttpStatusCode.fromValue(ServerEndpoint.ERROR.status)) + get(ServerEndpoint.ERROR.path) { + controller(ServerEndpoint.ERROR) { + call.respondText(ServerEndpoint.ERROR.body, status = HttpStatusCode.fromValue(ServerEndpoint.ERROR.status)) + } } - } - get(ServerEndpoint.EXCEPTION.path) { - controller(ServerEndpoint.EXCEPTION) { - throw IllegalStateException(ServerEndpoint.EXCEPTION.body) + get(ServerEndpoint.EXCEPTION.path) { + controller(ServerEndpoint.EXCEPTION) { + throw IllegalStateException(ServerEndpoint.EXCEPTION.body) + } } - } - get("/query") { - controller(ServerEndpoint.QUERY_PARAM) { - call.respondText("some=${call.request.queryParameters["some"]}", status = HttpStatusCode.fromValue(ServerEndpoint.QUERY_PARAM.status)) + get("/query") { + controller(ServerEndpoint.QUERY_PARAM) { + call.respondText("some=${call.request.queryParameters["some"]}", status = HttpStatusCode.fromValue(ServerEndpoint.QUERY_PARAM.status)) + } } - } - get("/path/{id}/param") { - controller(ServerEndpoint.PATH_PARAM) { - call.respondText( - call.parameters["id"] - ?: "", - status = HttpStatusCode.fromValue(ServerEndpoint.PATH_PARAM.status), - ) + get("/path/{id}/param") { + controller(ServerEndpoint.PATH_PARAM) { + call.respondText( + call.parameters["id"] + ?: "", + status = HttpStatusCode.fromValue(ServerEndpoint.PATH_PARAM.status), + ) + } } - } - get("/child") { - // with ktor 3.0 triggers the issue described in https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/16430 - withContext(Dispatchers.IO) { - delay(1.milliseconds) - } - controller(ServerEndpoint.INDEXED_CHILD) { - ServerEndpoint.INDEXED_CHILD.collectSpanAttributes { call.request.queryParameters[it] } - call.respondText(ServerEndpoint.INDEXED_CHILD.body, status = HttpStatusCode.fromValue(ServerEndpoint.INDEXED_CHILD.status)) + get("/child") { + // with ktor 3.0 triggers the issue described in https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/16430 + withContext(Dispatchers.IO) { + delay(1.milliseconds) + } + controller(ServerEndpoint.INDEXED_CHILD) { + ServerEndpoint.INDEXED_CHILD.collectSpanAttributes { call.request.queryParameters[it] } + call.respondText(ServerEndpoint.INDEXED_CHILD.body, status = HttpStatusCode.fromValue(ServerEndpoint.INDEXED_CHILD.status)) + } } - } - get("/captureHeaders") { - controller(ServerEndpoint.CAPTURE_HEADERS) { - call.response.header("X-Test-Response", call.request.header("X-Test-Request") ?: "") - call.respondText(ServerEndpoint.CAPTURE_HEADERS.body, status = HttpStatusCode.fromValue(ServerEndpoint.CAPTURE_HEADERS.status)) + get("/captureHeaders") { + controller(ServerEndpoint.CAPTURE_HEADERS) { + call.response.header("X-Test-Response", call.request.header("X-Test-Request") ?: "") + call.respondText(ServerEndpoint.CAPTURE_HEADERS.body, status = HttpStatusCode.fromValue(ServerEndpoint.CAPTURE_HEADERS.status)) + } } } - } - }.start() + }.start() override fun stopServer(server: EmbeddedServer<*, *>) { server.stop(0, 10, TimeUnit.SECONDS) } // Copy in HttpServerTest.controller but make it a suspending function - private suspend fun controller(endpoint: ServerEndpoint, wrapped: suspend () -> Unit) { + private suspend fun controller( + endpoint: ServerEndpoint, + wrapped: suspend () -> Unit + ) { assert(Span.current().spanContext.isValid, { "Controller should have a parent span. " }) if (endpoint == ServerEndpoint.NOT_FOUND) { wrapped() return } - val span = getTesting().openTelemetry.getTracer("test").spanBuilder("controller").setSpanKind(SpanKind.INTERNAL).startSpan() + val span = + getTesting() + .openTelemetry + .getTracer("test") + .spanBuilder("controller") + .setSpanKind(SpanKind.INTERNAL) + .startSpan() try { withContext(Context.current().with(span).asContextElement()) { wrapped() diff --git a/instrumentation/ktor/ktor-3.0/testing/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/AbstractKtorServerMetricsTest.kt b/instrumentation/ktor/ktor-3.0/testing/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/AbstractKtorServerMetricsTest.kt index 2b54572c1492..2fd7ffeb14ce 100644 --- a/instrumentation/ktor/ktor-3.0/testing/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/AbstractKtorServerMetricsTest.kt +++ b/instrumentation/ktor/ktor-3.0/testing/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/AbstractKtorServerMetricsTest.kt @@ -41,11 +41,11 @@ import java.util.stream.Stream * experimental flag is enabled. */ abstract class AbstractKtorServerMetricsTest : AbstractHttpServerUsingTest>() { - private val errorDuringSendEndpoint = ServerEndpoint("errorDuringSend", "error-during-send", 500, "") private val errorAfterSendEndpoint = ServerEndpoint("errorAfterSend", "error-after-send", 200, "") abstract fun serverInstall(application: Application) + abstract fun instrumentationName(): String @BeforeAll @@ -60,24 +60,25 @@ abstract class AbstractKtorServerMetricsTest : AbstractHttpServerUsingTest = embeddedServer(Netty, port = port) { - serverInstall(this) + override fun setupServer(): EmbeddedServer<*, *> = + embeddedServer(Netty, port = port) { + serverInstall(this) - routing { - get(errorDuringSendEndpoint.path) { - call.respondBytesWriter { + routing { + get(errorDuringSendEndpoint.path) { + call.respondBytesWriter { + throw IllegalArgumentException("exception") + } + } + get(errorAfterSendEndpoint.path) { + call.respondText( + errorAfterSendEndpoint.body, + status = HttpStatusCode.fromValue(errorAfterSendEndpoint.status) + ) throw IllegalArgumentException("exception") } } - get(errorAfterSendEndpoint.path) { - call.respondText( - errorAfterSendEndpoint.body, - status = HttpStatusCode.fromValue(errorAfterSendEndpoint.status) - ) - throw IllegalArgumentException("exception") - } - } - }.start() + }.start() override fun stopServer(server: EmbeddedServer<*, *>) { server.stop(0, 10, TimeUnit.SECONDS) @@ -100,25 +101,29 @@ abstract class AbstractKtorServerMetricsTest : AbstractHttpServerUsingTest - metrics!!.anySatisfy(ThrowingConsumer { metric: MetricData? -> - assertThat(metric) - .hasDescription("Number of active HTTP server requests.") - .hasUnit("{requests}") - .hasLongSumSatisfying { sum -> - sum.hasPointsSatisfying({ point -> - point.hasValue(0) - .hasAttributesSatisfyingExactly( - equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "GET"), - equalTo(UrlAttributes.URL_SCHEME, "http"), - ) - }) - } - }) + metrics!!.anySatisfy( + ThrowingConsumer { metric: MetricData? -> + assertThat(metric) + .hasDescription("Number of active HTTP server requests.") + .hasUnit("{requests}") + .hasLongSumSatisfying { sum -> + sum.hasPointsSatisfying({ point -> + point + .hasValue(0) + .hasAttributesSatisfyingExactly( + equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "GET"), + equalTo(UrlAttributes.URL_SCHEME, "http"), + ) + }) + } + } + ) } } - private fun provideArguments(): Stream = Stream.of( - arguments(errorDuringSendEndpoint), - arguments(errorAfterSendEndpoint), - ) + private fun provideArguments(): Stream = + Stream.of( + arguments(errorDuringSendEndpoint), + arguments(errorAfterSendEndpoint), + ) } diff --git a/instrumentation/ktor/ktor-3.0/testing/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/KtorHttpClientSingleConnection.kt b/instrumentation/ktor/ktor-3.0/testing/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/KtorHttpClientSingleConnection.kt index 82a2679c5a12..01823fe2c1cd 100644 --- a/instrumentation/ktor/ktor-3.0/testing/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/KtorHttpClientSingleConnection.kt +++ b/instrumentation/ktor/ktor-3.0/testing/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v3_0/KtorHttpClientSingleConnection.kt @@ -15,16 +15,19 @@ class KtorHttpClientSingleConnection( private val host: String, private val port: Int ) : SingleConnection { - - override fun doRequest(path: String, requestHeaders: MutableMap) = runBlocking { - val request = HttpRequestBuilder( - scheme = "http", - host = host, - port = port, - path = path, - ).apply { - requestHeaders.forEach { (name, value) -> headers.append(name, value) } - } + override fun doRequest( + path: String, + requestHeaders: MutableMap + ) = runBlocking { + val request = + HttpRequestBuilder( + scheme = "http", + host = host, + port = port, + path = path, + ).apply { + requestHeaders.forEach { (name, value) -> headers.append(name, value) } + } client.request(request).status.value } diff --git a/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/AbstractKtorClientTelemetry.kt b/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/AbstractKtorClientTelemetry.kt index 37f32d4edb10..92eeaabfe1a1 100644 --- a/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/AbstractKtorClientTelemetry.kt +++ b/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/AbstractKtorClientTelemetry.kt @@ -16,7 +16,6 @@ abstract class AbstractKtorClientTelemetry( private val instrumenter: Instrumenter, private val propagators: ContextPropagators, ) { - internal fun createSpan(requestBuilder: HttpRequestBuilder): Context? { val parentContext = Context.current() val requestData = requestBuilder.build() @@ -28,15 +27,27 @@ abstract class AbstractKtorClientTelemetry( } } - internal fun populateRequestHeaders(requestBuilder: HttpRequestBuilder, context: Context) { + internal fun populateRequestHeaders( + requestBuilder: HttpRequestBuilder, + context: Context + ) { propagators.textMapPropagator.inject(context, requestBuilder, KtorHttpHeadersSetter) } - internal fun endSpan(context: Context, call: HttpClientCall, error: Throwable?) { + internal fun endSpan( + context: Context, + call: HttpClientCall, + error: Throwable? + ) { endSpan(context, HttpRequestBuilder().takeFrom(call.request), call.response, error) } - internal fun endSpan(context: Context, requestBuilder: HttpRequestBuilder, response: HttpResponse?, error: Throwable?) { + internal fun endSpan( + context: Context, + requestBuilder: HttpRequestBuilder, + response: HttpResponse?, + error: Throwable? + ) { instrumenter.end(context, requestBuilder.build(), response, error) } } diff --git a/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/AbstractKtorClientTelemetryBuilder.kt b/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/AbstractKtorClientTelemetryBuilder.kt index 0c20d8c2f5fc..6ff458af1b37 100644 --- a/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/AbstractKtorClientTelemetryBuilder.kt +++ b/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/AbstractKtorClientTelemetryBuilder.kt @@ -34,11 +34,12 @@ abstract class AbstractKtorClientTelemetryBuilder( fun setOpenTelemetry(openTelemetry: OpenTelemetry) { this.openTelemetry = openTelemetry - this.builder = DefaultHttpClientInstrumenterBuilder.create( - instrumentationName, - openTelemetry, - KtorHttpClientAttributesGetter - ) + this.builder = + DefaultHttpClientInstrumenterBuilder.create( + instrumentationName, + openTelemetry, + KtorHttpClientAttributesGetter + ) } protected fun getOpenTelemetry(): OpenTelemetry = openTelemetry @@ -68,15 +69,27 @@ abstract class AbstractKtorClientTelemetryBuilder( fun attributesExtractor(extractorBuilder: ExtractorBuilder.() -> Unit = {}) { val builder = ExtractorBuilder().apply(extractorBuilder).build() - this.builder.addAttributesExtractor(object : AttributesExtractor { - override fun onStart(attributes: AttributesBuilder, parentContext: Context, request: HttpRequestData) { - builder.onStart(OnStartData(attributes, parentContext, request)) - } - - override fun onEnd(attributes: AttributesBuilder, context: Context, request: HttpRequestData, response: HttpResponse?, error: Throwable?) { - builder.onEnd(OnEndData(attributes, context, request, response, error)) + this.builder.addAttributesExtractor( + object : AttributesExtractor { + override fun onStart( + attributes: AttributesBuilder, + parentContext: Context, + request: HttpRequestData + ) { + builder.onStart(OnStartData(attributes, parentContext, request)) + } + + override fun onEnd( + attributes: AttributesBuilder, + context: Context, + request: HttpRequestData, + response: HttpResponse?, + error: Throwable? + ) { + builder.onEnd(OnEndData(attributes, context, request, response, error)) + } } - }) + ) } fun spanNameExtractor(spanNameExtractor: UnaryOperator>) { @@ -98,7 +111,10 @@ abstract class AbstractKtorClientTelemetryBuilder( internal fun build(): Extractor = Extractor(onStart, onEnd) } - internal class Extractor(val onStart: OnStartData.() -> Unit, val onEnd: OnEndData.() -> Unit) + internal class Extractor( + val onStart: OnStartData.() -> Unit, + val onEnd: OnEndData.() -> Unit + ) data class OnStartData( val attributes: AttributesBuilder, diff --git a/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/AbstractKtorServerTelemetryBuilder.kt b/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/AbstractKtorServerTelemetryBuilder.kt index 2b57bec039f0..fe2159c78afa 100644 --- a/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/AbstractKtorServerTelemetryBuilder.kt +++ b/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/AbstractKtorServerTelemetryBuilder.kt @@ -21,7 +21,9 @@ import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor import io.opentelemetry.instrumentation.ktor.common.v2_0.internal.KtorBuilderUtil import java.util.function.UnaryOperator -abstract class AbstractKtorServerTelemetryBuilder(private val instrumentationName: String) { +abstract class AbstractKtorServerTelemetryBuilder( + private val instrumentationName: String +) { companion object { init { KtorBuilderUtil.serverBuilderExtractor = { it.builder } @@ -45,10 +47,10 @@ abstract class AbstractKtorServerTelemetryBuilder(private val instrumentationNam fun spanStatusExtractor(extract: SpanStatusData.(SpanStatusExtractor) -> Unit) { builder.setSpanStatusExtractorCustomizer { prevExtractor -> SpanStatusExtractor { - spanStatusBuilder: SpanStatusBuilder, - request: ApplicationRequest, - response: ApplicationResponse?, - throwable: Throwable? + spanStatusBuilder: SpanStatusBuilder, + request: ApplicationRequest, + response: ApplicationResponse?, + throwable: Throwable? -> extract( SpanStatusData(spanStatusBuilder, request, response, throwable), @@ -77,11 +79,21 @@ abstract class AbstractKtorServerTelemetryBuilder(private val instrumentationNam val builder = ExtractorBuilder().apply(extractorBuilder).build() this.builder.addAttributesExtractor( object : AttributesExtractor { - override fun onStart(attributes: AttributesBuilder, parentContext: Context, request: ApplicationRequest) { + override fun onStart( + attributes: AttributesBuilder, + parentContext: Context, + request: ApplicationRequest + ) { builder.onStart(OnStartData(attributes, parentContext, request)) } - override fun onEnd(attributes: AttributesBuilder, context: Context, request: ApplicationRequest, response: ApplicationResponse?, error: Throwable?) { + override fun onEnd( + attributes: AttributesBuilder, + context: Context, + request: ApplicationRequest, + response: ApplicationResponse?, + error: Throwable? + ) { builder.onEnd(OnEndData(attributes, context, request, response, error)) } } @@ -107,7 +119,10 @@ abstract class AbstractKtorServerTelemetryBuilder(private val instrumentationNam internal fun build(): Extractor = Extractor(onStart, onEnd) } - internal class Extractor(val onStart: OnStartData.() -> Unit, val onEnd: OnEndData.() -> Unit) + internal class Extractor( + val onStart: OnStartData.() -> Unit, + val onEnd: OnEndData.() -> Unit + ) data class OnStartData( val attributes: AttributesBuilder, diff --git a/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/ApplicationRequestGetter.kt b/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/ApplicationRequestGetter.kt index 799dc5d6bec5..470e749b5949 100644 --- a/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/ApplicationRequestGetter.kt +++ b/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/ApplicationRequestGetter.kt @@ -12,7 +12,13 @@ import java.util.Collections internal object ApplicationRequestGetter : TextMapGetter { override fun keys(carrier: ApplicationRequest): Iterable = carrier.headers.names() - override fun get(carrier: ApplicationRequest?, name: String): String? = carrier?.headers?.get(name) + override fun get( + carrier: ApplicationRequest?, + name: String + ): String? = carrier?.headers?.get(name) - override fun getAll(carrier: ApplicationRequest?, name: String): Iterator = carrier?.headers?.getAll(name)?.iterator() ?: Collections.emptyIterator() + override fun getAll( + carrier: ApplicationRequest?, + name: String + ): Iterator = carrier?.headers?.getAll(name)?.iterator() ?: Collections.emptyIterator() } diff --git a/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/KtorHttpClientAttributesGetter.kt b/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/KtorHttpClientAttributesGetter.kt index 8bc631b348b8..0e241d22ec13 100644 --- a/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/KtorHttpClientAttributesGetter.kt +++ b/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/KtorHttpClientAttributesGetter.kt @@ -10,20 +10,36 @@ import io.ktor.client.statement.* import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesGetter internal object KtorHttpClientAttributesGetter : HttpClientAttributesGetter { - override fun getUrlFull(request: HttpRequestData) = request.url.toString() override fun getHttpRequestMethod(request: HttpRequestData) = request.method.value - override fun getHttpRequestHeader(request: HttpRequestData, name: String) = request.headers.getAll(name).orEmpty() - - override fun getHttpResponseStatusCode(request: HttpRequestData, response: HttpResponse, error: Throwable?) = response.status.value - - override fun getHttpResponseHeader(request: HttpRequestData, response: HttpResponse, name: String) = response.headers.getAll(name).orEmpty() - - override fun getNetworkProtocolName(request: HttpRequestData, response: HttpResponse?): String? = response?.version?.name - - override fun getNetworkProtocolVersion(request: HttpRequestData, response: HttpResponse?): String? { + override fun getHttpRequestHeader( + request: HttpRequestData, + name: String + ) = request.headers.getAll(name).orEmpty() + + override fun getHttpResponseStatusCode( + request: HttpRequestData, + response: HttpResponse, + error: Throwable? + ) = response.status.value + + override fun getHttpResponseHeader( + request: HttpRequestData, + response: HttpResponse, + name: String + ) = response.headers.getAll(name).orEmpty() + + override fun getNetworkProtocolName( + request: HttpRequestData, + response: HttpResponse? + ): String? = response?.version?.name + + override fun getNetworkProtocolVersion( + request: HttpRequestData, + response: HttpResponse? + ): String? { val version = response?.version ?: return null if (version.minor == 0) { return "${version.major}" diff --git a/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/KtorHttpHeadersSetter.kt b/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/KtorHttpHeadersSetter.kt index fc7926c9dea9..8a497705f0cf 100644 --- a/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/KtorHttpHeadersSetter.kt +++ b/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/KtorHttpHeadersSetter.kt @@ -9,8 +9,11 @@ import io.ktor.client.request.* import io.opentelemetry.context.propagation.TextMapSetter internal object KtorHttpHeadersSetter : TextMapSetter { - - override fun set(carrier: HttpRequestBuilder?, key: String, value: String) { + override fun set( + carrier: HttpRequestBuilder?, + key: String, + value: String + ) { carrier?.headers?.set(key, value) } } diff --git a/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/KtorHttpServerAttributesGetter.kt b/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/KtorHttpServerAttributesGetter.kt index a5872bd0d09f..75203f37b1c7 100644 --- a/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/KtorHttpServerAttributesGetter.kt +++ b/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/KtorHttpServerAttributesGetter.kt @@ -16,22 +16,33 @@ import java.lang.invoke.MethodHandles import java.lang.invoke.MethodType internal object KtorHttpServerAttributesGetter : HttpServerAttributesGetter { - private val getRemoteAddressMethodHandle: MethodHandle? = getRemoteAddressMethodHandle() - private fun getRemoteAddressMethodHandle(): MethodHandle? = try { - MethodHandles.lookup().findVirtual(RequestConnectionPoint::class.java, "getRemoteAddress", MethodType.methodType(String::class.java)) - } catch (_: Exception) { - null - } + private fun getRemoteAddressMethodHandle(): MethodHandle? = + try { + MethodHandles.lookup().findVirtual(RequestConnectionPoint::class.java, "getRemoteAddress", MethodType.methodType(String::class.java)) + } catch (_: Exception) { + null + } override fun getHttpRequestMethod(request: ApplicationRequest): String = request.httpMethod.value - override fun getHttpRequestHeader(request: ApplicationRequest, name: String): List = request.headers.getAll(name) ?: emptyList() + override fun getHttpRequestHeader( + request: ApplicationRequest, + name: String + ): List = request.headers.getAll(name) ?: emptyList() - override fun getHttpResponseStatusCode(request: ApplicationRequest, response: ApplicationResponse, error: Throwable?): Int? = response.status()?.value + override fun getHttpResponseStatusCode( + request: ApplicationRequest, + response: ApplicationResponse, + error: Throwable? + ): Int? = response.status()?.value - override fun getHttpResponseHeader(request: ApplicationRequest, response: ApplicationResponse, name: String): List = response.headers.allValues().getAll(name) ?: emptyList() + override fun getHttpResponseHeader( + request: ApplicationRequest, + response: ApplicationResponse, + name: String + ): List = response.headers.allValues().getAll(name) ?: emptyList() override fun getUrlScheme(request: ApplicationRequest): String = request.origin.scheme @@ -39,20 +50,30 @@ internal object KtorHttpServerAttributesGetter : HttpServerAttributesGetter("OpenTelemetry") - fun install(plugin: AbstractKtorClientTelemetry, scope: HttpClient) { + fun install( + plugin: AbstractKtorClientTelemetry, + scope: HttpClient + ) { installSpanCreation(plugin, scope) installSpanEnd(plugin, scope) } - private fun installSpanCreation(plugin: AbstractKtorClientTelemetry, scope: HttpClient) { + private fun installSpanCreation( + plugin: AbstractKtorClientTelemetry, + scope: HttpClient + ) { val initializeRequestPhase = PipelinePhase("OpenTelemetryInitializeRequest") scope.requestPipeline.insertPhaseAfter(HttpRequestPipeline.State, initializeRequestPhase) @@ -64,7 +70,10 @@ object KtorClientTelemetryUtil { } @OptIn(InternalCoroutinesApi::class) - private fun installSpanEnd(plugin: AbstractKtorClientTelemetry, scope: HttpClient) { + private fun installSpanEnd( + plugin: AbstractKtorClientTelemetry, + scope: HttpClient + ) { val endSpanPhase = PipelinePhase("OpenTelemetryEndSpan") scope.receivePipeline.insertPhaseBefore(HttpReceivePipeline.State, endSpanPhase) @@ -75,11 +84,12 @@ object KtorClientTelemetryUtil { scope.launch { val job = it.call.coroutineContext.job job.join() - val cause = if (!job.isCancelled) { - null - } else { - kotlin.runCatching { job.getCancellationException() }.getOrNull() - } + val cause = + if (!job.isCancelled) { + null + } else { + kotlin.runCatching { job.getCancellationException() }.getOrNull() + } plugin.endSpan(openTelemetryContext, it.call, cause) } diff --git a/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/internal/KtorServerTelemetryUtil.kt b/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/internal/KtorServerTelemetryUtil.kt index e2b82100fc22..055212309854 100644 --- a/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/internal/KtorServerTelemetryUtil.kt +++ b/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/internal/KtorServerTelemetryUtil.kt @@ -34,19 +34,24 @@ object KtorServerTelemetryUtil { // requests. This issue can be worked around by adding -Dio.ktor.internal.disable.sfg=true to jvm // arguments. Adding this no-op interceptor seems to also work around the issue. // See https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/16430 - private val emptyInterceptor = object : ContinuationInterceptor { - override val key = ContinuationInterceptor + private val emptyInterceptor = + object : ContinuationInterceptor { + override val key = ContinuationInterceptor - override fun interceptContinuation(continuation: Continuation): Continuation = object : Continuation { - override val context = continuation.context + override fun interceptContinuation(continuation: Continuation): Continuation = + object : Continuation { + override val context = continuation.context - override fun resumeWith(result: Result) { - continuation.resumeWith(result) - } + override fun resumeWith(result: Result) { + continuation.resumeWith(result) + } + } } - } - fun configureTelemetry(builder: AbstractKtorServerTelemetryBuilder, application: Application) { + fun configureTelemetry( + builder: AbstractKtorServerTelemetryBuilder, + application: Application + ) { val contextKey = AttributeKey("OpenTelemetry") val errorKey = AttributeKey("OpenTelemetryException") val processedKey = AttributeKey("OpenTelemetryProcessed") @@ -104,9 +109,10 @@ object KtorServerTelemetryUtil { } } - private fun instrumenter(builder: AbstractKtorServerTelemetryBuilder): Instrumenter = InstrumenterUtil.buildUpstreamInstrumenter( - builder.builder.instrumenterBuilder(), - ApplicationRequestGetter, - builder.spanKindExtractor(SpanKindExtractor.alwaysServer()) - ) + private fun instrumenter(builder: AbstractKtorServerTelemetryBuilder): Instrumenter = + InstrumenterUtil.buildUpstreamInstrumenter( + builder.builder.instrumenterBuilder(), + ApplicationRequestGetter, + builder.spanKindExtractor(SpanKindExtractor.alwaysServer()) + ) } diff --git a/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/internal/KtorServerTracer.kt b/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/internal/KtorServerTracer.kt index a37740023e00..6298b73df5c3 100644 --- a/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/internal/KtorServerTracer.kt +++ b/instrumentation/ktor/ktor-common-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/internal/KtorServerTracer.kt @@ -23,7 +23,11 @@ class KtorServerTracer( return instrumenter.start(parentContext, call.request) } - fun end(context: Context, call: ApplicationCall, error: Throwable?) { + fun end( + context: Context, + call: ApplicationCall, + error: Throwable? + ) { instrumenter.end(context, call.request, call.response, error) } } diff --git a/instrumentation/ktor/ktor-common-2.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/internal/IpAddressUtilTest.kt b/instrumentation/ktor/ktor-common-2.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/internal/IpAddressUtilTest.kt index 85cc1688d7eb..81618ad273c0 100644 --- a/instrumentation/ktor/ktor-common-2.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/internal/IpAddressUtilTest.kt +++ b/instrumentation/ktor/ktor-common-2.0/library/src/test/kotlin/io/opentelemetry/instrumentation/ktor/common/v2_0/internal/IpAddressUtilTest.kt @@ -9,7 +9,6 @@ import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class IpAddressUtilTest { - @Test fun `test ip address`() { assertThat(isIpAddress("2001:0660:7401:0200:0000:0000:0edf:bdd7")).isTrue() diff --git a/instrumentation/kubernetes-client-7.0/javaagent/build.gradle.kts b/instrumentation/kubernetes-client-7.0/javaagent/build.gradle.kts index 8f694ae4726f..7500d7042ad0 100644 --- a/instrumentation/kubernetes-client-7.0/javaagent/build.gradle.kts +++ b/instrumentation/kubernetes-client-7.0/javaagent/build.gradle.kts @@ -45,15 +45,24 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.kubernetes-client.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.kubernetes-client.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.kubernetes-client.experimental-span-attributes=true", + ) } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/lettuce/lettuce-4.0/javaagent/build.gradle.kts b/instrumentation/lettuce/lettuce-4.0/javaagent/build.gradle.kts index 06ecee3e4598..031736e70149 100644 --- a/instrumentation/lettuce/lettuce-4.0/javaagent/build.gradle.kts +++ b/instrumentation/lettuce/lettuce-4.0/javaagent/build.gradle.kts @@ -28,15 +28,24 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.lettuce.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.lettuce.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.lettuce.experimental-span-attributes=true", + ) } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database,service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database,service.peer") diff --git a/instrumentation/lettuce/lettuce-5.0/javaagent/build.gradle.kts b/instrumentation/lettuce/lettuce-5.0/javaagent/build.gradle.kts index a8aead4cc14a..2fcf0b5e30c4 100644 --- a/instrumentation/lettuce/lettuce-5.0/javaagent/build.gradle.kts +++ b/instrumentation/lettuce/lettuce-5.0/javaagent/build.gradle.kts @@ -35,15 +35,24 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.lettuce.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.lettuce.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.lettuce.experimental-span-attributes=true", + ) } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database,service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database,service.peer") diff --git a/instrumentation/lettuce/lettuce-5.1/javaagent/build.gradle.kts b/instrumentation/lettuce/lettuce-5.1/javaagent/build.gradle.kts index bc7b3df809c3..0ebc7d399e26 100644 --- a/instrumentation/lettuce/lettuce-5.1/javaagent/build.gradle.kts +++ b/instrumentation/lettuce/lettuce-5.1/javaagent/build.gradle.kts @@ -34,7 +34,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database") diff --git a/instrumentation/lettuce/lettuce-5.1/library/build.gradle.kts b/instrumentation/lettuce/lettuce-5.1/library/build.gradle.kts index 96a782d3b38a..fddb188d4e51 100644 --- a/instrumentation/lettuce/lettuce-5.1/library/build.gradle.kts +++ b/instrumentation/lettuce/lettuce-5.1/library/build.gradle.kts @@ -20,7 +20,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") } diff --git a/instrumentation/log4j/log4j-appender-2.17/javaagent/build.gradle.kts b/instrumentation/log4j/log4j-appender-2.17/javaagent/build.gradle.kts index a28f3b806c6a..d0383affb07a 100644 --- a/instrumentation/log4j/log4j-appender-2.17/javaagent/build.gradle.kts +++ b/instrumentation/log4j/log4j-appender-2.17/javaagent/build.gradle.kts @@ -47,13 +47,21 @@ tasks.withType().configureEach { tasks { val testAsync by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath - jvmArgs("-DLog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector") + jvmArgs( + "-DLog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector", + ) } val testV3Preview by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.common.v3-preview=true") } diff --git a/instrumentation/log4j/log4j-appender-2.17/library/build.gradle.kts b/instrumentation/log4j/log4j-appender-2.17/library/build.gradle.kts index 24189a4c8d00..583f2d8e3368 100644 --- a/instrumentation/log4j/log4j-appender-2.17/library/build.gradle.kts +++ b/instrumentation/log4j/log4j-appender-2.17/library/build.gradle.kts @@ -6,7 +6,11 @@ dependencies { library("org.apache.logging.log4j:log4j-core:2.17.0") annotationProcessor("org.apache.logging.log4j:log4j-core:2.17.0") - implementation(project(":instrumentation:log4j:log4j-context-data:log4j-context-data-2.17:library-autoconfigure")) + implementation( + project( + ":instrumentation:log4j:log4j-context-data:log4j-context-data-2.17:library-autoconfigure", + ), + ) testImplementation(project(":instrumentation:log4j:log4j-appender-2.17:testing")) testImplementation("io.opentelemetry:opentelemetry-sdk-testing") @@ -24,19 +28,30 @@ tasks { } val testAsyncLogger by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath - jvmArgs("-DLog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector") + jvmArgs( + "-DLog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector", + ) } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=code") } val testBothSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=code/dup") } diff --git a/instrumentation/log4j/log4j-context-data/log4j-context-data-2.17/javaagent/build.gradle.kts b/instrumentation/log4j/log4j-context-data/log4j-context-data-2.17/javaagent/build.gradle.kts index ffb05ed9387c..28996732ff44 100644 --- a/instrumentation/log4j/log4j-context-data/log4j-context-data-2.17/javaagent/build.gradle.kts +++ b/instrumentation/log4j/log4j-context-data/log4j-context-data-2.17/javaagent/build.gradle.kts @@ -14,11 +14,19 @@ muzzle { dependencies { library("org.apache.logging.log4j:log4j-core:2.17.0") - implementation(project(":instrumentation:log4j:log4j-context-data:log4j-context-data-2.17:library-autoconfigure")) + implementation( + project( + ":instrumentation:log4j:log4j-context-data:log4j-context-data-2.17:library-autoconfigure", + ), + ) - testInstrumentation(project(":instrumentation:log4j:log4j-context-data:log4j-context-data-2.7:javaagent")) + testInstrumentation( + project(":instrumentation:log4j:log4j-context-data:log4j-context-data-2.7:javaagent"), + ) - testImplementation(project(":instrumentation:log4j:log4j-context-data:log4j-context-data-common:testing")) + testImplementation( + project(":instrumentation:log4j:log4j-context-data:log4j-context-data-common:testing"), + ) } testing { @@ -32,14 +40,18 @@ testing { } } dependencies { - implementation(project(":instrumentation:log4j:log4j-context-data:log4j-context-data-common:testing")) + implementation( + project(":instrumentation:log4j:log4j-context-data:log4j-context-data-common:testing"), + ) } targets { all { testTask.configure { jvmArgs("-Dlog4j2.enable.threadlocals=false") - jvmArgs("-Dotel.instrumentation.common.mdc.resource-attributes=service.name,telemetry.sdk.language") + jvmArgs( + "-Dotel.instrumentation.common.mdc.resource-attributes=service.name,telemetry.sdk.language", + ) } } } @@ -47,7 +59,9 @@ testing { val testAddBaggage by registering(JvmTestSuite::class) { dependencies { - implementation(project(":instrumentation:log4j:log4j-context-data:log4j-context-data-common:testing")) + implementation( + project(":instrumentation:log4j:log4j-context-data:log4j-context-data-common:testing"), + ) } targets { @@ -62,7 +76,9 @@ testing { val testLoggingKeys by registering(JvmTestSuite::class) { dependencies { - implementation(project(":instrumentation:log4j:log4j-context-data:log4j-context-data-common:testing")) + implementation( + project(":instrumentation:log4j:log4j-context-data:log4j-context-data-common:testing"), + ) } targets { @@ -88,7 +104,9 @@ tasks { // now testing-common includes jetty / servlet. test { jvmArgs("-Dlog4j2.enable.threadlocals=true") - jvmArgs("-Dotel.instrumentation.common.mdc.resource-attributes=service.name,telemetry.sdk.language") + jvmArgs( + "-Dotel.instrumentation.common.mdc.resource-attributes=service.name,telemetry.sdk.language", + ) } named("check") { diff --git a/instrumentation/log4j/log4j-context-data/log4j-context-data-2.17/library-autoconfigure/build.gradle.kts b/instrumentation/log4j/log4j-context-data/log4j-context-data-2.17/library-autoconfigure/build.gradle.kts index 531ed79bcf72..5ecd4d2ea1fe 100644 --- a/instrumentation/log4j/log4j-context-data/log4j-context-data-2.17/library-autoconfigure/build.gradle.kts +++ b/instrumentation/log4j/log4j-context-data/log4j-context-data-2.17/library-autoconfigure/build.gradle.kts @@ -8,7 +8,9 @@ dependencies { compileOnly(project(":javaagent-extension-api")) library("org.apache.logging.log4j:log4j-core:2.17.0") - testImplementation(project(":instrumentation:log4j:log4j-context-data:log4j-context-data-common:testing")) + testImplementation( + project(":instrumentation:log4j:log4j-context-data:log4j-context-data-common:testing"), + ) } tasks { @@ -20,7 +22,10 @@ tasks { } val testAddBaggage by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { includeTestsMatching("LibraryLog4j2BaggageTest") @@ -29,7 +34,10 @@ tasks { } val testLoggingKeys by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { includeTestsMatching("LibraryLog4j2LoggingKeysTest") diff --git a/instrumentation/log4j/log4j-context-data/log4j-context-data-2.7/javaagent/build.gradle.kts b/instrumentation/log4j/log4j-context-data/log4j-context-data-2.7/javaagent/build.gradle.kts index 01733c59db22..548448b917e8 100644 --- a/instrumentation/log4j/log4j-context-data/log4j-context-data-2.7/javaagent/build.gradle.kts +++ b/instrumentation/log4j/log4j-context-data/log4j-context-data-2.7/javaagent/build.gradle.kts @@ -14,9 +14,13 @@ muzzle { dependencies { library("org.apache.logging.log4j:log4j-core:2.7") - testInstrumentation(project(":instrumentation:log4j:log4j-context-data:log4j-context-data-2.17:javaagent")) + testInstrumentation( + project(":instrumentation:log4j:log4j-context-data:log4j-context-data-2.17:javaagent"), + ) - testImplementation(project(":instrumentation:log4j:log4j-context-data:log4j-context-data-common:testing")) + testImplementation( + project(":instrumentation:log4j:log4j-context-data:log4j-context-data-common:testing"), + ) latestDepTestLibrary("org.apache.logging.log4j:log4j-core:2.16.+") // see log4j-context-data-2.17 module } @@ -27,11 +31,16 @@ tasks { excludeTestsMatching("Log4j27BaggageTest") excludeTestsMatching("Log4j27LoggingKeysTest") } - jvmArgs("-Dotel.instrumentation.common.mdc.resource-attributes=service.name,telemetry.sdk.language") + jvmArgs( + "-Dotel.instrumentation.common.mdc.resource-attributes=service.name,telemetry.sdk.language", + ) } val testAddBaggage by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { includeTestsMatching("Log4j27BaggageTest") @@ -40,7 +49,10 @@ tasks { } val testLoggingKeys by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { includeTestsMatching("Log4j27LoggingKeysTest") diff --git a/instrumentation/log4j/log4j-mdc-1.2/javaagent/build.gradle.kts b/instrumentation/log4j/log4j-mdc-1.2/javaagent/build.gradle.kts index 05e8142d814e..65a3b96f3218 100644 --- a/instrumentation/log4j/log4j-mdc-1.2/javaagent/build.gradle.kts +++ b/instrumentation/log4j/log4j-mdc-1.2/javaagent/build.gradle.kts @@ -32,6 +32,8 @@ configurations { tasks { test { - jvmArgs("-Dotel.instrumentation.common.mdc.resource-attributes=service.name,telemetry.sdk.language") + jvmArgs( + "-Dotel.instrumentation.common.mdc.resource-attributes=service.name,telemetry.sdk.language", + ) } } diff --git a/instrumentation/logback/logback-appender-1.0/library/build.gradle.kts b/instrumentation/logback/logback-appender-1.0/library/build.gradle.kts index f0fcb326a7c2..82859013c45b 100644 --- a/instrumentation/logback/logback-appender-1.0/library/build.gradle.kts +++ b/instrumentation/logback/logback-appender-1.0/library/build.gradle.kts @@ -176,13 +176,19 @@ testing { tasks { val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=code") } val testBothSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=code/dup") } diff --git a/instrumentation/logback/logback-appender-1.0/library/src/slf4j2ApiTest/java/io/opentelemetry/instrumentation/logback/appender/v1_0/Slf4j2Test.java b/instrumentation/logback/logback-appender-1.0/library/src/slf4j2ApiTest/java/io/opentelemetry/instrumentation/logback/appender/v1_0/Slf4j2Test.java index 38f8b943d479..c9d8918c31f0 100644 --- a/instrumentation/logback/logback-appender-1.0/library/src/slf4j2ApiTest/java/io/opentelemetry/instrumentation/logback/appender/v1_0/Slf4j2Test.java +++ b/instrumentation/logback/logback-appender-1.0/library/src/slf4j2ApiTest/java/io/opentelemetry/instrumentation/logback/appender/v1_0/Slf4j2Test.java @@ -153,7 +153,8 @@ void argumentsAndTemplate() { .hasResource(resource) .hasInstrumentationScope(instrumentationScopeInfo) .hasBody( - "log message 'world' and 3.141592653589793, bool true, long 9223372036854775807") + "log message 'world' and 3.141592653589793, bool true, long" + + " 9223372036854775807") .hasTotalAttributeCount(codeAttributesLogCount() + 2) .hasAttributesSatisfying( equalTo( diff --git a/instrumentation/logback/logback-mdc-1.0/javaagent/build.gradle.kts b/instrumentation/logback/logback-mdc-1.0/javaagent/build.gradle.kts index 10b1337675aa..388924438ae3 100644 --- a/instrumentation/logback/logback-mdc-1.0/javaagent/build.gradle.kts +++ b/instrumentation/logback/logback-mdc-1.0/javaagent/build.gradle.kts @@ -76,7 +76,9 @@ dependencies { tasks { test { - jvmArgs("-Dotel.instrumentation.common.mdc.resource-attributes=service.name,telemetry.sdk.language") + jvmArgs( + "-Dotel.instrumentation.common.mdc.resource-attributes=service.name,telemetry.sdk.language", + ) } named("check") { diff --git a/instrumentation/methods/javaagent/build.gradle.kts b/instrumentation/methods/javaagent/build.gradle.kts index f3b3111acb77..8a3a7936da40 100644 --- a/instrumentation/methods/javaagent/build.gradle.kts +++ b/instrumentation/methods/javaagent/build.gradle.kts @@ -15,7 +15,7 @@ dependencies { tasks.test { jvmArgs( - "-Dotel.instrumentation.methods.include=io.opentelemetry.javaagent.instrumentation.methods.MethodTest\$ConfigTracedCallable[call];io.opentelemetry.javaagent.instrumentation.methods.MethodTest\$ConfigTracedCompletableFuture[getResult];javax.naming.directory.InitialDirContext[search]" + "-Dotel.instrumentation.methods.include=io.opentelemetry.javaagent.instrumentation.methods.MethodTest\$ConfigTracedCallable[call];io.opentelemetry.javaagent.instrumentation.methods.MethodTest\$ConfigTracedCompletableFuture[getResult];javax.naming.directory.InitialDirContext[search]", ) } @@ -26,7 +26,7 @@ testing { all { testTask.configure { jvmArgs( - "-Dotel.config.file=$projectDir/src/declarativeConfigTest/resources/declarative-config.yaml" + "-Dotel.config.file=$projectDir/src/declarativeConfigTest/resources/declarative-config.yaml", ) } } diff --git a/instrumentation/micrometer/micrometer-1.5/javaagent/build.gradle.kts b/instrumentation/micrometer/micrometer-1.5/javaagent/build.gradle.kts index 1ce775c6700d..b7fe6a02837c 100644 --- a/instrumentation/micrometer/micrometer-1.5/javaagent/build.gradle.kts +++ b/instrumentation/micrometer/micrometer-1.5/javaagent/build.gradle.kts @@ -21,7 +21,10 @@ dependencies { tasks { val testPrometheusMode by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { includeTestsMatching("*PrometheusModeTest") @@ -31,7 +34,10 @@ tasks { } val testBaseTimeUnit by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { includeTestsMatching("*TimerMillisecondsTest") @@ -41,7 +47,10 @@ tasks { } val testHistogramGauges by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { includeTestsMatching("*HistogramGaugesTest") diff --git a/instrumentation/mongo/mongo-3.1/javaagent/build.gradle.kts b/instrumentation/mongo/mongo-3.1/javaagent/build.gradle.kts index 50d6e0869d30..8f657d42701d 100644 --- a/instrumentation/mongo/mongo-3.1/javaagent/build.gradle.kts +++ b/instrumentation/mongo/mongo-3.1/javaagent/build.gradle.kts @@ -30,7 +30,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database") diff --git a/instrumentation/mongo/mongo-3.1/library/build.gradle.kts b/instrumentation/mongo/mongo-3.1/library/build.gradle.kts index dae94556bc6c..2e422d9005d8 100644 --- a/instrumentation/mongo/mongo-3.1/library/build.gradle.kts +++ b/instrumentation/mongo/mongo-3.1/library/build.gradle.kts @@ -18,7 +18,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") } diff --git a/instrumentation/mongo/mongo-3.7/javaagent/build.gradle.kts b/instrumentation/mongo/mongo-3.7/javaagent/build.gradle.kts index 9c268ebc7275..3cf015c5c055 100644 --- a/instrumentation/mongo/mongo-3.7/javaagent/build.gradle.kts +++ b/instrumentation/mongo/mongo-3.7/javaagent/build.gradle.kts @@ -40,7 +40,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database") diff --git a/instrumentation/mongo/mongo-4.0/javaagent/build.gradle.kts b/instrumentation/mongo/mongo-4.0/javaagent/build.gradle.kts index 41ab7980d1e1..047c052e260d 100644 --- a/instrumentation/mongo/mongo-4.0/javaagent/build.gradle.kts +++ b/instrumentation/mongo/mongo-4.0/javaagent/build.gradle.kts @@ -36,7 +36,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database") diff --git a/instrumentation/mongo/mongo-async-3.3/javaagent/build.gradle.kts b/instrumentation/mongo/mongo-async-3.3/javaagent/build.gradle.kts index 2c6a7325d737..db2bdad9dcae 100644 --- a/instrumentation/mongo/mongo-async-3.3/javaagent/build.gradle.kts +++ b/instrumentation/mongo/mongo-async-3.3/javaagent/build.gradle.kts @@ -31,7 +31,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database") diff --git a/instrumentation/nats/nats-2.17/javaagent/build.gradle.kts b/instrumentation/nats/nats-2.17/javaagent/build.gradle.kts index f3ee460bd60e..477ca9d9c5a4 100644 --- a/instrumentation/nats/nats-2.17/javaagent/build.gradle.kts +++ b/instrumentation/nats/nats-2.17/javaagent/build.gradle.kts @@ -26,7 +26,10 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { includeTestsMatching("NatsExperimentalTest") diff --git a/instrumentation/netty/netty-3.8/javaagent/build.gradle.kts b/instrumentation/netty/netty-3.8/javaagent/build.gradle.kts index 6e5649d89c0a..26f40c592e32 100644 --- a/instrumentation/netty/netty-3.8/javaagent/build.gradle.kts +++ b/instrumentation/netty/netty-3.8/javaagent/build.gradle.kts @@ -57,7 +57,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/netty/netty-4.0/javaagent/build.gradle.kts b/instrumentation/netty/netty-4.0/javaagent/build.gradle.kts index ad7f02a720cf..2840fa801b9e 100644 --- a/instrumentation/netty/netty-4.0/javaagent/build.gradle.kts +++ b/instrumentation/netty/netty-4.0/javaagent/build.gradle.kts @@ -37,7 +37,10 @@ dependencies { tasks { val testConnectionSpan by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { includeTestsMatching("Netty40ConnectionSpanTest") @@ -58,7 +61,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/netty/netty-4.1/javaagent/build.gradle.kts b/instrumentation/netty/netty-4.1/javaagent/build.gradle.kts index bf577b2a05d7..9628a9761e88 100644 --- a/instrumentation/netty/netty-4.1/javaagent/build.gradle.kts +++ b/instrumentation/netty/netty-4.1/javaagent/build.gradle.kts @@ -49,7 +49,10 @@ tasks { } val testConnectionSpan by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { includeTestsMatching("Netty41ConnectionSpanTest") @@ -68,7 +71,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") @@ -92,7 +98,8 @@ if (!otelProps.testLatestDeps) { if (requested.group == "io.netty" && requested.name != "netty-bom" && !requested.name.startsWith("netty-transport-native") && - !requested.name.startsWith("netty-transport-classes")) { + !requested.name.startsWith("netty-transport-classes") + ) { useVersion("4.1.0.Final") } } diff --git a/instrumentation/netty/netty-4.1/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/netty/v4_1/Netty41ClientPipelineTest.java b/instrumentation/netty/netty-4.1/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/netty/v4_1/Netty41ClientPipelineTest.java index e6697c1f9151..c736f74ebdcc 100644 --- a/instrumentation/netty/netty-4.1/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/netty/v4_1/Netty41ClientPipelineTest.java +++ b/instrumentation/netty/netty-4.1/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/netty/v4_1/Netty41ClientPipelineTest.java @@ -185,7 +185,8 @@ void testCallAddLast() { @Test @DisplayName( - "when a traced handler is added from an initializer we still detect it and add our channel handlers") + "when a traced handler is added from an initializer we still detect it and add our channel" + + " handlers") void testAddInitializer() { // This test method replicates a scenario similar to how reactor 0.8.x register the // `HttpClientCodec` handler into the pipeline. diff --git a/instrumentation/netty/netty-4.1/library/build.gradle.kts b/instrumentation/netty/netty-4.1/library/build.gradle.kts index f6a8a69324cc..affc0a5e8507 100644 --- a/instrumentation/netty/netty-4.1/library/build.gradle.kts +++ b/instrumentation/netty/netty-4.1/library/build.gradle.kts @@ -15,7 +15,10 @@ dependencies { tasks { val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") } diff --git a/instrumentation/okhttp/okhttp-2.2/javaagent/build.gradle.kts b/instrumentation/okhttp/okhttp-2.2/javaagent/build.gradle.kts index 1c12f2ac4f3b..e517040dd94c 100644 --- a/instrumentation/okhttp/okhttp-2.2/javaagent/build.gradle.kts +++ b/instrumentation/okhttp/okhttp-2.2/javaagent/build.gradle.kts @@ -31,7 +31,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/okhttp/okhttp-3.0/javaagent/build.gradle.kts b/instrumentation/okhttp/okhttp-3.0/javaagent/build.gradle.kts index 603f407e0114..5dfb04ff5d59 100644 --- a/instrumentation/okhttp/okhttp-3.0/javaagent/build.gradle.kts +++ b/instrumentation/okhttp/okhttp-3.0/javaagent/build.gradle.kts @@ -49,7 +49,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/okhttp/okhttp-3.0/library/build.gradle.kts b/instrumentation/okhttp/okhttp-3.0/library/build.gradle.kts index c858a1ffc7eb..32fa0ea2bb6c 100644 --- a/instrumentation/okhttp/okhttp-3.0/library/build.gradle.kts +++ b/instrumentation/okhttp/okhttp-3.0/library/build.gradle.kts @@ -35,7 +35,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") } diff --git a/instrumentation/openai/openai-java-1.1/testing/src/main/java/io/opentelemetry/instrumentation/openai/v1_1/AbstractChatTest.java b/instrumentation/openai/openai-java-1.1/testing/src/main/java/io/opentelemetry/instrumentation/openai/v1_1/AbstractChatTest.java index 3ca0a33de2e8..79b6425ac932 100644 --- a/instrumentation/openai/openai-java-1.1/testing/src/main/java/io/opentelemetry/instrumentation/openai/v1_1/AbstractChatTest.java +++ b/instrumentation/openai/openai-java-1.1/testing/src/main/java/io/opentelemetry/instrumentation/openai/v1_1/AbstractChatTest.java @@ -289,7 +289,8 @@ void testDeveloperMessage() { KeyValue.of( "content", Value.of( - "You are an assistant which just answers every query with tomato")))), + "You are an assistant which just answers every query with" + + " tomato")))), log -> log.hasAttributesSatisfyingExactly( equalTo(GEN_AI_PROVIDER_NAME, OPENAI), @@ -679,7 +680,8 @@ void toolCalls() { KeyValue.of( "arguments", Value.of( - "{\"location\": \"New York City\"}")))), + "{\"location\": \"New York" + + " City\"}")))), KeyValue.of("id", Value.of(newYorkCallId)), KeyValue.of("type", Value.of("function"))), Value.of( @@ -1404,7 +1406,8 @@ void streamToolCalls() { KeyValue.of( "arguments", Value.of( - "{\"location\": \"New York City\"}")))), + "{\"location\": \"New York" + + " City\"}")))), KeyValue.of("id", Value.of(newYorkCallId)), KeyValue.of("type", Value.of("function"))), Value.of( diff --git a/instrumentation/opensearch/opensearch-java-3.0/javaagent/build.gradle.kts b/instrumentation/opensearch/opensearch-java-3.0/javaagent/build.gradle.kts index bac585c26f0c..32a5cf2ad712 100644 --- a/instrumentation/opensearch/opensearch-java-3.0/javaagent/build.gradle.kts +++ b/instrumentation/opensearch/opensearch-java-3.0/javaagent/build.gradle.kts @@ -47,7 +47,10 @@ tasks { } val testDisabledCaptureSearchQuery by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { @@ -61,7 +64,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { diff --git a/instrumentation/opensearch/opensearch-java-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opensearch/v3_0/AbstractOpenSearchQueryTest.java b/instrumentation/opensearch/opensearch-java-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opensearch/v3_0/AbstractOpenSearchQueryTest.java index e2350b0a342e..bc913f4555c1 100644 --- a/instrumentation/opensearch/opensearch-java-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opensearch/v3_0/AbstractOpenSearchQueryTest.java +++ b/instrumentation/opensearch/opensearch-java-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opensearch/v3_0/AbstractOpenSearchQueryTest.java @@ -55,7 +55,8 @@ void setUp() throws Exception { .withSecurityEnabled(); opensearch.withEnv( "OPENSEARCH_JAVA_OPTS", - "-Xmx256m -Xms256m -Dlog4j2.disableJmx=true -Dlog4j2.disable.jmx=true -XX:-UseContainerSupport"); + "-Xmx256m -Xms256m -Dlog4j2.disableJmx=true -Dlog4j2.disable.jmx=true" + + " -XX:-UseContainerSupport"); opensearch.start(); httpHost = URI.create(opensearch.getHttpHostAddress()); openSearchClient = buildOpenSearchClient(); diff --git a/instrumentation/opensearch/opensearch-java-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opensearch/v3_0/AbstractOpenSearchTest.java b/instrumentation/opensearch/opensearch-java-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opensearch/v3_0/AbstractOpenSearchTest.java index ed7966a3c58d..9e2c10bfaf4c 100644 --- a/instrumentation/opensearch/opensearch-java-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opensearch/v3_0/AbstractOpenSearchTest.java +++ b/instrumentation/opensearch/opensearch-java-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opensearch/v3_0/AbstractOpenSearchTest.java @@ -69,7 +69,8 @@ void setUp() throws Exception { // limit memory usage and disable Log4j JMX to avoid cgroup detection issues in containers opensearch.withEnv( "OPENSEARCH_JAVA_OPTS", - "-Xmx256m -Xms256m -Dlog4j2.disableJmx=true -Dlog4j2.disable.jmx=true -XX:-UseContainerSupport"); + "-Xmx256m -Xms256m -Dlog4j2.disableJmx=true -Dlog4j2.disable.jmx=true" + + " -XX:-UseContainerSupport"); opensearch.start(); httpHost = URI.create(opensearch.getHttpHostAddress()); openSearchClient = buildOpenSearchClient(); diff --git a/instrumentation/opensearch/opensearch-rest-1.0/javaagent/build.gradle.kts b/instrumentation/opensearch/opensearch-rest-1.0/javaagent/build.gradle.kts index 6bac710bfcef..fa0cbc338b22 100644 --- a/instrumentation/opensearch/opensearch-rest-1.0/javaagent/build.gradle.kts +++ b/instrumentation/opensearch/opensearch-rest-1.0/javaagent/build.gradle.kts @@ -46,7 +46,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database") diff --git a/instrumentation/opensearch/opensearch-rest-3.0/javaagent/build.gradle.kts b/instrumentation/opensearch/opensearch-rest-3.0/javaagent/build.gradle.kts index 696fc1714563..81a120f9dc76 100644 --- a/instrumentation/opensearch/opensearch-rest-3.0/javaagent/build.gradle.kts +++ b/instrumentation/opensearch/opensearch-rest-3.0/javaagent/build.gradle.kts @@ -39,7 +39,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database") diff --git a/instrumentation/opensearch/opensearch-rest-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/opensearch/rest/AbstractOpenSearchRestTest.java b/instrumentation/opensearch/opensearch-rest-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/opensearch/rest/AbstractOpenSearchRestTest.java index b9aaa60dc468..632370ab6b15 100644 --- a/instrumentation/opensearch/opensearch-rest-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/opensearch/rest/AbstractOpenSearchRestTest.java +++ b/instrumentation/opensearch/opensearch-rest-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/opensearch/rest/AbstractOpenSearchRestTest.java @@ -68,7 +68,8 @@ void setUp() throws Exception { // limit memory usage and disable Log4j JMX to avoid cgroup detection issues in containers opensearch.withEnv( "OPENSEARCH_JAVA_OPTS", - "-Xmx256m -Xms256m -Dlog4j2.disableJmx=true -Dlog4j2.disable.jmx=true -XX:-UseContainerSupport"); + "-Xmx256m -Xms256m -Dlog4j2.disableJmx=true -Dlog4j2.disable.jmx=true" + + " -XX:-UseContainerSupport"); opensearch.start(); httpHost = URI.create(opensearch.getHttpHostAddress()); diff --git a/instrumentation/opentelemetry-api/opentelemetry-api-1.31/javaagent/build.gradle.kts b/instrumentation/opentelemetry-api/opentelemetry-api-1.31/javaagent/build.gradle.kts index 018ca495154c..34eb01bc4542 100644 --- a/instrumentation/opentelemetry-api/opentelemetry-api-1.31/javaagent/build.gradle.kts +++ b/instrumentation/opentelemetry-api/opentelemetry-api-1.31/javaagent/build.gradle.kts @@ -14,7 +14,9 @@ dependencies { } configurations.configureEach { - if (name == "testRuntimeClasspath" || name == "testCompileClasspath" || name.startsWith("noopTest")) { + if (name == "testRuntimeClasspath" || name == "testCompileClasspath" || + name.startsWith("noopTest") + ) { resolutionStrategy { force("io.opentelemetry:opentelemetry-api:1.31.0") } diff --git a/instrumentation/opentelemetry-api/opentelemetry-api-1.32/javaagent/build.gradle.kts b/instrumentation/opentelemetry-api/opentelemetry-api-1.32/javaagent/build.gradle.kts index b963892bb475..e3e71f4aa867 100644 --- a/instrumentation/opentelemetry-api/opentelemetry-api-1.32/javaagent/build.gradle.kts +++ b/instrumentation/opentelemetry-api/opentelemetry-api-1.32/javaagent/build.gradle.kts @@ -15,12 +15,15 @@ dependencies { configurations.configureEach { if (name.endsWith("testRuntimeClasspath", true) || name.endsWith("testCompileClasspath", true) || - name.startsWith("noopTest")) { + name.startsWith("noopTest") + ) { resolutionStrategy { force("io.opentelemetry:opentelemetry-api:1.32.0") } } - if (name == "testRuntimeClasspath" || name == "incubatorTestRuntimeClasspath" || name == "noopTestRuntimeClasspath") { + if (name == "testRuntimeClasspath" || name == "incubatorTestRuntimeClasspath" || + name == "noopTestRuntimeClasspath" + ) { exclude(group = "io.opentelemetry", module = "opentelemetry-api-incubator") } } diff --git a/instrumentation/opentelemetry-api/opentelemetry-api-1.52/testing/build.gradle.kts b/instrumentation/opentelemetry-api/opentelemetry-api-1.52/testing/build.gradle.kts index 7c76bc2bb04e..8f47f8d7cf47 100644 --- a/instrumentation/opentelemetry-api/opentelemetry-api-1.52/testing/build.gradle.kts +++ b/instrumentation/opentelemetry-api/opentelemetry-api-1.52/testing/build.gradle.kts @@ -3,7 +3,9 @@ plugins { } dependencies { - testInstrumentation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.50:javaagent")) + testInstrumentation( + project(":instrumentation:opentelemetry-api:opentelemetry-api-1.50:javaagent"), + ) testImplementation("io.opentelemetry:opentelemetry-api-incubator") } diff --git a/instrumentation/opentelemetry-api/opentelemetry-api-1.56/javaagent/build.gradle.kts b/instrumentation/opentelemetry-api/opentelemetry-api-1.56/javaagent/build.gradle.kts index 87cd108ed37f..0be65475d138 100644 --- a/instrumentation/opentelemetry-api/opentelemetry-api-1.56/javaagent/build.gradle.kts +++ b/instrumentation/opentelemetry-api/opentelemetry-api-1.56/javaagent/build.gradle.kts @@ -27,6 +27,6 @@ configurations.configureEach { tasks.withType().configureEach { jvmArgs( - "-Dotel.config.file=$projectDir/src/test/resources/declarative-config.yaml" + "-Dotel.config.file=$projectDir/src/test/resources/declarative-config.yaml", ) } diff --git a/instrumentation/opentelemetry-api/opentelemetry-api-1.61/testing/build.gradle.kts b/instrumentation/opentelemetry-api/opentelemetry-api-1.61/testing/build.gradle.kts index 470a744ef722..3b00e1acb39f 100644 --- a/instrumentation/opentelemetry-api/opentelemetry-api-1.61/testing/build.gradle.kts +++ b/instrumentation/opentelemetry-api/opentelemetry-api-1.61/testing/build.gradle.kts @@ -3,7 +3,9 @@ plugins { } dependencies { - testInstrumentation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.27:javaagent")) + testInstrumentation( + project(":instrumentation:opentelemetry-api:opentelemetry-api-1.27:javaagent"), + ) } configurations.configureEach { diff --git a/instrumentation/opentelemetry-extension-annotations-1.0/javaagent/build.gradle.kts b/instrumentation/opentelemetry-extension-annotations-1.0/javaagent/build.gradle.kts index f523d89ae2c0..0c8d63988206 100644 --- a/instrumentation/opentelemetry-extension-annotations-1.0/javaagent/build.gradle.kts +++ b/instrumentation/opentelemetry-extension-annotations-1.0/javaagent/build.gradle.kts @@ -20,7 +20,9 @@ dependencies { // the @WithSpan annotation references the OpenTelemetry API's SpanKind class // // see the comment in opentelemetry-api-1.0.gradle for more details - compileOnly(project(":opentelemetry-ext-annotations-shaded-for-instrumenting", configuration = "shadow")) + compileOnly( + project(":opentelemetry-ext-annotations-shaded-for-instrumenting", configuration = "shadow"), + ) // Used by byte-buddy but not brought in as a transitive dependency. compileOnly("com.google.code.findbugs:annotations") @@ -36,14 +38,19 @@ tasks { options.compilerArgs.add("-parameters") } test { - jvmArgs("-Dotel.instrumentation.opentelemetry-annotations.exclude-methods=io.opentelemetry.test.annotation.TracedWithSpan[ignored]") + jvmArgs( + "-Dotel.instrumentation.opentelemetry-annotations.exclude-methods=io.opentelemetry.test.annotation.TracedWithSpan[ignored]", + ) } val testDeclarativeConfig by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs( - "-Dotel.config.file=$projectDir/src/test/resources/declarative-config.yaml" + "-Dotel.config.file=$projectDir/src/test/resources/declarative-config.yaml", ) } diff --git a/instrumentation/opentelemetry-extension-kotlin-1.0/javaagent/build.gradle.kts b/instrumentation/opentelemetry-extension-kotlin-1.0/javaagent/build.gradle.kts index bc8c1b8218c7..dbeab85f15be 100644 --- a/instrumentation/opentelemetry-extension-kotlin-1.0/javaagent/build.gradle.kts +++ b/instrumentation/opentelemetry-extension-kotlin-1.0/javaagent/build.gradle.kts @@ -34,7 +34,9 @@ if (!otelProps.testLatestDeps) { if (!name.contains("muzzle")) { resolutionStrategy { eachDependency { - if (requested.group == "io.opentelemetry" && requested.name == "opentelemetry-extension-kotlin") { + if (requested.group == "io.opentelemetry" && + requested.name == "opentelemetry-extension-kotlin" + ) { useVersion("1.0.0") } } diff --git a/instrumentation/opentelemetry-instrumentation-annotations-1.16/javaagent/build.gradle.kts b/instrumentation/opentelemetry-instrumentation-annotations-1.16/javaagent/build.gradle.kts index b7d15fca017a..30bb1e2a9ade 100644 --- a/instrumentation/opentelemetry-instrumentation-annotations-1.16/javaagent/build.gradle.kts +++ b/instrumentation/opentelemetry-instrumentation-annotations-1.16/javaagent/build.gradle.kts @@ -23,7 +23,12 @@ dependencies { // the @WithSpan annotation references the OpenTelemetry API's SpanKind class // // see the comment in opentelemetry-api-1.0.gradle for more details - compileOnly(project(":opentelemetry-instrumentation-annotations-shaded-for-instrumenting", configuration = "shadow")) + compileOnly( + project( + ":opentelemetry-instrumentation-annotations-shaded-for-instrumenting", + configuration = "shadow", + ), + ) // Used by byte-buddy but not brought in as a transitive dependency. compileOnly("com.google.code.findbugs:annotations") @@ -39,14 +44,19 @@ tasks { options.compilerArgs.add("-parameters") } test { - jvmArgs("-Dotel.instrumentation.opentelemetry-instrumentation-annotations.exclude-methods=io.opentelemetry.test.annotation.TracedWithSpan[ignored]") + jvmArgs( + "-Dotel.instrumentation.opentelemetry-instrumentation-annotations.exclude-methods=io.opentelemetry.test.annotation.TracedWithSpan[ignored]", + ) } val testDeclarativeConfig by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs( - "-Dotel.config.file=$projectDir/src/test/resources/declarative-config.yaml" + "-Dotel.config.file=$projectDir/src/test/resources/declarative-config.yaml", ) } diff --git a/instrumentation/opentelemetry-instrumentation-api/javaagent/build.gradle.kts b/instrumentation/opentelemetry-instrumentation-api/javaagent/build.gradle.kts index 7e2f7a7bd899..0211aa2dbff9 100644 --- a/instrumentation/opentelemetry-instrumentation-api/javaagent/build.gradle.kts +++ b/instrumentation/opentelemetry-instrumentation-api/javaagent/build.gradle.kts @@ -22,7 +22,12 @@ dependencies { implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.0:javaagent")) compileOnly(project(":opentelemetry-api-shaded-for-instrumenting", configuration = "shadow")) - compileOnly(project(":opentelemetry-instrumentation-api-shaded-for-instrumenting", configuration = "shadow")) + compileOnly( + project( + ":opentelemetry-instrumentation-api-shaded-for-instrumenting", + configuration = "shadow", + ), + ) testImplementation(project(":instrumentation-api-incubator")) testImplementation(project(":instrumentation:opentelemetry-instrumentation-api:testing")) @@ -36,7 +41,9 @@ testing { suites { val testOldServerSpan by registering(JvmTestSuite::class) { dependencies { - implementation("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api-semconv:$oldServerSpanVersion") + implementation( + "io.opentelemetry.instrumentation:opentelemetry-instrumentation-api-semconv:$oldServerSpanVersion", + ) implementation("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api") implementation(project(":instrumentation:opentelemetry-instrumentation-api:testing")) } @@ -47,7 +54,11 @@ testing { configurations.configureEach { if (name.startsWith("muzzle-Assert")) { // some names also start with "muzzle-AssertFail", which is conveniently the same length - val ver = name.substring("muzzle-AssertPass-io.opentelemetry.instrumentation-opentelemetry-instrumentation-api-".length) + val ver = + name.substring( + "muzzle-AssertPass-io.opentelemetry.instrumentation-opentelemetry-instrumentation-api-" + .length, + ) resolutionStrategy { dependencySubstitution { substitute(module("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api")) @@ -59,7 +70,11 @@ configurations.configureEach { resolutionStrategy { dependencySubstitution { substitute(module("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api")) - .using(module("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api:$oldServerSpanVersion")) + .using( + module( + "io.opentelemetry.instrumentation:opentelemetry-instrumentation-api:$oldServerSpanVersion", + ), + ) } } } @@ -68,13 +83,19 @@ configurations.configureEach { tasks { val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=code") } val testBothSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=code/dup") } diff --git a/instrumentation/oracle-ucp-11.2/javaagent/build.gradle.kts b/instrumentation/oracle-ucp-11.2/javaagent/build.gradle.kts index 05c2627f66b9..330c74168f57 100644 --- a/instrumentation/oracle-ucp-11.2/javaagent/build.gradle.kts +++ b/instrumentation/oracle-ucp-11.2/javaagent/build.gradle.kts @@ -27,7 +27,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database") diff --git a/instrumentation/oracle-ucp-11.2/library/build.gradle.kts b/instrumentation/oracle-ucp-11.2/library/build.gradle.kts index b9b7335a0df3..293ccd3e01a4 100644 --- a/instrumentation/oracle-ucp-11.2/library/build.gradle.kts +++ b/instrumentation/oracle-ucp-11.2/library/build.gradle.kts @@ -16,7 +16,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") } diff --git a/instrumentation/oshi/javaagent/build.gradle.kts b/instrumentation/oshi/javaagent/build.gradle.kts index 709fd0c86b3b..e06ecd1872bb 100644 --- a/instrumentation/oshi/javaagent/build.gradle.kts +++ b/instrumentation/oshi/javaagent/build.gradle.kts @@ -29,7 +29,10 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.oshi.experimental-metrics.enabled=true") systemProperty("testExperimental", "true") diff --git a/instrumentation/oshi/library/build.gradle.kts b/instrumentation/oshi/library/build.gradle.kts index 67b615e0000f..f23c29b697b9 100644 --- a/instrumentation/oshi/library/build.gradle.kts +++ b/instrumentation/oshi/library/build.gradle.kts @@ -11,5 +11,7 @@ dependencies { if (osdetector.os == "osx" && osdetector.arch == "aarch_64" && !otelProps.testLatestDeps) { // 5.5.0 is the first version that works on arm mac - configurations.testRuntimeClasspath.get().resolutionStrategy.force("com.github.oshi:oshi-core:5.5.0") + configurations.testRuntimeClasspath.get().resolutionStrategy.force( + "com.github.oshi:oshi-core:5.5.0", + ) } diff --git a/instrumentation/play/play-mvc/play-mvc-2.4/javaagent/build.gradle.kts b/instrumentation/play/play-mvc/play-mvc-2.4/javaagent/build.gradle.kts index 4f1217c24889..6bbfc6435c67 100644 --- a/instrumentation/play/play-mvc/play-mvc-2.4/javaagent/build.gradle.kts +++ b/instrumentation/play/play-mvc/play-mvc-2.4/javaagent/build.gradle.kts @@ -67,7 +67,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") @@ -90,7 +93,9 @@ if (!otelProps.testLatestDeps) { resolutionStrategy { eachDependency { // specifying a fixed version for all libraries with io.netty' group - if (requested.group == "io.netty" && requested.name != "netty-bom" && requested.name != "netty") { + if (requested.group == "io.netty" && requested.name != "netty-bom" && + requested.name != "netty" + ) { useVersion("4.0.34.Final") } } diff --git a/instrumentation/powerjob-4.0/javaagent/build.gradle.kts b/instrumentation/powerjob-4.0/javaagent/build.gradle.kts index 7645a4be96b0..0511a6838ca3 100644 --- a/instrumentation/powerjob-4.0/javaagent/build.gradle.kts +++ b/instrumentation/powerjob-4.0/javaagent/build.gradle.kts @@ -26,11 +26,17 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.powerjob.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.powerjob.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.powerjob.experimental-span-attributes=true", + ) } check { diff --git a/instrumentation/pulsar/pulsar-2.8/javaagent/build.gradle.kts b/instrumentation/pulsar/pulsar-2.8/javaagent/build.gradle.kts index 0ab1a505595a..8dc59a19fd2e 100644 --- a/instrumentation/pulsar/pulsar-2.8/javaagent/build.gradle.kts +++ b/instrumentation/pulsar/pulsar-2.8/javaagent/build.gradle.kts @@ -26,7 +26,10 @@ tasks { } val testReceiveSpanDisabled by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { includeTestsMatching("PulsarClientSuppressReceiveSpansTest") @@ -35,7 +38,10 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { @@ -44,7 +50,10 @@ tasks { jvmArgs("-Dotel.instrumentation.messaging.experimental.receive-telemetry.enabled=true") jvmArgs("-Dotel.instrumentation.pulsar.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.pulsar.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.pulsar.experimental-span-attributes=true", + ) } test { diff --git a/instrumentation/quarkus-resteasy-reactive/quarkus-2.0-plugin/src/main/java/io/opentelemetry/instrumentation/quarkus/v2_0/plugin/Quarkus2Plugin.java b/instrumentation/quarkus-resteasy-reactive/quarkus-2.0-plugin/src/main/java/io/opentelemetry/instrumentation/quarkus/v2_0/plugin/Quarkus2Plugin.java index f43f1a4205bc..38a56458200b 100644 --- a/instrumentation/quarkus-resteasy-reactive/quarkus-2.0-plugin/src/main/java/io/opentelemetry/instrumentation/quarkus/v2_0/plugin/Quarkus2Plugin.java +++ b/instrumentation/quarkus-resteasy-reactive/quarkus-2.0-plugin/src/main/java/io/opentelemetry/instrumentation/quarkus/v2_0/plugin/Quarkus2Plugin.java @@ -17,4 +17,3 @@ public void apply(Project project) { throw new IllegalStateException("this plugin is not meant to be applied"); } } - diff --git a/instrumentation/quarkus-resteasy-reactive/quarkus-2.0-plugin/src/main/java/io/quarkus/gradle/tooling/dependency/DependencyUtils.java b/instrumentation/quarkus-resteasy-reactive/quarkus-2.0-plugin/src/main/java/io/quarkus/gradle/tooling/dependency/DependencyUtils.java index f129014cfce8..72d40c75b799 100644 --- a/instrumentation/quarkus-resteasy-reactive/quarkus-2.0-plugin/src/main/java/io/quarkus/gradle/tooling/dependency/DependencyUtils.java +++ b/instrumentation/quarkus-resteasy-reactive/quarkus-2.0-plugin/src/main/java/io/quarkus/gradle/tooling/dependency/DependencyUtils.java @@ -22,6 +22,12 @@ package io.quarkus.gradle.tooling.dependency; +import io.quarkus.bootstrap.BootstrapConstants; +import io.quarkus.bootstrap.util.BootstrapUtils; +import io.quarkus.fs.util.ZipUtils; +import io.quarkus.maven.dependency.ArtifactCoords; +import io.quarkus.maven.dependency.ArtifactKey; +import io.quarkus.maven.dependency.GACTV; import java.io.BufferedReader; import java.io.File; import java.io.IOException; @@ -33,7 +39,6 @@ import java.util.Collections; import java.util.List; import java.util.Properties; - import org.gradle.api.GradleException; import org.gradle.api.Project; import org.gradle.api.artifacts.Configuration; @@ -46,31 +51,25 @@ import org.gradle.api.capabilities.Capability; import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSetContainer; -import org.gradle.internal.composite.IncludedBuildInternal; - -import io.quarkus.bootstrap.BootstrapConstants; -import io.quarkus.bootstrap.util.BootstrapUtils; -import io.quarkus.fs.util.ZipUtils; -import io.quarkus.gradle.tooling.ToolingUtils; -import io.quarkus.maven.dependency.ArtifactCoords; -import io.quarkus.maven.dependency.ArtifactKey; -import io.quarkus.maven.dependency.GACTV; -// Based on https://github.com/quarkusio/quarkus/blob/2.16.7.Final/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/dependency/DependencyUtils.java +// Based on +// https://github.com/quarkusio/quarkus/blob/2.16.7.Final/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/dependency/DependencyUtils.java public class DependencyUtils { private static final String COPY_CONFIGURATION_NAME = "quarkusDependency"; private static final String TEST_FIXTURE_SUFFIX = "-test-fixtures"; public static Configuration duplicateConfiguration(Project project, Configuration toDuplicate) { - Configuration configurationCopy = project.getConfigurations().findByName(COPY_CONFIGURATION_NAME); + Configuration configurationCopy = + project.getConfigurations().findByName(COPY_CONFIGURATION_NAME); if (configurationCopy != null) { project.getConfigurations().remove(configurationCopy); } return duplicateConfiguration(project, COPY_CONFIGURATION_NAME, toDuplicate); } - public static Configuration duplicateConfiguration(Project project, String name, Configuration toDuplicate) { + public static Configuration duplicateConfiguration( + Project project, String name, Configuration toDuplicate) { final Configuration configurationCopy = project.getConfigurations().create(name); configurationCopy.getDependencies().addAll(toDuplicate.getAllDependencies()); configurationCopy.getDependencyConstraints().addAll(toDuplicate.getAllDependencyConstraints()); @@ -95,20 +94,27 @@ public static String asDependencyNotation(Dependency dependency) { } public static String asDependencyNotation(ArtifactCoords artifactCoords) { - return String.join(":", artifactCoords.getGroupId(), artifactCoords.getArtifactId(), artifactCoords.getVersion()); + return String.join( + ":", + artifactCoords.getGroupId(), + artifactCoords.getArtifactId(), + artifactCoords.getVersion()); } - public static ExtensionDependency getExtensionInfoOrNull(Project project, ResolvedArtifact artifact) { + public static ExtensionDependency getExtensionInfoOrNull( + Project project, ResolvedArtifact artifact) { ModuleVersionIdentifier artifactId = artifact.getModuleVersion().getId(); File artifactFile = artifact.getFile(); if (artifact.getId().getComponentIdentifier() instanceof ProjectComponentIdentifier) { - ProjectComponentIdentifier componentIdentifier = ((ProjectComponentIdentifier) artifact.getId() - .getComponentIdentifier()); - Project projectDep = project.getRootProject().findProject( - componentIdentifier.getProjectPath()); - SourceSetContainer sourceSets = projectDep == null ? null - : projectDep.getExtensions().findByType(SourceSetContainer.class); + ProjectComponentIdentifier componentIdentifier = + ((ProjectComponentIdentifier) artifact.getId().getComponentIdentifier()); + Project projectDep = + project.getRootProject().findProject(componentIdentifier.getProjectPath()); + SourceSetContainer sourceSets = + projectDep == null + ? null + : projectDep.getExtensions().findByType(SourceSetContainer.class); final String classifier = artifact.getClassifier(); boolean isIncludedBuild = false; // Upstream uses componentIdentifier.getBuild().isCurrentBuild() and ToolingUtils to resolve @@ -121,7 +127,8 @@ public static ExtensionDependency getExtensionInfoOrNull(Project project, Resolv File resourcesDir = mainSourceSet.getOutput().getResourcesDir(); Path descriptorPath = resourcesDir.toPath().resolve(BootstrapConstants.DESCRIPTOR_PATH); if (Files.exists(descriptorPath)) { - return loadExtensionInfo(project, descriptorPath, artifactId, projectDep, isIncludedBuild); + return loadExtensionInfo( + project, descriptorPath, artifactId, projectDep, isIncludedBuild); } } } @@ -147,20 +154,26 @@ public static ExtensionDependency getExtensionInfoOrNull(Project project, Resolv return null; } - private static ExtensionDependency loadExtensionInfo(Project project, Path descriptorPath, - ModuleVersionIdentifier exentionId, Project extensionProject, boolean isIncludedBuild) { + private static ExtensionDependency loadExtensionInfo( + Project project, + Path descriptorPath, + ModuleVersionIdentifier exentionId, + Project extensionProject, + boolean isIncludedBuild) { final Properties extensionProperties = new Properties(); try (BufferedReader reader = Files.newBufferedReader(descriptorPath)) { extensionProperties.load(reader); } catch (IOException e) { throw new GradleException("Failed to load " + descriptorPath, e); } - ArtifactCoords deploymentModule = GACTV - .fromString(extensionProperties.getProperty(BootstrapConstants.PROP_DEPLOYMENT_ARTIFACT)); + ArtifactCoords deploymentModule = + GACTV.fromString( + extensionProperties.getProperty(BootstrapConstants.PROP_DEPLOYMENT_ARTIFACT)); final List conditionalDependencies; if (extensionProperties.containsKey(BootstrapConstants.CONDITIONAL_DEPENDENCIES)) { - final String[] deps = BootstrapUtils - .splitByWhitespace(extensionProperties.getProperty(BootstrapConstants.CONDITIONAL_DEPENDENCIES)); + final String[] deps = + BootstrapUtils.splitByWhitespace( + extensionProperties.getProperty(BootstrapConstants.CONDITIONAL_DEPENDENCIES)); conditionalDependencies = new ArrayList<>(deps.length); for (String conditionalDep : deps) { conditionalDependencies.add(create(project.getDependencies(), conditionalDep)); @@ -169,36 +182,62 @@ private static ExtensionDependency loadExtensionInfo(Project project, Path descr conditionalDependencies = Collections.emptyList(); } - final ArtifactKey[] constraints = BootstrapUtils - .parseDependencyCondition(extensionProperties.getProperty(BootstrapConstants.DEPENDENCY_CONDITION)); + final ArtifactKey[] constraints = + BootstrapUtils.parseDependencyCondition( + extensionProperties.getProperty(BootstrapConstants.DEPENDENCY_CONDITION)); if (isIncludedBuild) { - return new IncludedBuildExtensionDependency(extensionProject, exentionId, deploymentModule, conditionalDependencies, + return new IncludedBuildExtensionDependency( + extensionProject, + exentionId, + deploymentModule, + conditionalDependencies, constraints == null ? Collections.emptyList() : Arrays.asList(constraints)); } if (extensionProject != null) { - return new LocalExtensionDependency(extensionProject, exentionId, deploymentModule, conditionalDependencies, + return new LocalExtensionDependency( + extensionProject, + exentionId, + deploymentModule, + conditionalDependencies, constraints == null ? Collections.emptyList() : Arrays.asList(constraints)); } - return new ExtensionDependency(exentionId, deploymentModule, conditionalDependencies, + return new ExtensionDependency( + exentionId, + deploymentModule, + conditionalDependencies, constraints == null ? Collections.emptyList() : Arrays.asList(constraints)); } public static Dependency create(DependencyHandler dependencies, String conditionalDependency) { final ArtifactCoords dependencyCoords = GACTV.fromString(conditionalDependency); - return dependencies.create(String.join(":", dependencyCoords.getGroupId(), dependencyCoords.getArtifactId(), - dependencyCoords.getVersion())); + return dependencies.create( + String.join( + ":", + dependencyCoords.getGroupId(), + dependencyCoords.getArtifactId(), + dependencyCoords.getVersion())); } - public static void addLocalDeploymentDependency(String deploymentConfigurationName, LocalExtensionDependency extension, + public static void addLocalDeploymentDependency( + String deploymentConfigurationName, + LocalExtensionDependency extension, DependencyHandler dependencies) { - dependencies.add(deploymentConfigurationName, - dependencies.project(Collections.singletonMap("path", extension.findDeploymentModulePath()))); + dependencies.add( + deploymentConfigurationName, + dependencies.project( + Collections.singletonMap("path", extension.findDeploymentModulePath()))); } - public static void requireDeploymentDependency(String deploymentConfigurationName, ExtensionDependency extension, + public static void requireDeploymentDependency( + String deploymentConfigurationName, + ExtensionDependency extension, DependencyHandler dependencies) { - dependencies.add(deploymentConfigurationName, - extension.getDeploymentModule().getGroupId() + ":" + extension.getDeploymentModule().getArtifactId() + ":" + dependencies.add( + deploymentConfigurationName, + extension.getDeploymentModule().getGroupId() + + ":" + + extension.getDeploymentModule().getArtifactId() + + ":" + extension.getDeploymentModule().getVersion()); } } diff --git a/instrumentation/quarkus-resteasy-reactive/quarkus-2.0-testing/build.gradle.kts b/instrumentation/quarkus-resteasy-reactive/quarkus-2.0-testing/build.gradle.kts index bf02b0cc5c0e..f68eaf593bb3 100644 --- a/instrumentation/quarkus-resteasy-reactive/quarkus-2.0-testing/build.gradle.kts +++ b/instrumentation/quarkus-resteasy-reactive/quarkus-2.0-testing/build.gradle.kts @@ -48,17 +48,24 @@ val quarkusTestCompileOnlyConfiguration by configurations.creating { val testModelPath = layout.buildDirectory.file("quarkus-app-test-model.dat") -val buildModel = if (findProperty("skipTests") as String? != "true") { - tasks.register("buildModel") { - projectRef = project - runtimeClasspath.from(configurations.named("testRuntimeClasspath")) - outputFile.set(testModelPath) - - onlyIf { outputFile.get().asFile.toPath().notExists() } +val buildModel = + if (findProperty("skipTests") as String? != "true") { + tasks.register("buildModel") { + projectRef = project + runtimeClasspath.from(configurations.named("testRuntimeClasspath")) + outputFile.set(testModelPath) + + onlyIf { + outputFile + .get() + .asFile + .toPath() + .notExists() + } + } + } else { + null } -} else { - null -} tasks { test { @@ -66,7 +73,10 @@ tasks { dependsOn(buildModel) } - systemProperty("quarkus-internal-test.serialized-app-model.path", testModelPath.get().asFile.toString()) + systemProperty( + "quarkus-internal-test.serialized-app-model.path", + testModelPath.get().asFile.toString(), + ) } if (otelProps.denyUnsafe) { @@ -77,7 +87,6 @@ tasks { } abstract class BuildModelTask : DefaultTask() { - @get:Internal @Transient var projectRef: Project? = null @@ -90,7 +99,7 @@ abstract class BuildModelTask : DefaultTask() { init { notCompatibleWithConfigurationCache( - "Quarkus GradleApplicationModelBuilder.buildAll() requires Project reference" + "Quarkus GradleApplicationModelBuilder.buildAll() requires Project reference", ) } @@ -99,11 +108,12 @@ abstract class BuildModelTask : DefaultTask() { val modelPath = outputFile.get().asFile.toPath() val modelParameter = ModelParameterImpl() modelParameter.mode = LaunchMode.TEST.toString() - val model = GradleApplicationModelBuilder().buildAll( - ApplicationModel::class.java.getName(), - modelParameter, - checkNotNull(projectRef) - ) + val model = + GradleApplicationModelBuilder().buildAll( + ApplicationModel::class.java.getName(), + modelParameter, + checkNotNull(projectRef), + ) BootstrapUtils.serializeAppModel(model as ApplicationModel?, modelPath) } } diff --git a/instrumentation/quarkus-resteasy-reactive/quarkus-3.0-plugin/src/main/java/io/opentelemetry/instrumentation/quarkus/v3_0/plugin/Quarkus3Plugin.java b/instrumentation/quarkus-resteasy-reactive/quarkus-3.0-plugin/src/main/java/io/opentelemetry/instrumentation/quarkus/v3_0/plugin/Quarkus3Plugin.java index ee93bd5a7ca5..9f30f85839ce 100644 --- a/instrumentation/quarkus-resteasy-reactive/quarkus-3.0-plugin/src/main/java/io/opentelemetry/instrumentation/quarkus/v3_0/plugin/Quarkus3Plugin.java +++ b/instrumentation/quarkus-resteasy-reactive/quarkus-3.0-plugin/src/main/java/io/opentelemetry/instrumentation/quarkus/v3_0/plugin/Quarkus3Plugin.java @@ -17,4 +17,3 @@ public void apply(Project project) { throw new IllegalStateException("this plugin is not meant to be applied"); } } - diff --git a/instrumentation/quarkus-resteasy-reactive/quarkus-3.0-plugin/src/main/java/io/quarkus/gradle/tooling/dependency/DependencyUtils.java b/instrumentation/quarkus-resteasy-reactive/quarkus-3.0-plugin/src/main/java/io/quarkus/gradle/tooling/dependency/DependencyUtils.java index 490bf730fab2..1e8baf904848 100644 --- a/instrumentation/quarkus-resteasy-reactive/quarkus-3.0-plugin/src/main/java/io/quarkus/gradle/tooling/dependency/DependencyUtils.java +++ b/instrumentation/quarkus-resteasy-reactive/quarkus-3.0-plugin/src/main/java/io/quarkus/gradle/tooling/dependency/DependencyUtils.java @@ -22,6 +22,12 @@ package io.quarkus.gradle.tooling.dependency; +import io.quarkus.bootstrap.BootstrapConstants; +import io.quarkus.bootstrap.util.BootstrapUtils; +import io.quarkus.fs.util.ZipUtils; +import io.quarkus.maven.dependency.ArtifactCoords; +import io.quarkus.maven.dependency.ArtifactKey; +import io.quarkus.maven.dependency.GACTV; import java.io.BufferedReader; import java.io.File; import java.io.IOException; @@ -33,7 +39,6 @@ import java.util.Collections; import java.util.List; import java.util.Properties; - import org.gradle.api.GradleException; import org.gradle.api.Project; import org.gradle.api.artifacts.Configuration; @@ -46,31 +51,25 @@ import org.gradle.api.capabilities.Capability; import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSetContainer; -import org.gradle.internal.composite.IncludedBuildInternal; - -import io.quarkus.bootstrap.BootstrapConstants; -import io.quarkus.bootstrap.util.BootstrapUtils; -import io.quarkus.fs.util.ZipUtils; -import io.quarkus.gradle.tooling.ToolingUtils; -import io.quarkus.maven.dependency.ArtifactCoords; -import io.quarkus.maven.dependency.ArtifactKey; -import io.quarkus.maven.dependency.GACTV; -// Based on https://github.com/quarkusio/quarkus/blob/3.0.0.Final/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/dependency/DependencyUtils.java +// Based on +// https://github.com/quarkusio/quarkus/blob/3.0.0.Final/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/dependency/DependencyUtils.java public class DependencyUtils { private static final String COPY_CONFIGURATION_NAME = "quarkusDependency"; private static final String TEST_FIXTURE_SUFFIX = "-test-fixtures"; public static Configuration duplicateConfiguration(Project project, Configuration toDuplicate) { - Configuration configurationCopy = project.getConfigurations().findByName(COPY_CONFIGURATION_NAME); + Configuration configurationCopy = + project.getConfigurations().findByName(COPY_CONFIGURATION_NAME); if (configurationCopy != null) { project.getConfigurations().remove(configurationCopy); } return duplicateConfiguration(project, COPY_CONFIGURATION_NAME, toDuplicate); } - public static Configuration duplicateConfiguration(Project project, String name, Configuration toDuplicate) { + public static Configuration duplicateConfiguration( + Project project, String name, Configuration toDuplicate) { final Configuration configurationCopy = project.getConfigurations().create(name); configurationCopy.getDependencies().addAll(toDuplicate.getAllDependencies()); configurationCopy.getDependencyConstraints().addAll(toDuplicate.getAllDependencyConstraints()); @@ -95,20 +94,27 @@ public static String asDependencyNotation(Dependency dependency) { } public static String asDependencyNotation(ArtifactCoords artifactCoords) { - return String.join(":", artifactCoords.getGroupId(), artifactCoords.getArtifactId(), artifactCoords.getVersion()); + return String.join( + ":", + artifactCoords.getGroupId(), + artifactCoords.getArtifactId(), + artifactCoords.getVersion()); } - public static ExtensionDependency getExtensionInfoOrNull(Project project, ResolvedArtifact artifact) { + public static ExtensionDependency getExtensionInfoOrNull( + Project project, ResolvedArtifact artifact) { ModuleVersionIdentifier artifactId = artifact.getModuleVersion().getId(); File artifactFile = artifact.getFile(); if (artifact.getId().getComponentIdentifier() instanceof ProjectComponentIdentifier) { - ProjectComponentIdentifier componentIdentifier = ((ProjectComponentIdentifier) artifact.getId() - .getComponentIdentifier()); - Project projectDep = project.getRootProject().findProject( - componentIdentifier.getProjectPath()); - SourceSetContainer sourceSets = projectDep == null ? null - : projectDep.getExtensions().findByType(SourceSetContainer.class); + ProjectComponentIdentifier componentIdentifier = + ((ProjectComponentIdentifier) artifact.getId().getComponentIdentifier()); + Project projectDep = + project.getRootProject().findProject(componentIdentifier.getProjectPath()); + SourceSetContainer sourceSets = + projectDep == null + ? null + : projectDep.getExtensions().findByType(SourceSetContainer.class); final String classifier = artifact.getClassifier(); boolean isIncludedBuild = false; // Upstream uses componentIdentifier.getBuild().isCurrentBuild() and ToolingUtils to resolve @@ -121,7 +127,8 @@ public static ExtensionDependency getExtensionInfoOrNull(Project project, Resolv File resourcesDir = mainSourceSet.getOutput().getResourcesDir(); Path descriptorPath = resourcesDir.toPath().resolve(BootstrapConstants.DESCRIPTOR_PATH); if (Files.exists(descriptorPath)) { - return loadExtensionInfo(project, descriptorPath, artifactId, projectDep, isIncludedBuild); + return loadExtensionInfo( + project, descriptorPath, artifactId, projectDep, isIncludedBuild); } } } @@ -147,20 +154,26 @@ public static ExtensionDependency getExtensionInfoOrNull(Project project, Resolv return null; } - private static ExtensionDependency loadExtensionInfo(Project project, Path descriptorPath, - ModuleVersionIdentifier exentionId, Project extensionProject, boolean isIncludedBuild) { + private static ExtensionDependency loadExtensionInfo( + Project project, + Path descriptorPath, + ModuleVersionIdentifier exentionId, + Project extensionProject, + boolean isIncludedBuild) { final Properties extensionProperties = new Properties(); try (BufferedReader reader = Files.newBufferedReader(descriptorPath)) { extensionProperties.load(reader); } catch (IOException e) { throw new GradleException("Failed to load " + descriptorPath, e); } - ArtifactCoords deploymentModule = GACTV - .fromString(extensionProperties.getProperty(BootstrapConstants.PROP_DEPLOYMENT_ARTIFACT)); + ArtifactCoords deploymentModule = + GACTV.fromString( + extensionProperties.getProperty(BootstrapConstants.PROP_DEPLOYMENT_ARTIFACT)); final List conditionalDependencies; if (extensionProperties.containsKey(BootstrapConstants.CONDITIONAL_DEPENDENCIES)) { - final String[] deps = BootstrapUtils - .splitByWhitespace(extensionProperties.getProperty(BootstrapConstants.CONDITIONAL_DEPENDENCIES)); + final String[] deps = + BootstrapUtils.splitByWhitespace( + extensionProperties.getProperty(BootstrapConstants.CONDITIONAL_DEPENDENCIES)); conditionalDependencies = new ArrayList<>(deps.length); for (String conditionalDep : deps) { conditionalDependencies.add(create(project.getDependencies(), conditionalDep)); @@ -169,36 +182,62 @@ private static ExtensionDependency loadExtensionInfo(Project project, Path descr conditionalDependencies = Collections.emptyList(); } - final ArtifactKey[] constraints = BootstrapUtils - .parseDependencyCondition(extensionProperties.getProperty(BootstrapConstants.DEPENDENCY_CONDITION)); + final ArtifactKey[] constraints = + BootstrapUtils.parseDependencyCondition( + extensionProperties.getProperty(BootstrapConstants.DEPENDENCY_CONDITION)); if (isIncludedBuild) { - return new IncludedBuildExtensionDependency(extensionProject, exentionId, deploymentModule, conditionalDependencies, + return new IncludedBuildExtensionDependency( + extensionProject, + exentionId, + deploymentModule, + conditionalDependencies, constraints == null ? Collections.emptyList() : Arrays.asList(constraints)); } if (extensionProject != null) { - return new LocalExtensionDependency(extensionProject, exentionId, deploymentModule, conditionalDependencies, + return new LocalExtensionDependency( + extensionProject, + exentionId, + deploymentModule, + conditionalDependencies, constraints == null ? Collections.emptyList() : Arrays.asList(constraints)); } - return new ExtensionDependency(exentionId, deploymentModule, conditionalDependencies, + return new ExtensionDependency( + exentionId, + deploymentModule, + conditionalDependencies, constraints == null ? Collections.emptyList() : Arrays.asList(constraints)); } public static Dependency create(DependencyHandler dependencies, String conditionalDependency) { final ArtifactCoords dependencyCoords = GACTV.fromString(conditionalDependency); - return dependencies.create(String.join(":", dependencyCoords.getGroupId(), dependencyCoords.getArtifactId(), - dependencyCoords.getVersion())); + return dependencies.create( + String.join( + ":", + dependencyCoords.getGroupId(), + dependencyCoords.getArtifactId(), + dependencyCoords.getVersion())); } - public static void addLocalDeploymentDependency(String deploymentConfigurationName, LocalExtensionDependency extension, + public static void addLocalDeploymentDependency( + String deploymentConfigurationName, + LocalExtensionDependency extension, DependencyHandler dependencies) { - dependencies.add(deploymentConfigurationName, - dependencies.project(Collections.singletonMap("path", extension.findDeploymentModulePath()))); + dependencies.add( + deploymentConfigurationName, + dependencies.project( + Collections.singletonMap("path", extension.findDeploymentModulePath()))); } - public static void requireDeploymentDependency(String deploymentConfigurationName, ExtensionDependency extension, + public static void requireDeploymentDependency( + String deploymentConfigurationName, + ExtensionDependency extension, DependencyHandler dependencies) { - dependencies.add(deploymentConfigurationName, - extension.getDeploymentModule().getGroupId() + ":" + extension.getDeploymentModule().getArtifactId() + ":" + dependencies.add( + deploymentConfigurationName, + extension.getDeploymentModule().getGroupId() + + ":" + + extension.getDeploymentModule().getArtifactId() + + ":" + extension.getDeploymentModule().getVersion()); } } diff --git a/instrumentation/quarkus-resteasy-reactive/quarkus-3.0-testing/build.gradle.kts b/instrumentation/quarkus-resteasy-reactive/quarkus-3.0-testing/build.gradle.kts index 6da8bd576e25..673b783bdb3b 100644 --- a/instrumentation/quarkus-resteasy-reactive/quarkus-3.0-testing/build.gradle.kts +++ b/instrumentation/quarkus-resteasy-reactive/quarkus-3.0-testing/build.gradle.kts @@ -54,17 +54,24 @@ val quarkusTestCompileOnlyConfiguration by configurations.creating { val testModelPath = layout.buildDirectory.file("quarkus-app-test-model.dat") -val buildModel = if (findProperty("skipTests") as String? != "true") { - tasks.register("buildModel") { - projectRef = project - runtimeClasspath.from(configurations.named("testRuntimeClasspath")) - outputFile.set(testModelPath) - - onlyIf { outputFile.get().asFile.toPath().notExists() } +val buildModel = + if (findProperty("skipTests") as String? != "true") { + tasks.register("buildModel") { + projectRef = project + runtimeClasspath.from(configurations.named("testRuntimeClasspath")) + outputFile.set(testModelPath) + + onlyIf { + outputFile + .get() + .asFile + .toPath() + .notExists() + } + } + } else { + null } -} else { - null -} tasks { test { @@ -72,7 +79,10 @@ tasks { dependsOn(buildModel) } - systemProperty("quarkus-internal-test.serialized-app-model.path", testModelPath.get().asFile.toString()) + systemProperty( + "quarkus-internal-test.serialized-app-model.path", + testModelPath.get().asFile.toString(), + ) } if (otelProps.denyUnsafe) { @@ -83,7 +93,6 @@ tasks { } abstract class BuildModelTask : DefaultTask() { - @get:Internal @Transient var projectRef: Project? = null @@ -96,7 +105,7 @@ abstract class BuildModelTask : DefaultTask() { init { notCompatibleWithConfigurationCache( - "Quarkus GradleApplicationModelBuilder.buildAll() requires Project reference" + "Quarkus GradleApplicationModelBuilder.buildAll() requires Project reference", ) } @@ -105,11 +114,12 @@ abstract class BuildModelTask : DefaultTask() { val modelPath = outputFile.get().asFile.toPath() val modelParameter = ModelParameterImpl() modelParameter.mode = LaunchMode.TEST.toString() - val model = GradleApplicationModelBuilder().buildAll( - ApplicationModel::class.java.getName(), - modelParameter, - checkNotNull(projectRef) - ) + val model = + GradleApplicationModelBuilder().buildAll( + ApplicationModel::class.java.getName(), + modelParameter, + checkNotNull(projectRef), + ) BootstrapUtils.serializeAppModel(model as ApplicationModel?, modelPath) } } diff --git a/instrumentation/quarkus-resteasy-reactive/quarkus-3.9-plugin/src/main/java/io/quarkus/gradle/dependency/ConditionalDependenciesEnabler.java b/instrumentation/quarkus-resteasy-reactive/quarkus-3.9-plugin/src/main/java/io/quarkus/gradle/dependency/ConditionalDependenciesEnabler.java index 131b8fd6a4b8..836206fee32c 100644 --- a/instrumentation/quarkus-resteasy-reactive/quarkus-3.9-plugin/src/main/java/io/quarkus/gradle/dependency/ConditionalDependenciesEnabler.java +++ b/instrumentation/quarkus-resteasy-reactive/quarkus-3.9-plugin/src/main/java/io/quarkus/gradle/dependency/ConditionalDependenciesEnabler.java @@ -22,6 +22,12 @@ package io.quarkus.gradle.dependency; +import io.quarkus.gradle.tooling.dependency.DependencyUtils; +import io.quarkus.gradle.tooling.dependency.ExtensionDependency; +import io.quarkus.maven.dependency.ArtifactCoords; +import io.quarkus.maven.dependency.ArtifactKey; +import io.quarkus.maven.dependency.GACT; +import io.quarkus.runtime.LaunchMode; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -29,37 +35,32 @@ import java.util.List; import java.util.Map; import java.util.Set; - import org.gradle.api.Project; import org.gradle.api.artifacts.Configuration; import org.gradle.api.artifacts.Dependency; import org.gradle.api.artifacts.ModuleVersionIdentifier; import org.gradle.api.artifacts.ResolvedArtifact; -import io.quarkus.gradle.tooling.dependency.DependencyUtils; -import io.quarkus.gradle.tooling.dependency.ExtensionDependency; -import io.quarkus.maven.dependency.ArtifactCoords; -import io.quarkus.maven.dependency.ArtifactKey; -import io.quarkus.maven.dependency.GACT; -import io.quarkus.runtime.LaunchMode; - -// Based on https://github.com/quarkusio/quarkus/blob/3.9.5/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/dependency/ConditionalDependenciesEnabler.java +// Based on +// https://github.com/quarkusio/quarkus/blob/3.9.5/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/dependency/ConditionalDependenciesEnabler.java public class ConditionalDependenciesEnabler { /** Links dependencies to extensions */ private final Map>> featureVariants = new HashMap<>(); + /** * Despite its name, only contains extensions which have no conditional dependencies, or have * resolved their conditional dependencies. */ - private final Map> allExtensions = new HashMap<>(); + private final Map> allExtensions = + new HashMap<>(); + private final Project project; private final Configuration enforcedPlatforms; private final Set existingArtifacts = new HashSet<>(); private final List unsatisfiedConditionalDeps = new ArrayList<>(); - public ConditionalDependenciesEnabler( - Project project, LaunchMode mode, Configuration platforms) { + public ConditionalDependenciesEnabler(Project project, LaunchMode mode, Configuration platforms) { this.project = project; this.enforcedPlatforms = platforms; @@ -116,8 +117,7 @@ private void collectConditionalDependencies(Set runtimeArtifac for (ResolvedArtifact artifact : runtimeArtifacts) { // Add to master list of artifacts: existingArtifacts.add(getKey(artifact)); - ExtensionDependency extension = - DependencyUtils.getExtensionInfoOrNull(project, artifact); + ExtensionDependency extension = DependencyUtils.getExtensionInfoOrNull(project, artifact); // If this artifact represents an extension: if (extension != null) { // Add to master list of accepted extensions: @@ -145,14 +145,8 @@ private boolean resolveConditionalDependency(Dependency conditionalDep) { // dependency for (ResolvedArtifact artifact : resolvedArtifacts) { if (conditionalDep.getName().equals(artifact.getName()) - && conditionalDep - .getVersion() - .equals(artifact.getModuleVersion().getId().getVersion()) - && artifact - .getModuleVersion() - .getId() - .getGroup() - .equals(conditionalDep.getGroup())) { + && conditionalDep.getVersion().equals(artifact.getModuleVersion().getId().getVersion()) + && artifact.getModuleVersion().getId().getGroup().equals(conditionalDep.getGroup())) { // Once the dependency is found, reload the extension info from within final ExtensionDependency extensionDependency = DependencyUtils.getExtensionInfoOrNull(project, artifact); @@ -214,8 +208,7 @@ private void queueConditionalDependency( // build, so we manually copy exclude rules and dependencies instead private Configuration createConditionalDependenciesConfiguration( Project project, Dependency conditionalDep) { - Configuration conditionalDepConfiguration = - project.getConfigurations().detachedConfiguration(); + Configuration conditionalDepConfiguration = project.getConfigurations().detachedConfiguration(); enforcedPlatforms .getExcludeRules() .forEach( @@ -236,8 +229,7 @@ private void enableConditionalDependency(ModuleVersionIdentifier dependency) { if (extensions == null) { return; } - extensions.forEach( - e -> e.importConditionalDependency(project.getDependencies(), dependency)); + extensions.forEach(e -> e.importConditionalDependency(project.getDependencies(), dependency)); } private boolean exist(List dependencies) { diff --git a/instrumentation/quarkus-resteasy-reactive/quarkus-3.9-plugin/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java b/instrumentation/quarkus-resteasy-reactive/quarkus-3.9-plugin/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java index 4bbf1bd4c250..ec793562bdcb 100644 --- a/instrumentation/quarkus-resteasy-reactive/quarkus-3.9-plugin/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java +++ b/instrumentation/quarkus-resteasy-reactive/quarkus-3.9-plugin/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java @@ -22,6 +22,33 @@ package io.quarkus.gradle.tooling; +import io.quarkus.bootstrap.BootstrapConstants; +import io.quarkus.bootstrap.model.ApplicationModel; +import io.quarkus.bootstrap.model.ApplicationModelBuilder; +import io.quarkus.bootstrap.model.CapabilityContract; +import io.quarkus.bootstrap.model.PlatformImports; +import io.quarkus.bootstrap.model.gradle.ModelParameter; +import io.quarkus.bootstrap.model.gradle.impl.ModelParameterImpl; +import io.quarkus.bootstrap.workspace.ArtifactSources; +import io.quarkus.bootstrap.workspace.DefaultArtifactSources; +import io.quarkus.bootstrap.workspace.DefaultSourceDir; +import io.quarkus.bootstrap.workspace.DefaultWorkspaceModule; +import io.quarkus.bootstrap.workspace.SourceDir; +import io.quarkus.bootstrap.workspace.WorkspaceModule; +import io.quarkus.fs.util.ZipUtils; +import io.quarkus.gradle.dependency.ApplicationDeploymentClasspathBuilder; +import io.quarkus.maven.dependency.ArtifactCoords; +import io.quarkus.maven.dependency.ArtifactDependency; +import io.quarkus.maven.dependency.ArtifactKey; +import io.quarkus.maven.dependency.DependencyFlags; +import io.quarkus.maven.dependency.GACT; +import io.quarkus.maven.dependency.GACTV; +import io.quarkus.maven.dependency.GAV; +import io.quarkus.maven.dependency.ResolvedDependency; +import io.quarkus.maven.dependency.ResolvedDependencyBuilder; +import io.quarkus.paths.PathCollection; +import io.quarkus.paths.PathList; +import io.quarkus.runtime.LaunchMode; import java.io.BufferedReader; import java.io.File; import java.io.IOException; @@ -42,7 +69,6 @@ import java.util.Objects; import java.util.Properties; import java.util.Set; - import org.gradle.api.Project; import org.gradle.api.Task; import org.gradle.api.artifacts.Configuration; @@ -62,35 +88,8 @@ import org.gradle.language.jvm.tasks.ProcessResources; import org.gradle.tooling.provider.model.ParameterizedToolingModelBuilder; -import io.quarkus.bootstrap.BootstrapConstants; -import io.quarkus.bootstrap.model.ApplicationModel; -import io.quarkus.bootstrap.model.ApplicationModelBuilder; -import io.quarkus.bootstrap.model.CapabilityContract; -import io.quarkus.bootstrap.model.PlatformImports; -import io.quarkus.bootstrap.model.gradle.ModelParameter; -import io.quarkus.bootstrap.model.gradle.impl.ModelParameterImpl; -import io.quarkus.bootstrap.workspace.ArtifactSources; -import io.quarkus.bootstrap.workspace.DefaultArtifactSources; -import io.quarkus.bootstrap.workspace.DefaultSourceDir; -import io.quarkus.bootstrap.workspace.DefaultWorkspaceModule; -import io.quarkus.bootstrap.workspace.SourceDir; -import io.quarkus.bootstrap.workspace.WorkspaceModule; -import io.quarkus.fs.util.ZipUtils; -import io.quarkus.gradle.dependency.ApplicationDeploymentClasspathBuilder; -import io.quarkus.maven.dependency.ArtifactCoords; -import io.quarkus.maven.dependency.ArtifactDependency; -import io.quarkus.maven.dependency.ArtifactKey; -import io.quarkus.maven.dependency.DependencyFlags; -import io.quarkus.maven.dependency.GACT; -import io.quarkus.maven.dependency.GACTV; -import io.quarkus.maven.dependency.GAV; -import io.quarkus.maven.dependency.ResolvedDependency; -import io.quarkus.maven.dependency.ResolvedDependencyBuilder; -import io.quarkus.paths.PathCollection; -import io.quarkus.paths.PathList; -import io.quarkus.runtime.LaunchMode; - -// Based on https://github.com/quarkusio/quarkus/blob/3.9.5/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java +// Based on +// https://github.com/quarkusio/quarkus/blob/3.9.5/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java public class GradleApplicationModelBuilder implements ParameterizedToolingModelBuilder { @@ -99,8 +98,9 @@ public class GradleApplicationModelBuilder /* @formatter:off */ private static final byte COLLECT_TOP_EXTENSION_RUNTIME_NODES = 0b001; - private static final byte COLLECT_DIRECT_DEPS = 0b010; - private static final byte COLLECT_RELOADABLE_MODULES = 0b100; + private static final byte COLLECT_DIRECT_DEPS = 0b010; + private static final byte COLLECT_RELOADABLE_MODULES = 0b100; + /* @formatter:on */ @Override @@ -137,9 +137,7 @@ public Object buildAll(String modelName, ModelParameter parameter, Project proje System.getProperty(BootstrapConstants.QUARKUS_BOOTSTRAP_WORKSPACE_DISCOVERY)); if (!workspaceDiscovery) { Object o = - project - .getProperties() - .get(BootstrapConstants.QUARKUS_BOOTSTRAP_WORKSPACE_DISCOVERY); + project.getProperties().get(BootstrapConstants.QUARKUS_BOOTSTRAP_WORKSPACE_DISCOVERY); if (o != null) { workspaceDiscovery = Boolean.parseBoolean(o.toString()); } @@ -181,8 +179,7 @@ private static void addCompileOnly( } var moduleId = a.getModuleVersion().getId(); var key = - ArtifactKey.of( - moduleId.getGroup(), moduleId.getName(), a.getClassifier(), a.getType()); + ArtifactKey.of(moduleId.getGroup(), moduleId.getName(), a.getClassifier(), a.getType()); var appDep = modelBuilder.getDependency(key); if (appDep == null) { addArtifactDependency(project, modelBuilder, a); @@ -200,8 +197,7 @@ private static void addCompileOnly( } } - public static ResolvedDependency getProjectArtifact( - Project project, boolean workspaceDiscovery) { + public static ResolvedDependency getProjectArtifact(Project project, boolean workspaceDiscovery) { final ResolvedDependencyBuilder appArtifact = ResolvedDependencyBuilder.newInstance() .setGroupId(project.getGroup().toString()) @@ -300,19 +296,15 @@ private static void addArtifactDependency( (ProjectComponentIdentifier) a.getId().getComponentIdentifier(); // Upstream uses getBuild().getName(); getBuildPath() is needed for our composite build var includedBuild = - ToolingUtils.includedBuild( - project, projectComponentIdentifier.getBuild().getBuildPath()); + ToolingUtils.includedBuild(project, projectComponentIdentifier.getBuild().getBuildPath()); final Project projectDep; if (includedBuild != null) { projectDep = ToolingUtils.includedBuildProject( - (IncludedBuildInternal) includedBuild, - projectComponentIdentifier.getProjectPath()); + (IncludedBuildInternal) includedBuild, projectComponentIdentifier.getProjectPath()); } else { projectDep = - project - .getRootProject() - .findProject(projectComponentIdentifier.getProjectPath()); + project.getRootProject().findProject(projectComponentIdentifier.getProjectPath()); } Objects.requireNonNull( projectDep, @@ -535,13 +527,7 @@ private void collectDependencies( final PathList.Builder pathBuilder = PathList.builder(); projectModule = initProjectModuleAndBuildPaths( - projectDep, - a, - modelBuilder, - depBuilder, - pathBuilder, - "testFixtures", - true); + projectDep, a, modelBuilder, depBuilder, pathBuilder, "testFixtures", true); paths = pathBuilder.build(); } } @@ -567,11 +553,9 @@ private void collectDependencies( } } - processedModules.add( - ArtifactKey.ga(resolvedDep.getModuleGroup(), resolvedDep.getModuleName())); + processedModules.add(ArtifactKey.ga(resolvedDep.getModuleGroup(), resolvedDep.getModuleName())); for (org.gradle.api.artifacts.ResolvedDependency child : resolvedDep.getChildren()) { - if (!processedModules.contains( - new GACT(child.getModuleGroup(), child.getModuleName()))) { + if (!processedModules.contains(new GACT(child.getModuleGroup(), child.getModuleName()))) { collectDependencies( child, workspaceDiscovery, @@ -612,14 +596,11 @@ private WorkspaceModule.Mutable initProjectModuleAndBuildPaths( .setBuildFile(project.getBuildFile().toPath()); final String classifier = toNonNullClassifier(resolvedArtifact.getClassifier()); - SourceSetContainer sourceSets = - project.getExtensions().getByType(SourceSetContainer.class); + SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); initProjectModule(project, projectModule, sourceSets.findByName(sourceName), classifier); - collectDestinationDirs( - projectModule.getSources(classifier).getSourceDirs(), buildPaths); - collectDestinationDirs( - projectModule.getSources(classifier).getResourceDirs(), buildPaths); + collectDestinationDirs(projectModule.getSources(classifier).getSourceDirs(), buildPaths); + collectDestinationDirs(projectModule.getSources(classifier).getResourceDirs(), buildPaths); appModel.addReloadableWorkspaceModule( ArtifactKey.of( @@ -639,15 +620,11 @@ private boolean processQuarkusDependency( } if (Files.isDirectory(artifactPath)) { return processQuarkusDir( - artifactBuilder, - artifactPath.resolve(BootstrapConstants.META_INF), - modelBuilder); + artifactBuilder, artifactPath.resolve(BootstrapConstants.META_INF), modelBuilder); } else { try (FileSystem artifactFs = ZipUtils.newFileSystem(artifactPath)) { return processQuarkusDir( - artifactBuilder, - artifactFs.getPath(BootstrapConstants.META_INF), - modelBuilder); + artifactBuilder, artifactFs.getPath(BootstrapConstants.META_INF), modelBuilder); } catch (IOException e) { throw new RuntimeException("Failed to process " + artifactPath, e); } @@ -700,10 +677,7 @@ private static Properties readDescriptor(final Path path) { } private static void initProjectModule( - Project project, - WorkspaceModule.Mutable module, - SourceSet sourceSet, - String classifier) { + Project project, WorkspaceModule.Mutable module, SourceSet sourceSet, String classifier) { if (sourceSet == null) { return; @@ -721,11 +695,7 @@ private static void initProjectModule( AbstractCompile.class, t -> configureCompileTask( - t.getSource(), - t.getDestinationDirectory(), - allClassesDirs, - sourceDirs, - t)); + t.getSource(), t.getDestinationDirectory(), allClassesDirs, sourceDirs, t)); // Upstream calls maybeConfigureKotlinJvmCompile() here; removed to avoid adding a // compile-time dependency on kotlin-gradle-plugin-api @@ -796,10 +766,7 @@ private static void configureCompileTask( final File srcDir = a.getFile().getParentFile(); sourceDirs.add( new DefaultSourceDir( - srcDir.toPath(), - destDir.toPath(), - null, - Map.of("compiler", task.getName()))); + srcDir.toPath(), destDir.toPath(), null, Map.of("compiler", task.getName()))); } }); } @@ -842,9 +809,7 @@ private static boolean isDependency(ResolvedArtifact a) { || a.getFile().isDirectory(); } - /** - * Creates an instance of Dependency and associates it with the ResolvedArtifact's path - */ + /** Creates an instance of Dependency and associates it with the ResolvedArtifact's path */ static ResolvedDependencyBuilder toDependency(ResolvedArtifact a, int... flags) { return toDependency(a, PathList.of(a.getFile().toPath()), null, flags); } @@ -868,10 +833,7 @@ static ResolvedDependencyBuilder toDependency(ResolvedArtifact a, SourceSet s) { } static ResolvedDependencyBuilder toDependency( - ResolvedArtifact a, - PathCollection paths, - DefaultWorkspaceModule module, - int... flags) { + ResolvedArtifact a, PathCollection paths, DefaultWorkspaceModule module, int... flags) { int allFlags = 0; for (int f : flags) { allFlags |= f; @@ -886,11 +848,7 @@ static ResolvedDependencyBuilder toDependency( private static ArtifactCoords toArtifactCoords(ResolvedArtifact a) { final String[] split = a.getModuleVersion().toString().split(":"); return new GACTV( - split[0], - split[1], - a.getClassifier(), - a.getType(), - split.length > 2 ? split[2] : null); + split[0], split[1], a.getClassifier(), a.getType(), split.length > 2 ? split[2] : null); } private static ArtifactKey toAppDependenciesKey( @@ -903,8 +861,7 @@ private static ArtifactKey toAppDependenciesKey( private static String sha1(String value) { try { byte[] digest = - MessageDigest.getInstance("SHA-1") - .digest(value.getBytes(StandardCharsets.UTF_8)); + MessageDigest.getInstance("SHA-1").digest(value.getBytes(StandardCharsets.UTF_8)); StringBuilder sb = new StringBuilder(40); for (byte b : digest) { sb.append(Integer.toHexString((b & 0xFF) | 0x100).substring(1, 3)); diff --git a/instrumentation/quarkus-resteasy-reactive/quarkus-3.9-plugin/src/main/java/io/quarkus/gradle/tooling/ToolingUtils.java b/instrumentation/quarkus-resteasy-reactive/quarkus-3.9-plugin/src/main/java/io/quarkus/gradle/tooling/ToolingUtils.java index 0f4549f4702c..2d1cec67f0eb 100644 --- a/instrumentation/quarkus-resteasy-reactive/quarkus-3.9-plugin/src/main/java/io/quarkus/gradle/tooling/ToolingUtils.java +++ b/instrumentation/quarkus-resteasy-reactive/quarkus-3.9-plugin/src/main/java/io/quarkus/gradle/tooling/ToolingUtils.java @@ -22,12 +22,16 @@ package io.quarkus.gradle.tooling; +import io.quarkus.bootstrap.model.ApplicationModel; +import io.quarkus.bootstrap.model.gradle.ModelParameter; +import io.quarkus.bootstrap.model.gradle.impl.ModelParameterImpl; +import io.quarkus.maven.dependency.ArtifactCoords; +import io.quarkus.runtime.LaunchMode; import java.io.IOException; import java.io.ObjectOutputStream; import java.nio.file.Files; import java.nio.file.Path; import java.util.Objects; - import org.gradle.api.Project; import org.gradle.api.Task; import org.gradle.api.artifacts.ExternalModuleDependency; @@ -39,13 +43,8 @@ import org.gradle.internal.composite.IncludedBuildInternal; import org.gradle.internal.composite.IncludedRootBuild; -import io.quarkus.bootstrap.model.ApplicationModel; -import io.quarkus.bootstrap.model.gradle.ModelParameter; -import io.quarkus.bootstrap.model.gradle.impl.ModelParameterImpl; -import io.quarkus.maven.dependency.ArtifactCoords; -import io.quarkus.runtime.LaunchMode; - -// Based on https://github.com/quarkusio/quarkus/blob/3.9.5/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/ToolingUtils.java +// Based on +// https://github.com/quarkusio/quarkus/blob/3.9.5/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/ToolingUtils.java public class ToolingUtils { private static final String DEPLOYMENT_CONFIGURATION_SUFFIX = "Deployment"; @@ -62,8 +61,9 @@ public static String toPlatformConfigurationName(String baseConfigurationName) { public static boolean isEnforcedPlatform(ModuleDependency module) { final Category category = module.getAttributes().getAttribute(Category.CATEGORY_ATTRIBUTE); - return category != null && (Category.ENFORCED_PLATFORM.equals(category.getName()) - || Category.REGULAR_PLATFORM.equals(category.getName())); + return category != null + && (Category.ENFORCED_PLATFORM.equals(category.getName()) + || Category.REGULAR_PLATFORM.equals(category.getName())); } public static IncludedBuild includedBuild(final Project project, final String buildName) { @@ -86,7 +86,8 @@ public static IncludedBuild includedBuild(final Project project, final String bu return null; } - public static Project includedBuildProject(IncludedBuildInternal includedBuild, final String projectPath) { + public static Project includedBuildProject( + IncludedBuildInternal includedBuild, final String projectPath) { return includedBuild.getTarget().getMutableModel().getRootProject().findProject(projectPath); } @@ -108,11 +109,13 @@ public static Project findLocalProject(final Project project, final String proje } } - public static Project findLocalProject(final Project project, final ArtifactCoords artifactCoords) { + public static Project findLocalProject( + final Project project, final ArtifactCoords artifactCoords) { for (Project subproject : project.getRootProject().getSubprojects()) { if (subproject.getGroup().equals(artifactCoords.getGroupId()) && subproject.getName().equals(artifactCoords.getArtifactId()) - && (artifactCoords.getVersion() == null || subproject.getVersion().equals(artifactCoords.getVersion()))) { + && (artifactCoords.getVersion() == null + || subproject.getVersion().equals(artifactCoords.getVersion()))) { return subproject; } } @@ -140,7 +143,8 @@ public static Project findIncludedProject(Project project, ExternalModuleDepende return null; } } catch (IllegalStateException ise) { - // This can happen if the project itself is in an included build, which means that the root-project + // This can happen if the project itself is in an included build, which means that the + // root-project // is not yet known, so `DefaultGradle.getRootProject()` throws an ISE. return null; } @@ -150,7 +154,8 @@ private static Project findLocalProject(Project project, ExternalModuleDependenc for (Project p : project.getRootProject().getSubprojects()) { if (Objects.equals(p.getGroup(), dependency.getGroup()) && Objects.equals(p.getName(), dependency.getName()) - && (dependency.getVersion() == null || Objects.equals(p.getVersion(), dependency.getVersion()))) { + && (dependency.getVersion() == null + || Objects.equals(p.getVersion(), dependency.getVersion()))) { return p; } } @@ -158,7 +163,8 @@ private static Project findLocalProject(Project project, ExternalModuleDependenc return null; } - private static Project findIncludedBuildProject(IncludedBuild ib, ExternalModuleDependency dependency) { + private static Project findIncludedBuildProject( + IncludedBuild ib, ExternalModuleDependency dependency) { if (!(ib instanceof DefaultIncludedBuild.IncludedBuildImpl)) { return null; } @@ -169,15 +175,20 @@ private static Project findIncludedBuildProject(IncludedBuild ib, ExternalModule return findLocalProject(rootProject, dependency); } catch (IllegalStateException ise) { - // This can happen if the project itself is in an included build, which means that the root-project + // This can happen if the project itself is in an included build, which means that the + // root-project // is not yet known, so `DefaultGradle.getRootProject()` throws an ISE. return null; } } - public static Path serializeAppModel(ApplicationModel appModel, Task context, boolean test) throws IOException { - final Path serializedModel = context.getTemporaryDir().toPath() - .resolve("quarkus-app" + (test ? "-test" : "") + "-model.dat"); + public static Path serializeAppModel(ApplicationModel appModel, Task context, boolean test) + throws IOException { + final Path serializedModel = + context + .getTemporaryDir() + .toPath() + .resolve("quarkus-app" + (test ? "-test" : "") + "-model.dat"); try (ObjectOutputStream out = new ObjectOutputStream(Files.newOutputStream(serializedModel))) { out.writeObject(appModel); } @@ -191,8 +202,8 @@ public static ApplicationModel create(Project project, LaunchMode mode) { } public static ApplicationModel create(Project project, ModelParameter params) { - return (ApplicationModel) new GradleApplicationModelBuilder().buildAll(ApplicationModel.class.getName(), params, - project); + return (ApplicationModel) + new GradleApplicationModelBuilder() + .buildAll(ApplicationModel.class.getName(), params, project); } - } diff --git a/instrumentation/quarkus-resteasy-reactive/quarkus-3.9-plugin/src/main/java/io/quarkus/gradle/tooling/dependency/DependencyUtils.java b/instrumentation/quarkus-resteasy-reactive/quarkus-3.9-plugin/src/main/java/io/quarkus/gradle/tooling/dependency/DependencyUtils.java index e820f8aaba2a..21234953c5a4 100644 --- a/instrumentation/quarkus-resteasy-reactive/quarkus-3.9-plugin/src/main/java/io/quarkus/gradle/tooling/dependency/DependencyUtils.java +++ b/instrumentation/quarkus-resteasy-reactive/quarkus-3.9-plugin/src/main/java/io/quarkus/gradle/tooling/dependency/DependencyUtils.java @@ -22,6 +22,16 @@ package io.quarkus.gradle.tooling.dependency; +import io.quarkus.bootstrap.BootstrapConstants; +import io.quarkus.bootstrap.util.BootstrapUtils; +import io.quarkus.fs.util.ZipUtils; +import io.quarkus.gradle.extension.ConfigurationUtils; +import io.quarkus.gradle.extension.ExtensionConstants; +import io.quarkus.gradle.tooling.ToolingUtils; +import io.quarkus.maven.dependency.ArtifactCoords; +import io.quarkus.maven.dependency.ArtifactKey; +import io.quarkus.maven.dependency.GACT; +import io.quarkus.maven.dependency.GACTV; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -34,7 +44,6 @@ import java.util.List; import java.util.Properties; import java.util.Set; - import org.gradle.api.GradleException; import org.gradle.api.Project; import org.gradle.api.artifacts.Configuration; @@ -54,32 +63,24 @@ import org.gradle.internal.composite.IncludedBuildInternal; import org.jetbrains.annotations.Nullable; -import io.quarkus.bootstrap.BootstrapConstants; -import io.quarkus.bootstrap.util.BootstrapUtils; -import io.quarkus.fs.util.ZipUtils; -import io.quarkus.gradle.extension.ConfigurationUtils; -import io.quarkus.gradle.extension.ExtensionConstants; -import io.quarkus.gradle.tooling.ToolingUtils; -import io.quarkus.maven.dependency.ArtifactCoords; -import io.quarkus.maven.dependency.ArtifactKey; -import io.quarkus.maven.dependency.GACT; -import io.quarkus.maven.dependency.GACTV; - -// Based on https://github.com/quarkusio/quarkus/blob/3.9.5/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/dependency/DependencyUtils.java +// Based on +// https://github.com/quarkusio/quarkus/blob/3.9.5/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/dependency/DependencyUtils.java public class DependencyUtils { private static final String COPY_CONFIGURATION_NAME = "quarkusDependency"; private static final String TEST_FIXTURE_SUFFIX = "-test-fixtures"; public static Configuration duplicateConfiguration(Project project, Configuration toDuplicate) { - Configuration configurationCopy = project.getConfigurations().findByName(COPY_CONFIGURATION_NAME); + Configuration configurationCopy = + project.getConfigurations().findByName(COPY_CONFIGURATION_NAME); if (configurationCopy != null) { project.getConfigurations().remove(configurationCopy); } return duplicateConfiguration(project, COPY_CONFIGURATION_NAME, toDuplicate); } - public static Configuration duplicateConfiguration(Project project, String name, Configuration toDuplicate) { + public static Configuration duplicateConfiguration( + Project project, String name, Configuration toDuplicate) { final Configuration configurationCopy = project.getConfigurations().create(name); configurationCopy.getDependencies().addAll(toDuplicate.getAllDependencies()); configurationCopy.getDependencyConstraints().addAll(toDuplicate.getAllDependencyConstraints()); @@ -104,32 +105,41 @@ public static String asDependencyNotation(Dependency dependency) { } public static String asDependencyNotation(ArtifactCoords artifactCoords) { - return String.join(":", artifactCoords.getGroupId(), artifactCoords.getArtifactId(), artifactCoords.getVersion()); + return String.join( + ":", + artifactCoords.getGroupId(), + artifactCoords.getArtifactId(), + artifactCoords.getVersion()); } - public static ExtensionDependency getExtensionInfoOrNull(Project project, ResolvedArtifact artifact) { + public static ExtensionDependency getExtensionInfoOrNull( + Project project, ResolvedArtifact artifact) { ModuleVersionIdentifier artifactId = artifact.getModuleVersion().getId(); ExtensionDependency projectDependency; if (artifact.getId().getComponentIdentifier() instanceof ProjectComponentIdentifier) { - ProjectComponentIdentifier componentId = (ProjectComponentIdentifier) artifact.getId().getComponentIdentifier(); + ProjectComponentIdentifier componentId = + (ProjectComponentIdentifier) artifact.getId().getComponentIdentifier(); - projectDependency = getProjectExtensionDependencyOrNull( - project, - componentId.getProjectPath(), - // upstream uses getBuild().getName(), but getBuildPath() is needed for our - // composite build structure where included build names may be colon-prefixed - componentId.getBuild().getBuildPath()); + projectDependency = + getProjectExtensionDependencyOrNull( + project, + componentId.getProjectPath(), + // upstream uses getBuild().getName(), but getBuildPath() is needed for our + // composite build structure where included build names may be colon-prefixed + componentId.getBuild().getBuildPath()); if (projectDependency != null) { return projectDependency; } } - Project localExtensionProject = ToolingUtils.findLocalProject( - project, - ArtifactCoords.of(artifactId.getGroup(), artifactId.getName(), null, null, artifactId.getVersion())); + Project localExtensionProject = + ToolingUtils.findLocalProject( + project, + ArtifactCoords.of( + artifactId.getGroup(), artifactId.getName(), null, null, artifactId.getVersion())); if (localExtensionProject != null) { projectDependency = getExtensionInfoOrNull(project, localExtensionProject); @@ -162,16 +172,21 @@ public static ExtensionDependency getExtensionInfoOrNull(Project project, Res return null; } - public static ExtensionDependency getExtensionInfoOrNull(Project project, Project extensionProject) { - boolean isIncludedBuild = !project.getRootProject().getGradle().equals(extensionProject.getRootProject().getGradle()); + public static ExtensionDependency getExtensionInfoOrNull( + Project project, Project extensionProject) { + boolean isIncludedBuild = + !project.getRootProject().getGradle().equals(extensionProject.getRootProject().getGradle()); - ModuleVersionIdentifier extensionArtifactId = DefaultModuleVersionIdentifier.newId( - extensionProject.getGroup().toString(), - extensionProject.getName(), - extensionProject.getVersion().toString()); + ModuleVersionIdentifier extensionArtifactId = + DefaultModuleVersionIdentifier.newId( + extensionProject.getGroup().toString(), + extensionProject.getName(), + extensionProject.getVersion().toString()); - Object extensionConfiguration = extensionProject - .getExtensions().findByName(ExtensionConstants.EXTENSION_CONFIGURATION_NAME); + Object extensionConfiguration = + extensionProject + .getExtensions() + .findByName(ExtensionConstants.EXTENSION_CONFIGURATION_NAME); // If there's an extension configuration file in the project resources it can override // certain settings, so we also look for it here. @@ -191,7 +206,8 @@ public static ExtensionDependency getExtensionInfoOrNull(Project project, Pro } private static Path findLocalExtensionDescriptorPath(Project extensionProject) { - SourceSetContainer sourceSets = extensionProject.getExtensions().getByType(SourceSetContainer.class); + SourceSetContainer sourceSets = + extensionProject.getExtensions().getByType(SourceSetContainer.class); SourceSet mainSourceSet = sourceSets.findByName(SourceSet.MAIN_SOURCE_SET_NAME); if (mainSourceSet == null) { return null; @@ -221,14 +237,14 @@ private static Properties loadLocalExtensionDescriptor(Path descriptorPath) { @Nullable public static ExtensionDependency getProjectExtensionDependencyOrNull( - Project project, - String projectPath, - @Nullable String buildName) { + Project project, String projectPath, @Nullable String buildName) { Project extensionProject = project.getRootProject().findProject(projectPath); if (extensionProject == null) { IncludedBuild extProjIncludedBuild = ToolingUtils.includedBuild(project, buildName); if (extProjIncludedBuild instanceof IncludedBuildInternal) { - extensionProject = ToolingUtils.includedBuildProject((IncludedBuildInternal) extProjIncludedBuild, projectPath); + extensionProject = + ToolingUtils.includedBuildProject( + (IncludedBuildInternal) extProjIncludedBuild, projectPath); } } @@ -247,28 +263,37 @@ private static ProjectExtensionDependency createExtensionDependency( @Nullable Properties extensionDescriptor, boolean isIncludedBuild) { if (extensionConfiguration == null && extensionDescriptor == null) { - throw new IllegalArgumentException("both extensionConfiguration and extensionDescriptor are null"); + throw new IllegalArgumentException( + "both extensionConfiguration and extensionDescriptor are null"); } Project deploymentProject = null; if (extensionConfiguration != null) { - final String deploymentProjectPath = ConfigurationUtils.getDeploymentModule(extensionConfiguration).get(); + final String deploymentProjectPath = + ConfigurationUtils.getDeploymentModule(extensionConfiguration).get(); deploymentProject = ToolingUtils.findLocalProject(extensionProject, deploymentProjectPath); if (deploymentProject == null) { - throw new GradleException("Cannot find deployment project for extension " + extensionArtifactId + " at path " - + deploymentProjectPath); + throw new GradleException( + "Cannot find deployment project for extension " + + extensionArtifactId + + " at path " + + deploymentProjectPath); } } else if (extensionDescriptor.containsKey(BootstrapConstants.PROP_DEPLOYMENT_ARTIFACT)) { - final ArtifactCoords deploymentArtifact = GACTV - .fromString(extensionDescriptor.getProperty(BootstrapConstants.PROP_DEPLOYMENT_ARTIFACT)); + final ArtifactCoords deploymentArtifact = + GACTV.fromString( + extensionDescriptor.getProperty(BootstrapConstants.PROP_DEPLOYMENT_ARTIFACT)); deploymentProject = ToolingUtils.findLocalProject(project, deploymentArtifact); if (deploymentProject == null) { - throw new GradleException("Cannot find deployment project for extension " + extensionArtifactId - + " with artifact coordinates " + deploymentArtifact); + throw new GradleException( + "Cannot find deployment project for extension " + + extensionArtifactId + + " with artifact coordinates " + + deploymentArtifact); } } @@ -276,8 +301,8 @@ private static ProjectExtensionDependency createExtensionDependency( final List dependencyConditions = new ArrayList<>(); if (extensionConfiguration != null) { - final ListProperty conditionalDependenciesProp = ConfigurationUtils - .getConditionalDependencies(extensionConfiguration); + final ListProperty conditionalDependenciesProp = + ConfigurationUtils.getConditionalDependencies(extensionConfiguration); if (conditionalDependenciesProp.isPresent()) { for (String rawDep : conditionalDependenciesProp.get()) { @@ -285,8 +310,8 @@ private static ProjectExtensionDependency createExtensionDependency( } } - final ListProperty dependencyConditionsProp = ConfigurationUtils - .getDependencyConditions(extensionConfiguration); + final ListProperty dependencyConditionsProp = + ConfigurationUtils.getDependencyConditions(extensionConfiguration); if (dependencyConditionsProp.isPresent()) { for (String rawCond : dependencyConditionsProp.get()) { @@ -295,18 +320,22 @@ private static ProjectExtensionDependency createExtensionDependency( } } - if (extensionDescriptor != null && extensionDescriptor.containsKey(BootstrapConstants.CONDITIONAL_DEPENDENCIES)) { - final String[] deps = BootstrapUtils - .splitByWhitespace(extensionDescriptor.getProperty(BootstrapConstants.CONDITIONAL_DEPENDENCIES)); + if (extensionDescriptor != null + && extensionDescriptor.containsKey(BootstrapConstants.CONDITIONAL_DEPENDENCIES)) { + final String[] deps = + BootstrapUtils.splitByWhitespace( + extensionDescriptor.getProperty(BootstrapConstants.CONDITIONAL_DEPENDENCIES)); for (String condDep : deps) { conditionalDependencies.add(create(project.getDependencies(), condDep)); } } - if (extensionDescriptor != null && extensionDescriptor.containsKey(BootstrapConstants.DEPENDENCY_CONDITION)) { - final ArtifactKey[] conditions = BootstrapUtils - .parseDependencyCondition(extensionDescriptor.getProperty(BootstrapConstants.DEPENDENCY_CONDITION)); + if (extensionDescriptor != null + && extensionDescriptor.containsKey(BootstrapConstants.DEPENDENCY_CONDITION)) { + final ArtifactKey[] conditions = + BootstrapUtils.parseDependencyCondition( + extensionDescriptor.getProperty(BootstrapConstants.DEPENDENCY_CONDITION)); dependencyConditions.addAll(Arrays.asList(conditions)); } @@ -320,18 +349,18 @@ private static ProjectExtensionDependency createExtensionDependency( } private static ArtifactExtensionDependency createExtensionDependency( - Project project, - ModuleVersionIdentifier extensionArtifactId, - Path descriptorPath) { + Project project, ModuleVersionIdentifier extensionArtifactId, Path descriptorPath) { final Properties extensionProperties = loadLocalExtensionDescriptor(descriptorPath); - final ArtifactCoords deploymentArtifact = GACTV - .fromString(extensionProperties.getProperty(BootstrapConstants.PROP_DEPLOYMENT_ARTIFACT)); + final ArtifactCoords deploymentArtifact = + GACTV.fromString( + extensionProperties.getProperty(BootstrapConstants.PROP_DEPLOYMENT_ARTIFACT)); final List conditionalDependencies; if (extensionProperties.containsKey(BootstrapConstants.CONDITIONAL_DEPENDENCIES)) { - final String[] deps = BootstrapUtils - .splitByWhitespace(extensionProperties.getProperty(BootstrapConstants.CONDITIONAL_DEPENDENCIES)); + final String[] deps = + BootstrapUtils.splitByWhitespace( + extensionProperties.getProperty(BootstrapConstants.CONDITIONAL_DEPENDENCIES)); if (deps.length > 0) { conditionalDependencies = new ArrayList<>(deps.length); @@ -347,8 +376,9 @@ private static ArtifactExtensionDependency createExtensionDependency( final List dependencyConditions; if (extensionProperties.containsKey(BootstrapConstants.DEPENDENCY_CONDITION)) { - final ArtifactKey[] conditions = BootstrapUtils - .parseDependencyCondition(extensionProperties.getProperty(BootstrapConstants.DEPENDENCY_CONDITION)); + final ArtifactKey[] conditions = + BootstrapUtils.parseDependencyCondition( + extensionProperties.getProperty(BootstrapConstants.DEPENDENCY_CONDITION)); if (conditions.length > 0) { dependencyConditions = Arrays.asList(conditions); @@ -360,21 +390,21 @@ private static ArtifactExtensionDependency createExtensionDependency( } return new ArtifactExtensionDependency( - extensionArtifactId, - deploymentArtifact, - conditionalDependencies, - dependencyConditions); + extensionArtifactId, deploymentArtifact, conditionalDependencies, dependencyConditions); } public static Dependency create(DependencyHandler dependencies, String conditionalDependency) { final ArtifactCoords dependencyCoords = GACTV.fromString(conditionalDependency); - return dependencies.create(String.join(":", dependencyCoords.getGroupId(), dependencyCoords.getArtifactId(), - dependencyCoords.getVersion())); + return dependencies.create( + String.join( + ":", + dependencyCoords.getGroupId(), + dependencyCoords.getArtifactId(), + dependencyCoords.getVersion())); } public static Dependency createDeploymentDependency( - DependencyHandler dependencyHandler, - ExtensionDependency dependency) { + DependencyHandler dependencyHandler, ExtensionDependency dependency) { if (dependency instanceof ProjectExtensionDependency) { ProjectExtensionDependency ped = (ProjectExtensionDependency) dependency; return createDeploymentProjectDependency(dependencyHandler, ped); @@ -383,26 +413,32 @@ public static Dependency createDeploymentDependency( return createArtifactDeploymentDependency(dependencyHandler, aed); } - throw new IllegalArgumentException("Unknown ExtensionDependency type: " + dependency.getClass().getName()); + throw new IllegalArgumentException( + "Unknown ExtensionDependency type: " + dependency.getClass().getName()); } - private static Dependency createDeploymentProjectDependency(DependencyHandler handler, ProjectExtensionDependency ped) { + private static Dependency createDeploymentProjectDependency( + DependencyHandler handler, ProjectExtensionDependency ped) { if (ped.isIncludedBuild()) { return new DefaultExternalModuleDependency( ped.getDeploymentModule().getGroup().toString(), ped.getDeploymentModule().getName(), ped.getDeploymentModule().getVersion().toString()); - // upstream has an additional branch here for ProjectInternal, which is removed to avoid - // depending on Gradle-internal APIs that are not needed in our build + // upstream has an additional branch here for ProjectInternal, which is removed to avoid + // depending on Gradle-internal APIs that are not needed in our build } else { - return handler.create(handler.project(Collections.singletonMap("path", ped.getDeploymentModule().getPath()))); + return handler.create( + handler.project(Collections.singletonMap("path", ped.getDeploymentModule().getPath()))); } } - private static Dependency createArtifactDeploymentDependency(DependencyHandler handler, - ArtifactExtensionDependency dependency) { - return handler.create(dependency.getDeploymentModule().getGroupId() + ":" - + dependency.getDeploymentModule().getArtifactId() + ":" - + dependency.getDeploymentModule().getVersion()); + private static Dependency createArtifactDeploymentDependency( + DependencyHandler handler, ArtifactExtensionDependency dependency) { + return handler.create( + dependency.getDeploymentModule().getGroupId() + + ":" + + dependency.getDeploymentModule().getArtifactId() + + ":" + + dependency.getDeploymentModule().getVersion()); } } diff --git a/instrumentation/quarkus-resteasy-reactive/quarkus-3.9-testing/build.gradle.kts b/instrumentation/quarkus-resteasy-reactive/quarkus-3.9-testing/build.gradle.kts index b40050cb4b6c..d22b64159339 100644 --- a/instrumentation/quarkus-resteasy-reactive/quarkus-3.9-testing/build.gradle.kts +++ b/instrumentation/quarkus-resteasy-reactive/quarkus-3.9-testing/build.gradle.kts @@ -53,17 +53,24 @@ val quarkusTestCompileOnlyConfiguration by configurations.creating { val testModelPath = layout.buildDirectory.file("quarkus-app-test-model.dat") -val buildModel = if (findProperty("skipTests") as String? != "true") { - tasks.register("buildModel") { - projectRef = project - runtimeClasspath.from(configurations.named("testRuntimeClasspath")) - outputFile.set(testModelPath) - - onlyIf { outputFile.get().asFile.toPath().notExists() } +val buildModel = + if (findProperty("skipTests") as String? != "true") { + tasks.register("buildModel") { + projectRef = project + runtimeClasspath.from(configurations.named("testRuntimeClasspath")) + outputFile.set(testModelPath) + + onlyIf { + outputFile + .get() + .asFile + .toPath() + .notExists() + } + } + } else { + null } -} else { - null -} tasks { test { @@ -71,7 +78,10 @@ tasks { dependsOn(buildModel) } - systemProperty("quarkus-internal-test.serialized-app-model.path", testModelPath.get().asFile.toString()) + systemProperty( + "quarkus-internal-test.serialized-app-model.path", + testModelPath.get().asFile.toString(), + ) } if (otelProps.denyUnsafe) { @@ -82,7 +92,6 @@ tasks { } abstract class BuildModelTask : DefaultTask() { - @get:Internal @Transient var projectRef: Project? = null @@ -95,7 +104,7 @@ abstract class BuildModelTask : DefaultTask() { init { notCompatibleWithConfigurationCache( - "Quarkus GradleApplicationModelBuilder.buildAll() requires Project reference" + "Quarkus GradleApplicationModelBuilder.buildAll() requires Project reference", ) } @@ -104,11 +113,12 @@ abstract class BuildModelTask : DefaultTask() { val modelPath = outputFile.get().asFile.toPath() val modelParameter = ModelParameterImpl() modelParameter.mode = LaunchMode.TEST.toString() - val model = GradleApplicationModelBuilder().buildAll( - ApplicationModel::class.java.getName(), - modelParameter, - checkNotNull(projectRef) - ) + val model = + GradleApplicationModelBuilder().buildAll( + ApplicationModel::class.java.getName(), + modelParameter, + checkNotNull(projectRef), + ) BootstrapUtils.serializeAppModel(model as ApplicationModel?, modelPath) } } diff --git a/instrumentation/quarkus-resteasy-reactive/quarkus-common-plugin/src/main/java/io/quarkus/gradle/dependency/ConditionalDependenciesEnabler.java b/instrumentation/quarkus-resteasy-reactive/quarkus-common-plugin/src/main/java/io/quarkus/gradle/dependency/ConditionalDependenciesEnabler.java index 77d863a9e8ca..5b389eec861e 100644 --- a/instrumentation/quarkus-resteasy-reactive/quarkus-common-plugin/src/main/java/io/quarkus/gradle/dependency/ConditionalDependenciesEnabler.java +++ b/instrumentation/quarkus-resteasy-reactive/quarkus-common-plugin/src/main/java/io/quarkus/gradle/dependency/ConditionalDependenciesEnabler.java @@ -22,6 +22,12 @@ package io.quarkus.gradle.dependency; +import io.quarkus.gradle.tooling.dependency.DependencyUtils; +import io.quarkus.gradle.tooling.dependency.ExtensionDependency; +import io.quarkus.maven.dependency.ArtifactCoords; +import io.quarkus.maven.dependency.ArtifactKey; +import io.quarkus.maven.dependency.GACT; +import io.quarkus.runtime.LaunchMode; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -29,49 +35,44 @@ import java.util.List; import java.util.Map; import java.util.Set; - import org.gradle.api.Project; import org.gradle.api.artifacts.Configuration; import org.gradle.api.artifacts.Dependency; import org.gradle.api.artifacts.ModuleVersionIdentifier; import org.gradle.api.artifacts.ResolvedArtifact; -import io.quarkus.gradle.tooling.dependency.DependencyUtils; -import io.quarkus.gradle.tooling.dependency.ExtensionDependency; -import io.quarkus.maven.dependency.ArtifactCoords; -import io.quarkus.maven.dependency.ArtifactKey; -import io.quarkus.maven.dependency.GACT; -import io.quarkus.runtime.LaunchMode; - -// Based on https://github.com/quarkusio/quarkus/blob/2.16.7.Final/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/dependency/ConditionalDependenciesEnabler.java +// Based on +// https://github.com/quarkusio/quarkus/blob/2.16.7.Final/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/dependency/ConditionalDependenciesEnabler.java public class ConditionalDependenciesEnabler { - /** - * Links dependencies to extensions - */ + /** Links dependencies to extensions */ private final Map> featureVariants = new HashMap<>(); + /** * Despite its name, only contains extensions which have no conditional dependencies, or have * resolved their conditional dependencies. */ private final Map allExtensions = new HashMap<>(); + private final Project project; private final Configuration enforcedPlatforms; private final Set existingArtifacts = new HashSet<>(); private final List unsatisfiedConditionalDeps = new ArrayList<>(); - public ConditionalDependenciesEnabler(Project project, LaunchMode mode, - Configuration platforms) { + public ConditionalDependenciesEnabler(Project project, LaunchMode mode, Configuration platforms) { this.project = project; this.enforcedPlatforms = platforms; // Get runtimeClasspath (quarkusProdBaseRuntimeClasspathConfiguration to be exact) - Configuration baseRuntimeConfig = project.getConfigurations() - .getByName(ApplicationDeploymentClasspathBuilder.getBaseRuntimeConfigName(mode)); + Configuration baseRuntimeConfig = + project + .getConfigurations() + .getByName(ApplicationDeploymentClasspathBuilder.getBaseRuntimeConfigName(mode)); if (!baseRuntimeConfig.getIncoming().getDependencies().isEmpty()) { // Gather all extensions from the full resolved dependency tree - collectConditionalDependencies(baseRuntimeConfig.getResolvedConfiguration().getResolvedArtifacts()); + collectConditionalDependencies( + baseRuntimeConfig.getResolvedConfiguration().getResolvedArtifacts()); // If there are any extensions which had unresolved conditional dependencies: while (!unsatisfiedConditionalDeps.isEmpty()) { boolean satisfiedConditionalDeps = false; @@ -91,13 +92,13 @@ public ConditionalDependenciesEnabler(Project project, LaunchMode mode, } } // If we didn't resolve any dependencies and the graph did not evolve, give up. - if (!satisfiedConditionalDeps && unsatisfiedConditionalDeps.size() == originalUnsatisfiedCount) { + if (!satisfiedConditionalDeps + && unsatisfiedConditionalDeps.size() == originalUnsatisfiedCount) { break; } } reset(); } - } public Collection getAllExtensions() { @@ -132,8 +133,10 @@ private void collectConditionalDependencies(Set runtimeArtifac private boolean resolveConditionalDependency(Dependency conditionalDep) { - final Configuration conditionalDeps = createConditionalDependenciesConfiguration(project, conditionalDep); - Set resolvedArtifacts = conditionalDeps.getResolvedConfiguration().getResolvedArtifacts(); + final Configuration conditionalDeps = + createConditionalDependenciesConfiguration(project, conditionalDep); + Set resolvedArtifacts = + conditionalDeps.getResolvedConfiguration().getResolvedArtifacts(); boolean satisfied = false; // Resolved artifacts don't have great linking back to the original artifact, so I think @@ -144,10 +147,12 @@ private boolean resolveConditionalDependency(Dependency conditionalDep) { && conditionalDep.getVersion().equals(artifact.getModuleVersion().getId().getVersion()) && artifact.getModuleVersion().getId().getGroup().equals(conditionalDep.getGroup())) { // Once the dependency is found, reload the extension info from within - final ExtensionDependency extensionDependency = DependencyUtils.getExtensionInfoOrNull(project, artifact); + final ExtensionDependency extensionDependency = + DependencyUtils.getExtensionInfoOrNull(project, artifact); // Now check if this conditional dependency is resolved given the latest graph evolution - if (extensionDependency != null && (extensionDependency.getDependencyConditions().isEmpty() - || exist(extensionDependency.getDependencyConditions()))) { + if (extensionDependency != null + && (extensionDependency.getDependencyConditions().isEmpty() + || exist(extensionDependency.getDependencyConditions()))) { satisfied = true; enableConditionalDependency(extensionDependency.getExtensionId()); break; @@ -164,7 +169,8 @@ private boolean resolveConditionalDependency(Dependency conditionalDep) { for (ResolvedArtifact artifact : resolvedArtifacts) { // First add the artifact to the master list existingArtifacts.add(getKey(artifact)); - ExtensionDependency extensionDependency = DependencyUtils.getExtensionInfoOrNull(project, artifact); + ExtensionDependency extensionDependency = + DependencyUtils.getExtensionInfoOrNull(project, artifact); if (extensionDependency == null) { continue; } @@ -182,27 +188,40 @@ private boolean resolveConditionalDependency(Dependency conditionalDep) { return satisfied; } - private void queueConditionalDependency(ExtensionDependency extension, Dependency conditionalDep) { + private void queueConditionalDependency( + ExtensionDependency extension, Dependency conditionalDep) { // 1. Add to master list of unresolved/unsatisfied dependencies // 2. Add map entry to link dependency to extension - featureVariants.computeIfAbsent(getFeatureKey(conditionalDep), k -> { - unsatisfiedConditionalDeps.add(conditionalDep); - return new HashSet<>(); - }).add(extension); + featureVariants + .computeIfAbsent( + getFeatureKey(conditionalDep), + k -> { + unsatisfiedConditionalDeps.add(conditionalDep); + return new HashSet<>(); + }) + .add(extension); } - private Configuration createConditionalDependenciesConfiguration(Project project, Dependency conditionalDep) { + private Configuration createConditionalDependenciesConfiguration( + Project project, Dependency conditionalDep) { // Upstream uses .extendsFrom(enforcedPlatforms) but that does not work in our composite // build, so we manually copy exclude rules and dependencies instead Configuration conditionalDepConfiguration = project.getConfigurations().detachedConfiguration(); - enforcedPlatforms.getExcludeRules().forEach(rule -> { - conditionalDepConfiguration.exclude(Map.of( - "group", rule.getGroup(), - "module", rule.getModule())); - }); - enforcedPlatforms.getAllDependencies().forEach(dependency -> { - conditionalDepConfiguration.getDependencies().add(dependency); - }); + enforcedPlatforms + .getExcludeRules() + .forEach( + rule -> { + conditionalDepConfiguration.exclude( + Map.of( + "group", rule.getGroup(), + "module", rule.getModule())); + }); + enforcedPlatforms + .getAllDependencies() + .forEach( + dependency -> { + conditionalDepConfiguration.getDependencies().add(dependency); + }); conditionalDepConfiguration.getDependencies().add(conditionalDep); return conditionalDepConfiguration; } @@ -220,13 +239,13 @@ private boolean exist(List dependencies) { } private boolean exists(Dependency dependency) { - return existingArtifacts - .contains(ArtifactKey.of(dependency.getGroup(), dependency.getName(), null, ArtifactCoords.TYPE_JAR)); + return existingArtifacts.contains( + ArtifactKey.of(dependency.getGroup(), dependency.getName(), null, ArtifactCoords.TYPE_JAR)); } public boolean exists(ExtensionDependency dependency) { - return existingArtifacts - .contains(ArtifactKey.of(dependency.getGroup(), dependency.getName(), null, ArtifactCoords.TYPE_JAR)); + return existingArtifacts.contains( + ArtifactKey.of(dependency.getGroup(), dependency.getName(), null, ArtifactCoords.TYPE_JAR)); } private static GACT getFeatureKey(ModuleVersionIdentifier version) { @@ -238,6 +257,7 @@ private static GACT getFeatureKey(Dependency version) { } private static ArtifactKey getKey(ResolvedArtifact a) { - return ArtifactKey.of(a.getModuleVersion().getId().getGroup(), a.getName(), a.getClassifier(), a.getType()); + return ArtifactKey.of( + a.getModuleVersion().getId().getGroup(), a.getName(), a.getClassifier(), a.getType()); } } diff --git a/instrumentation/quarkus-resteasy-reactive/quarkus-common-plugin/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java b/instrumentation/quarkus-resteasy-reactive/quarkus-common-plugin/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java index aebc69b8b463..e44563fc602b 100644 --- a/instrumentation/quarkus-resteasy-reactive/quarkus-common-plugin/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java +++ b/instrumentation/quarkus-resteasy-reactive/quarkus-common-plugin/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java @@ -24,6 +24,34 @@ import static java.util.Objects.requireNonNull; +import io.quarkus.bootstrap.BootstrapConstants; +import io.quarkus.bootstrap.model.ApplicationModel; +import io.quarkus.bootstrap.model.ApplicationModelBuilder; +import io.quarkus.bootstrap.model.CapabilityContract; +import io.quarkus.bootstrap.model.PlatformImports; +import io.quarkus.bootstrap.model.gradle.ModelParameter; +import io.quarkus.bootstrap.model.gradle.impl.ModelParameterImpl; +import io.quarkus.bootstrap.workspace.ArtifactSources; +import io.quarkus.bootstrap.workspace.DefaultArtifactSources; +import io.quarkus.bootstrap.workspace.DefaultSourceDir; +import io.quarkus.bootstrap.workspace.DefaultWorkspaceModule; +import io.quarkus.bootstrap.workspace.SourceDir; +import io.quarkus.bootstrap.workspace.WorkspaceModule; +import io.quarkus.fs.util.ZipUtils; +import io.quarkus.gradle.dependency.ApplicationDeploymentClasspathBuilder; +import io.quarkus.maven.dependency.ArtifactCoords; +import io.quarkus.maven.dependency.ArtifactDependency; +import io.quarkus.maven.dependency.ArtifactKey; +import io.quarkus.maven.dependency.DependencyFlags; +import io.quarkus.maven.dependency.GACT; +import io.quarkus.maven.dependency.GACTV; +import io.quarkus.maven.dependency.GAV; +import io.quarkus.maven.dependency.ResolvedDependency; +import io.quarkus.maven.dependency.ResolvedDependencyBuilder; +import io.quarkus.paths.PathCollection; +import io.quarkus.paths.PathList; +import io.quarkus.runtime.LaunchMode; +import io.quarkus.runtime.util.HashUtil; import java.io.BufferedReader; import java.io.File; import java.io.IOException; @@ -38,10 +66,8 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.Properties; import java.util.Set; - import org.gradle.api.Project; import org.gradle.api.artifacts.Configuration; import org.gradle.api.artifacts.ResolvableDependencies; @@ -60,45 +86,19 @@ import org.gradle.language.jvm.tasks.ProcessResources; import org.gradle.tooling.provider.model.ParameterizedToolingModelBuilder; -import io.quarkus.bootstrap.BootstrapConstants; -import io.quarkus.bootstrap.model.ApplicationModel; -import io.quarkus.bootstrap.model.ApplicationModelBuilder; -import io.quarkus.bootstrap.model.CapabilityContract; -import io.quarkus.bootstrap.model.PlatformImports; -import io.quarkus.bootstrap.model.gradle.ModelParameter; -import io.quarkus.bootstrap.model.gradle.impl.ModelParameterImpl; -import io.quarkus.bootstrap.workspace.ArtifactSources; -import io.quarkus.bootstrap.workspace.DefaultArtifactSources; -import io.quarkus.bootstrap.workspace.DefaultSourceDir; -import io.quarkus.bootstrap.workspace.DefaultWorkspaceModule; -import io.quarkus.bootstrap.workspace.SourceDir; -import io.quarkus.bootstrap.workspace.WorkspaceModule; -import io.quarkus.fs.util.ZipUtils; -import io.quarkus.gradle.dependency.ApplicationDeploymentClasspathBuilder; -import io.quarkus.maven.dependency.ArtifactCoords; -import io.quarkus.maven.dependency.ArtifactDependency; -import io.quarkus.maven.dependency.ArtifactKey; -import io.quarkus.maven.dependency.DependencyFlags; -import io.quarkus.maven.dependency.GACT; -import io.quarkus.maven.dependency.GACTV; -import io.quarkus.maven.dependency.GAV; -import io.quarkus.maven.dependency.ResolvedDependency; -import io.quarkus.maven.dependency.ResolvedDependencyBuilder; -import io.quarkus.paths.PathCollection; -import io.quarkus.paths.PathList; -import io.quarkus.runtime.LaunchMode; -import io.quarkus.runtime.util.HashUtil; - -// Based on https://github.com/quarkusio/quarkus/blob/2.16.7.Final/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java -public class GradleApplicationModelBuilder implements ParameterizedToolingModelBuilder { +// Based on +// https://github.com/quarkusio/quarkus/blob/2.16.7.Final/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java +public class GradleApplicationModelBuilder + implements ParameterizedToolingModelBuilder { private static final String MAIN_RESOURCES_OUTPUT = "build/resources/main"; private static final String CLASSES_OUTPUT = "build/classes"; /* @formatter:off */ private static final byte COLLECT_TOP_EXTENSION_RUNTIME_NODES = 0b001; - private static final byte COLLECT_DIRECT_DEPS = 0b010; - private static final byte COLLECT_RELOADABLE_MODULES = 0b100; + private static final byte COLLECT_DIRECT_DEPS = 0b010; + private static final byte COLLECT_RELOADABLE_MODULES = 0b100; + /* @formatter:on */ @Override @@ -122,74 +122,105 @@ public Object buildAll(String modelName, Project project) { public Object buildAll(String modelName, ModelParameter parameter, Project project) { final LaunchMode mode = LaunchMode.valueOf(parameter.getMode()); - final ApplicationDeploymentClasspathBuilder classpathBuilder = new ApplicationDeploymentClasspathBuilder(project, - mode); + final ApplicationDeploymentClasspathBuilder classpathBuilder = + new ApplicationDeploymentClasspathBuilder(project, mode); final Configuration classpathConfig = classpathBuilder.getRuntimeConfiguration(); final Configuration deploymentConfig = classpathBuilder.getDeploymentConfiguration(); final PlatformImports platformImports = classpathBuilder.getPlatformImports(); - boolean workspaceDiscovery = LaunchMode.DEVELOPMENT.equals(mode) || LaunchMode.TEST.equals(mode) - || Boolean.parseBoolean(System.getProperty(BootstrapConstants.QUARKUS_BOOTSTRAP_WORKSPACE_DISCOVERY)); + boolean workspaceDiscovery = + LaunchMode.DEVELOPMENT.equals(mode) + || LaunchMode.TEST.equals(mode) + || Boolean.parseBoolean( + System.getProperty(BootstrapConstants.QUARKUS_BOOTSTRAP_WORKSPACE_DISCOVERY)); if (!workspaceDiscovery) { - Object o = project.getProperties().get(BootstrapConstants.QUARKUS_BOOTSTRAP_WORKSPACE_DISCOVERY); + Object o = + project.getProperties().get(BootstrapConstants.QUARKUS_BOOTSTRAP_WORKSPACE_DISCOVERY); if (o != null) { workspaceDiscovery = Boolean.parseBoolean(o.toString()); } } final ResolvedDependency appArtifact = getProjectArtifact(project, workspaceDiscovery); - final ApplicationModelBuilder modelBuilder = new ApplicationModelBuilder() - .setAppArtifact(appArtifact) - .addReloadableWorkspaceModule(appArtifact.getKey()) - .setPlatformImports(platformImports); - - collectDependencies(classpathConfig.getResolvedConfiguration(), classpathConfig.getIncoming(), workspaceDiscovery, - project, modelBuilder, appArtifact.getWorkspaceModule().mutable()); + final ApplicationModelBuilder modelBuilder = + new ApplicationModelBuilder() + .setAppArtifact(appArtifact) + .addReloadableWorkspaceModule(appArtifact.getKey()) + .setPlatformImports(platformImports); + + collectDependencies( + classpathConfig.getResolvedConfiguration(), + classpathConfig.getIncoming(), + workspaceDiscovery, + project, + modelBuilder, + appArtifact.getWorkspaceModule().mutable()); collectExtensionDependencies(project, deploymentConfig, modelBuilder); return modelBuilder.build(); } public static ResolvedDependency getProjectArtifact(Project project, boolean workspaceDiscovery) { - final ResolvedDependencyBuilder appArtifact = ResolvedDependencyBuilder.newInstance() - .setGroupId(project.getGroup().toString()) - .setArtifactId(project.getName()) - .setVersion(project.getVersion().toString()); - - final SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); - final WorkspaceModule.Mutable mainModule = WorkspaceModule.builder() - .setModuleId(new GAV(appArtifact.getGroupId(), appArtifact.getArtifactId(), appArtifact.getVersion())) - .setModuleDir(project.getProjectDir().toPath()) - .setBuildDir(project.getBuildDir().toPath()) - .setBuildFile(project.getBuildFile().toPath()); - - initProjectModule(project, mainModule, sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME), ArtifactSources.MAIN); + final ResolvedDependencyBuilder appArtifact = + ResolvedDependencyBuilder.newInstance() + .setGroupId(project.getGroup().toString()) + .setArtifactId(project.getName()) + .setVersion(project.getVersion().toString()); + + final SourceSetContainer sourceSets = + project.getExtensions().getByType(SourceSetContainer.class); + final WorkspaceModule.Mutable mainModule = + WorkspaceModule.builder() + .setModuleId( + new GAV( + appArtifact.getGroupId(), + appArtifact.getArtifactId(), + appArtifact.getVersion())) + .setModuleDir(project.getProjectDir().toPath()) + .setBuildDir(project.getBuildDir().toPath()) + .setBuildFile(project.getBuildFile().toPath()); + + initProjectModule( + project, + mainModule, + sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME), + ArtifactSources.MAIN); if (workspaceDiscovery) { final TaskCollection testTasks = project.getTasks().withType(Test.class); if (!testTasks.isEmpty()) { final Map sourceSetsByClassesDir = new HashMap<>(); - sourceSets.forEach(s -> { - s.getOutput().getClassesDirs().forEach(d -> { - if (d.exists()) { - sourceSetsByClassesDir.put(d, s); - } - }); - }); - testTasks.forEach(t -> { - if (t.getEnabled()) { - t.getTestClassesDirs().forEach(d -> { - if (d.exists()) { - final SourceSet sourceSet = sourceSetsByClassesDir.remove(d); - if (sourceSet != null) { - initProjectModule(project, mainModule, sourceSet, - sourceSet.getName().equals(SourceSet.TEST_SOURCE_SET_NAME) - ? ArtifactSources.TEST - : sourceSet.getName()); - } + sourceSets.forEach( + s -> { + s.getOutput() + .getClassesDirs() + .forEach( + d -> { + if (d.exists()) { + sourceSetsByClassesDir.put(d, s); + } + }); + }); + testTasks.forEach( + t -> { + if (t.getEnabled()) { + t.getTestClassesDirs() + .forEach( + d -> { + if (d.exists()) { + final SourceSet sourceSet = sourceSetsByClassesDir.remove(d); + if (sourceSet != null) { + initProjectModule( + project, + mainModule, + sourceSet, + sourceSet.getName().equals(SourceSet.TEST_SOURCE_SET_NAME) + ? ArtifactSources.TEST + : sourceSet.getName()); + } + } + }); } }); - } - }); } } @@ -200,7 +231,8 @@ public static ResolvedDependency getProjectArtifact(Project project, boolean wor return appArtifact.setWorkspaceModule(mainModule).setResolvedPaths(paths.build()).build(); } - private static void collectDestinationDirs(Collection sources, final PathList.Builder paths) { + private static void collectDestinationDirs( + Collection sources, final PathList.Builder paths) { for (SourceDir src : sources) { final Path path = src.getOutputDir(); if (paths.contains(path) || !Files.exists(path)) { @@ -210,27 +242,35 @@ private static void collectDestinationDirs(Collection sources, final } } - private void collectExtensionDependencies(Project project, Configuration deploymentConfiguration, + private void collectExtensionDependencies( + Project project, + Configuration deploymentConfiguration, ApplicationModelBuilder modelBuilder) { final ResolvedConfiguration rc = deploymentConfiguration.getResolvedConfiguration(); for (ResolvedArtifact a : rc.getResolvedArtifacts()) { if (a.getId().getComponentIdentifier() instanceof ProjectComponentIdentifier) { - ProjectComponentIdentifier projectComponentIdentifier = (ProjectComponentIdentifier) a.getId() - .getComponentIdentifier(); + ProjectComponentIdentifier projectComponentIdentifier = + (ProjectComponentIdentifier) a.getId().getComponentIdentifier(); var includedBuild = ToolingUtils.includedBuild(project, projectComponentIdentifier); Project projectDep = null; if (includedBuild != null) { - projectDep = ToolingUtils.includedBuildProject((IncludedBuildInternal) includedBuild, - projectComponentIdentifier); + projectDep = + ToolingUtils.includedBuildProject( + (IncludedBuildInternal) includedBuild, projectComponentIdentifier); } else { - projectDep = project.getRootProject().findProject(projectComponentIdentifier.getProjectPath()); + projectDep = + project.getRootProject().findProject(projectComponentIdentifier.getProjectPath()); } - requireNonNull(projectDep, "project " + projectComponentIdentifier.getProjectPath() + " should exist"); - SourceSetContainer sourceSets = projectDep.getExtensions().getByType(SourceSetContainer.class); + requireNonNull( + projectDep, "project " + projectComponentIdentifier.getProjectPath() + " should exist"); + SourceSetContainer sourceSets = + projectDep.getExtensions().getByType(SourceSetContainer.class); SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME); - ResolvedDependencyBuilder dep = modelBuilder.getDependency( - toAppDependenciesKey(a.getModuleVersion().getId().getGroup(), a.getName(), a.getClassifier())); + ResolvedDependencyBuilder dep = + modelBuilder.getDependency( + toAppDependenciesKey( + a.getModuleVersion().getId().getGroup(), a.getName(), a.getClassifier())); if (dep == null) { dep = toDependency(a, mainSourceSet); modelBuilder.addDependency(dep); @@ -238,8 +278,10 @@ private void collectExtensionDependencies(Project project, Configuration deploym dep.setDeploymentCp(); dep.clearFlag(DependencyFlags.RELOADABLE); } else if (isDependency(a)) { - ResolvedDependencyBuilder dep = modelBuilder.getDependency( - toAppDependenciesKey(a.getModuleVersion().getId().getGroup(), a.getName(), a.getClassifier())); + ResolvedDependencyBuilder dep = + modelBuilder.getDependency( + toAppDependenciesKey( + a.getModuleVersion().getId().getGroup(), a.getName(), a.getClassifier())); if (dep == null) { dep = toDependency(a); modelBuilder.addDependency(dep); @@ -250,8 +292,12 @@ private void collectExtensionDependencies(Project project, Configuration deploym } } - private void collectDependencies(ResolvedConfiguration configuration, ResolvableDependencies dependencies, - boolean workspaceDiscovery, Project project, ApplicationModelBuilder modelBuilder, + private void collectDependencies( + ResolvedConfiguration configuration, + ResolvableDependencies dependencies, + boolean workspaceDiscovery, + Project project, + ApplicationModelBuilder modelBuilder, WorkspaceModule.Mutable wsModule) { final Set resolvedArtifacts = configuration.getResolvedArtifacts(); @@ -259,17 +305,28 @@ private void collectDependencies(ResolvedConfiguration configuration, Resolvable // the project includes direct file dependencies // Upstream uses configuration.getFiles(); replaced with dependencies.getFiles().getFiles() // since ResolvedConfiguration.getFiles() was removed in Gradle 9 - final Set artifactFiles = resolvedArtifacts.size() < dependencies.getFiles().getFiles().size() - ? new HashSet<>(resolvedArtifacts.size()) - : null; - - configuration.getFirstLevelModuleDependencies() - .forEach(d -> { - collectDependencies(d, workspaceDiscovery, project, artifactFiles, new HashSet<>(), - modelBuilder, - wsModule, - (byte) (COLLECT_TOP_EXTENSION_RUNTIME_NODES | COLLECT_DIRECT_DEPS | COLLECT_RELOADABLE_MODULES)); - }); + final Set artifactFiles = + resolvedArtifacts.size() < dependencies.getFiles().getFiles().size() + ? new HashSet<>(resolvedArtifacts.size()) + : null; + + configuration + .getFirstLevelModuleDependencies() + .forEach( + d -> { + collectDependencies( + d, + workspaceDiscovery, + project, + artifactFiles, + new HashSet<>(), + modelBuilder, + wsModule, + (byte) + (COLLECT_TOP_EXTENSION_RUNTIME_NODES + | COLLECT_DIRECT_DEPS + | COLLECT_RELOADABLE_MODULES)); + }); if (artifactFiles != null) { // detect FS paths that aren't provided by the resolved artifacts @@ -294,35 +351,41 @@ private void collectDependencies(ResolvedConfiguration configuration, Resolvable } // hash could be a better way to represent the version final String version = String.valueOf(f.lastModified()); - final ResolvedDependencyBuilder artifactBuilder = ResolvedDependencyBuilder.newInstance() - .setGroupId(group) - .setArtifactId(name) - .setType(type) - .setVersion(version) - .setResolvedPath(f.toPath()) - .setDirect(true) - .setRuntimeCp(); + final ResolvedDependencyBuilder artifactBuilder = + ResolvedDependencyBuilder.newInstance() + .setGroupId(group) + .setArtifactId(name) + .setType(type) + .setVersion(version) + .setResolvedPath(f.toPath()) + .setDirect(true) + .setRuntimeCp(); processQuarkusDependency(artifactBuilder, modelBuilder); modelBuilder.addDependency(artifactBuilder); } } } - private void collectDependencies(org.gradle.api.artifacts.ResolvedDependency resolvedDep, boolean workspaceDiscovery, - Project project, Set artifactFiles, Set processedModules, ApplicationModelBuilder modelBuilder, + private void collectDependencies( + org.gradle.api.artifacts.ResolvedDependency resolvedDep, + boolean workspaceDiscovery, + Project project, + Set artifactFiles, + Set processedModules, + ApplicationModelBuilder modelBuilder, WorkspaceModule.Mutable parentModule, byte flags) { WorkspaceModule.Mutable projectModule = null; for (ResolvedArtifact a : resolvedDep.getModuleArtifacts()) { - final ArtifactKey artifactKey = toAppDependenciesKey(a.getModuleVersion().getId().getGroup(), a.getName(), - a.getClassifier()); + final ArtifactKey artifactKey = + toAppDependenciesKey( + a.getModuleVersion().getId().getGroup(), a.getName(), a.getClassifier()); if (!isDependency(a) || modelBuilder.getDependency(artifactKey) != null) { continue; } final ArtifactCoords depCoords = toArtifactCoords(a); - final ResolvedDependencyBuilder depBuilder = ResolvedDependencyBuilder.newInstance() - .setCoords(depCoords) - .setRuntimeCp(); + final ResolvedDependencyBuilder depBuilder = + ResolvedDependencyBuilder.newInstance().setCoords(depCoords).setRuntimeCp(); if (isFlagOn(flags, COLLECT_DIRECT_DEPS)) { depBuilder.setDirect(true); flags = clearFlag(flags, COLLECT_DIRECT_DEPS); @@ -332,27 +395,45 @@ private void collectDependencies(org.gradle.api.artifacts.ResolvedDependency res } PathCollection paths = null; - if (workspaceDiscovery && a.getId().getComponentIdentifier() instanceof ProjectComponentIdentifier) { - - Project projectDep = project.getRootProject().findProject( - ((ProjectComponentIdentifier) a.getId().getComponentIdentifier()).getProjectPath()); - SourceSetContainer sourceSets = projectDep == null ? null - : projectDep.getExtensions().findByType(SourceSetContainer.class); + if (workspaceDiscovery + && a.getId().getComponentIdentifier() instanceof ProjectComponentIdentifier) { + + Project projectDep = + project + .getRootProject() + .findProject( + ((ProjectComponentIdentifier) a.getId().getComponentIdentifier()) + .getProjectPath()); + SourceSetContainer sourceSets = + projectDep == null + ? null + : projectDep.getExtensions().findByType(SourceSetContainer.class); final String classifier = a.getClassifier(); if (classifier == null || classifier.isEmpty()) { - final IncludedBuild includedBuild = ToolingUtils.includedBuild(project.getRootProject(), - (ProjectComponentIdentifier) a.getId().getComponentIdentifier()); + final IncludedBuild includedBuild = + ToolingUtils.includedBuild( + project.getRootProject(), + (ProjectComponentIdentifier) a.getId().getComponentIdentifier()); if (includedBuild != null) { final PathList.Builder pathBuilder = PathList.builder(); if (includedBuild instanceof IncludedBuildInternal) { - projectDep = ToolingUtils.includedBuildProject((IncludedBuildInternal) includedBuild, - (ProjectComponentIdentifier) a.getId().getComponentIdentifier()); + projectDep = + ToolingUtils.includedBuildProject( + (IncludedBuildInternal) includedBuild, + (ProjectComponentIdentifier) a.getId().getComponentIdentifier()); } if (projectDep != null) { - projectModule = initProjectModuleAndBuildPaths(projectDep, a, modelBuilder, depBuilder, - pathBuilder, SourceSet.MAIN_SOURCE_SET_NAME, false); + projectModule = + initProjectModuleAndBuildPaths( + projectDep, + a, + modelBuilder, + depBuilder, + pathBuilder, + SourceSet.MAIN_SOURCE_SET_NAME, + false); addSubstitutedProject(pathBuilder, projectDep.getProjectDir()); } else { addSubstitutedProject(pathBuilder, includedBuild.getProjectDir()); @@ -360,26 +441,42 @@ private void collectDependencies(org.gradle.api.artifacts.ResolvedDependency res paths = pathBuilder.build(); } else if (sourceSets != null) { final PathList.Builder pathBuilder = PathList.builder(); - projectModule = initProjectModuleAndBuildPaths(projectDep, a, modelBuilder, depBuilder, - pathBuilder, SourceSet.MAIN_SOURCE_SET_NAME, false); + projectModule = + initProjectModuleAndBuildPaths( + projectDep, + a, + modelBuilder, + depBuilder, + pathBuilder, + SourceSet.MAIN_SOURCE_SET_NAME, + false); paths = pathBuilder.build(); } } else if (sourceSets != null) { if (SourceSet.TEST_SOURCE_SET_NAME.equals(classifier)) { final PathList.Builder pathBuilder = PathList.builder(); - projectModule = initProjectModuleAndBuildPaths(projectDep, a, modelBuilder, depBuilder, - pathBuilder, SourceSet.TEST_SOURCE_SET_NAME, true); + projectModule = + initProjectModuleAndBuildPaths( + projectDep, + a, + modelBuilder, + depBuilder, + pathBuilder, + SourceSet.TEST_SOURCE_SET_NAME, + true); paths = pathBuilder.build(); } else if ("test-fixtures".equals(classifier)) { final PathList.Builder pathBuilder = PathList.builder(); - projectModule = initProjectModuleAndBuildPaths(projectDep, a, modelBuilder, depBuilder, - pathBuilder, "testFixtures", true); + projectModule = + initProjectModuleAndBuildPaths( + projectDep, a, modelBuilder, depBuilder, pathBuilder, "testFixtures", true); paths = pathBuilder.build(); } } } - depBuilder.setResolvedPaths(paths == null ? PathList.of(a.getFile().toPath()) : paths) + depBuilder + .setResolvedPaths(paths == null ? PathList.of(a.getFile().toPath()) : paths) .setWorkspaceModule(projectModule); if (processQuarkusDependency(depBuilder, modelBuilder)) { if (isFlagOn(flags, COLLECT_TOP_EXTENSION_RUNTIME_NODES)) { @@ -401,8 +498,15 @@ private void collectDependencies(org.gradle.api.artifacts.ResolvedDependency res processedModules.add(ArtifactKey.ga(resolvedDep.getModuleGroup(), resolvedDep.getModuleName())); for (org.gradle.api.artifacts.ResolvedDependency child : resolvedDep.getChildren()) { if (!processedModules.contains(new GACT(child.getModuleGroup(), child.getModuleName()))) { - collectDependencies(child, workspaceDiscovery, project, artifactFiles, processedModules, - modelBuilder, projectModule, flags); + collectDependencies( + child, + workspaceDiscovery, + project, + artifactFiles, + processedModules, + modelBuilder, + projectModule, + flags); } } } @@ -411,18 +515,27 @@ private static String toNonNullClassifier(String resolvedClassifier) { return resolvedClassifier == null ? ArtifactCoords.DEFAULT_CLASSIFIER : resolvedClassifier; } - private WorkspaceModule.Mutable initProjectModuleAndBuildPaths(final Project project, - ResolvedArtifact resolvedArtifact, ApplicationModelBuilder appModel, final ResolvedDependencyBuilder appDep, - PathList.Builder buildPaths, String sourceName, boolean test) { + private WorkspaceModule.Mutable initProjectModuleAndBuildPaths( + final Project project, + ResolvedArtifact resolvedArtifact, + ApplicationModelBuilder appModel, + final ResolvedDependencyBuilder appDep, + PathList.Builder buildPaths, + String sourceName, + boolean test) { appDep.setWorkspaceModule().setReloadable(); - final WorkspaceModule.Mutable projectModule = appModel.getOrCreateProjectModule( - new GAV(resolvedArtifact.getModuleVersion().getId().getGroup(), resolvedArtifact.getName(), - resolvedArtifact.getModuleVersion().getId().getVersion()), - project.getProjectDir(), - project.getBuildDir()) - .setBuildFile(project.getBuildFile().toPath()); + final WorkspaceModule.Mutable projectModule = + appModel + .getOrCreateProjectModule( + new GAV( + resolvedArtifact.getModuleVersion().getId().getGroup(), + resolvedArtifact.getName(), + resolvedArtifact.getModuleVersion().getId().getVersion()), + project.getProjectDir(), + project.getBuildDir()) + .setBuildFile(project.getBuildFile().toPath()); final String classifier = toNonNullClassifier(resolvedArtifact.getClassifier()); SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); @@ -432,21 +545,28 @@ private WorkspaceModule.Mutable initProjectModuleAndBuildPaths(final Project pro collectDestinationDirs(projectModule.getSources(classifier).getResourceDirs(), buildPaths); appModel.addReloadableWorkspaceModule( - ArtifactKey.of(resolvedArtifact.getModuleVersion().getId().getGroup(), resolvedArtifact.getName(), classifier, + ArtifactKey.of( + resolvedArtifact.getModuleVersion().getId().getGroup(), + resolvedArtifact.getName(), + classifier, ArtifactCoords.TYPE_JAR)); return projectModule; } - private boolean processQuarkusDependency(ResolvedDependencyBuilder artifactBuilder, ApplicationModelBuilder modelBuilder) { + private boolean processQuarkusDependency( + ResolvedDependencyBuilder artifactBuilder, ApplicationModelBuilder modelBuilder) { for (Path artifactPath : artifactBuilder.getResolvedPaths()) { - if (!Files.exists(artifactPath) || !artifactBuilder.getType().equals(ArtifactCoords.TYPE_JAR)) { + if (!Files.exists(artifactPath) + || !artifactBuilder.getType().equals(ArtifactCoords.TYPE_JAR)) { break; } if (Files.isDirectory(artifactPath)) { - return processQuarkusDir(artifactBuilder, artifactPath.resolve(BootstrapConstants.META_INF), modelBuilder); + return processQuarkusDir( + artifactBuilder, artifactPath.resolve(BootstrapConstants.META_INF), modelBuilder); } else { try (FileSystem artifactFs = ZipUtils.newFileSystem(artifactPath)) { - return processQuarkusDir(artifactBuilder, artifactFs.getPath(BootstrapConstants.META_INF), modelBuilder); + return processQuarkusDir( + artifactBuilder, artifactFs.getPath(BootstrapConstants.META_INF), modelBuilder); } catch (IOException e) { throw new RuntimeException("Failed to process " + artifactPath, e); } @@ -455,7 +575,9 @@ private boolean processQuarkusDependency(ResolvedDependencyBuilder artifactBuild return false; } - private static boolean processQuarkusDir(ResolvedDependencyBuilder artifactBuilder, Path quarkusDir, + private static boolean processQuarkusDir( + ResolvedDependencyBuilder artifactBuilder, + Path quarkusDir, ApplicationModelBuilder modelBuilder) { if (!Files.exists(quarkusDir)) { return false; @@ -472,10 +594,11 @@ private static boolean processQuarkusDir(ResolvedDependencyBuilder artifactBuild final String extensionCoords = artifactBuilder.toGACTVString(); modelBuilder.handleExtensionProperties(extProps, extensionCoords); - final String providesCapabilities = extProps.getProperty(BootstrapConstants.PROP_PROVIDES_CAPABILITIES); + final String providesCapabilities = + extProps.getProperty(BootstrapConstants.PROP_PROVIDES_CAPABILITIES); if (providesCapabilities != null) { - modelBuilder - .addExtensionCapabilities(CapabilityContract.of(extensionCoords, providesCapabilities, null)); + modelBuilder.addExtensionCapabilities( + CapabilityContract.of(extensionCoords, providesCapabilities, null)); } return true; } @@ -495,67 +618,84 @@ private static Properties readDescriptor(final Path path) { return rtProps; } - private static void initProjectModule(Project project, WorkspaceModule.Mutable module, SourceSet sourceSet, - String classifier) { + private static void initProjectModule( + Project project, WorkspaceModule.Mutable module, SourceSet sourceSet, String classifier) { if (sourceSet == null) { return; } final FileCollection allClassesDirs = sourceSet.getOutput().getClassesDirs(); - // some plugins do not add source directories to source sets and they may be missing from sourceSet.getAllJava() + // some plugins do not add source directories to source sets and they may be missing from + // sourceSet.getAllJava() // see https://github.com/quarkusio/quarkus/issues/20755 final List sourceDirs = new ArrayList<>(1); - project.getTasks().withType(AbstractCompile.class, t -> { - if (!t.getEnabled()) { - return; - } - final FileTree source = t.getSource(); - if (source.isEmpty()) { - return; - } - final File destDir = t.getDestinationDirectory().getAsFile().get(); - if (!allClassesDirs.contains(destDir)) { - return; - } - source.visit(a -> { - // we are looking for the root dirs containing sources - if (a.getRelativePath().getSegments().length == 1) { - final File srcDir = a.getFile().getParentFile(); - sourceDirs.add(new DefaultSourceDir(srcDir.toPath(), destDir.toPath(), Map.of("compiler", t.getName()))); - } - }); - }); + project + .getTasks() + .withType( + AbstractCompile.class, + t -> { + if (!t.getEnabled()) { + return; + } + final FileTree source = t.getSource(); + if (source.isEmpty()) { + return; + } + final File destDir = t.getDestinationDirectory().getAsFile().get(); + if (!allClassesDirs.contains(destDir)) { + return; + } + source.visit( + a -> { + // we are looking for the root dirs containing sources + if (a.getRelativePath().getSegments().length == 1) { + final File srcDir = a.getFile().getParentFile(); + sourceDirs.add( + new DefaultSourceDir( + srcDir.toPath(), destDir.toPath(), Map.of("compiler", t.getName()))); + } + }); + }); // Upstream calls maybeConfigureKotlinJvmCompile() here; removed to avoid adding a // compile-time dependency on kotlin-gradle-plugin-api final LinkedHashMap resourceDirs = new LinkedHashMap<>(1); final File resourcesOutputDir = sourceSet.getOutput().getResourcesDir(); - project.getTasks().withType(ProcessResources.class, t -> { - if (!t.getEnabled()) { - return; - } - final FileCollection source = t.getSource(); - if (source.isEmpty()) { - return; - } - if (!t.getDestinationDir().equals(resourcesOutputDir)) { - return; - } - final Path destDir = t.getDestinationDir().toPath(); - source.getAsFileTree().visit(a -> { - // we are looking for the root dirs containing sources - if (a.getRelativePath().getSegments().length == 1) { - final File srcDir = a.getFile().getParentFile(); - resourceDirs.put(srcDir, destDir); - } - }); - }); + project + .getTasks() + .withType( + ProcessResources.class, + t -> { + if (!t.getEnabled()) { + return; + } + final FileCollection source = t.getSource(); + if (source.isEmpty()) { + return; + } + if (!t.getDestinationDir().equals(resourcesOutputDir)) { + return; + } + final Path destDir = t.getDestinationDir().toPath(); + source + .getAsFileTree() + .visit( + a -> { + // we are looking for the root dirs containing sources + if (a.getRelativePath().getSegments().length == 1) { + final File srcDir = a.getFile().getParentFile(); + resourceDirs.put(srcDir, destDir); + } + }); + }); // there could be a task generating resources if (resourcesOutputDir.exists() && resourceDirs.isEmpty()) { - sourceSet.getResources().getSrcDirs() + sourceSet + .getResources() + .getSrcDirs() .forEach(srcDir -> resourceDirs.put(srcDir, resourcesOutputDir.toPath())); } final List resources = new ArrayList<>(resourceDirs.size()); @@ -576,7 +716,8 @@ private void addSubstitutedProject(PathList.Builder paths, File projectFile) { for (File languageDirectory : languageDirectories) { if (languageDirectory.isDirectory()) { for (File sourceSet : languageDirectory.listFiles()) { - if (sourceSet.isDirectory() && sourceSet.getName().equals(SourceSet.MAIN_SOURCE_SET_NAME)) { + if (sourceSet.isDirectory() + && sourceSet.getName().equals(SourceSet.MAIN_SOURCE_SET_NAME)) { paths.add(sourceSet.toPath()); } } @@ -597,13 +738,12 @@ private static byte clearFlag(byte flags, byte flag) { } private static boolean isDependency(ResolvedArtifact a) { - return ArtifactCoords.TYPE_JAR.equalsIgnoreCase(a.getExtension()) || "exe".equalsIgnoreCase(a.getExtension()) || - a.getFile().isDirectory(); + return ArtifactCoords.TYPE_JAR.equalsIgnoreCase(a.getExtension()) + || "exe".equalsIgnoreCase(a.getExtension()) + || a.getFile().isDirectory(); } - /** - * Creates an instance of Dependency and associates it with the ResolvedArtifact's path - */ + /** Creates an instance of Dependency and associates it with the ResolvedArtifact's path */ static ResolvedDependencyBuilder toDependency(ResolvedArtifact a, int... flags) { return toDependency(a, PathList.of(a.getFile().toPath()), null, flags); } @@ -621,14 +761,13 @@ static ResolvedDependencyBuilder toDependency(ResolvedArtifact a, SourceSet s) { resolvedPathBuilder.add(resourceDir.toPath()); } - return ResolvedDependencyBuilder - .newInstance() + return ResolvedDependencyBuilder.newInstance() .setResolvedPaths(resolvedPathBuilder.build()) .setCoords(toArtifactCoords(a)); } - static ResolvedDependencyBuilder toDependency(ResolvedArtifact a, PathCollection paths, DefaultWorkspaceModule module, - int... flags) { + static ResolvedDependencyBuilder toDependency( + ResolvedArtifact a, PathCollection paths, DefaultWorkspaceModule module, int... flags) { int allFlags = 0; for (int f : flags) { allFlags |= f; @@ -642,10 +781,12 @@ static ResolvedDependencyBuilder toDependency(ResolvedArtifact a, PathCollection private static ArtifactCoords toArtifactCoords(ResolvedArtifact a) { final String[] split = a.getModuleVersion().toString().split(":"); - return new GACTV(split[0], split[1], a.getClassifier(), a.getType(), split.length > 2 ? split[2] : null); + return new GACTV( + split[0], split[1], a.getClassifier(), a.getType(), split.length > 2 ? split[2] : null); } - private static ArtifactKey toAppDependenciesKey(String groupId, String artifactId, String classifier) { + private static ArtifactKey toAppDependenciesKey( + String groupId, String artifactId, String classifier) { return new GACT(groupId, artifactId, classifier, ArtifactCoords.TYPE_JAR); } } diff --git a/instrumentation/quarkus-resteasy-reactive/quarkus-common-plugin/src/main/java/io/quarkus/gradle/tooling/ToolingUtils.java b/instrumentation/quarkus-resteasy-reactive/quarkus-common-plugin/src/main/java/io/quarkus/gradle/tooling/ToolingUtils.java index ea2c9109876f..1ef766363da1 100644 --- a/instrumentation/quarkus-resteasy-reactive/quarkus-common-plugin/src/main/java/io/quarkus/gradle/tooling/ToolingUtils.java +++ b/instrumentation/quarkus-resteasy-reactive/quarkus-common-plugin/src/main/java/io/quarkus/gradle/tooling/ToolingUtils.java @@ -22,11 +22,14 @@ package io.quarkus.gradle.tooling; +import io.quarkus.bootstrap.model.ApplicationModel; +import io.quarkus.bootstrap.model.gradle.ModelParameter; +import io.quarkus.bootstrap.model.gradle.impl.ModelParameterImpl; +import io.quarkus.runtime.LaunchMode; import java.io.IOException; import java.io.ObjectOutputStream; import java.nio.file.Files; import java.nio.file.Path; - import org.gradle.api.Project; import org.gradle.api.Task; import org.gradle.api.artifacts.ModuleDependency; @@ -35,12 +38,8 @@ import org.gradle.api.initialization.IncludedBuild; import org.gradle.internal.composite.IncludedBuildInternal; -import io.quarkus.bootstrap.model.ApplicationModel; -import io.quarkus.bootstrap.model.gradle.ModelParameter; -import io.quarkus.bootstrap.model.gradle.impl.ModelParameterImpl; -import io.quarkus.runtime.LaunchMode; - -// Based on https://github.com/quarkusio/quarkus/blob/2.16.7.Final/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/ToolingUtils.java +// Based on +// https://github.com/quarkusio/quarkus/blob/2.16.7.Final/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/ToolingUtils.java public class ToolingUtils { private static final String DEPLOYMENT_CONFIGURATION_SUFFIX = "Deployment"; @@ -57,31 +56,43 @@ public static String toPlatformConfigurationName(String baseConfigurationName) { public static boolean isEnforcedPlatform(ModuleDependency module) { final Category category = module.getAttributes().getAttribute(Category.CATEGORY_ATTRIBUTE); - return category != null && (Category.ENFORCED_PLATFORM.equals(category.getName()) - || Category.REGULAR_PLATFORM.equals(category.getName())); + return category != null + && (Category.ENFORCED_PLATFORM.equals(category.getName()) + || Category.REGULAR_PLATFORM.equals(category.getName())); } - public static IncludedBuild includedBuild(final Project project, - final ProjectComponentIdentifier projectComponentIdentifier) { + public static IncludedBuild includedBuild( + final Project project, final ProjectComponentIdentifier projectComponentIdentifier) { // Upstream uses getBuild().getName(); getBuildPath() is needed for our composite build final String buildPath = projectComponentIdentifier.getBuild().getBuildPath(); for (IncludedBuild ib : project.getRootProject().getGradle().getIncludedBuilds()) { - if (((IncludedBuildInternal) ib).getTarget().getBuildIdentifier().getBuildPath().equals(buildPath)) { + if (((IncludedBuildInternal) ib) + .getTarget() + .getBuildIdentifier() + .getBuildPath() + .equals(buildPath)) { return ib; } } return null; } - public static Project includedBuildProject(IncludedBuildInternal includedBuild, - final ProjectComponentIdentifier componentIdentifier) { - return includedBuild.getTarget().getMutableModel().getRootProject().findProject( - componentIdentifier.getProjectPath()); + public static Project includedBuildProject( + IncludedBuildInternal includedBuild, final ProjectComponentIdentifier componentIdentifier) { + return includedBuild + .getTarget() + .getMutableModel() + .getRootProject() + .findProject(componentIdentifier.getProjectPath()); } - public static Path serializeAppModel(ApplicationModel appModel, Task context, boolean test) throws IOException { - final Path serializedModel = context.getTemporaryDir().toPath() - .resolve("quarkus-app" + (test ? "-test" : "") + "-model.dat"); + public static Path serializeAppModel(ApplicationModel appModel, Task context, boolean test) + throws IOException { + final Path serializedModel = + context + .getTemporaryDir() + .toPath() + .resolve("quarkus-app" + (test ? "-test" : "") + "-model.dat"); try (ObjectOutputStream out = new ObjectOutputStream(Files.newOutputStream(serializedModel))) { out.writeObject(appModel); } @@ -95,8 +106,8 @@ public static ApplicationModel create(Project project, LaunchMode mode) { } public static ApplicationModel create(Project project, ModelParameter params) { - return (ApplicationModel) new GradleApplicationModelBuilder().buildAll(ApplicationModel.class.getName(), params, - project); + return (ApplicationModel) + new GradleApplicationModelBuilder() + .buildAll(ApplicationModel.class.getName(), params, project); } - } diff --git a/instrumentation/quartz-2.0/javaagent/build.gradle.kts b/instrumentation/quartz-2.0/javaagent/build.gradle.kts index 620d2f48d1d2..cc789d7a7cb0 100644 --- a/instrumentation/quartz-2.0/javaagent/build.gradle.kts +++ b/instrumentation/quartz-2.0/javaagent/build.gradle.kts @@ -25,11 +25,17 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.quartz.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.quartz.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.quartz.experimental-span-attributes=true", + ) } check { diff --git a/instrumentation/quartz-2.0/library/build.gradle.kts b/instrumentation/quartz-2.0/library/build.gradle.kts index b4119f049295..b3ae0e24094a 100644 --- a/instrumentation/quartz-2.0/library/build.gradle.kts +++ b/instrumentation/quartz-2.0/library/build.gradle.kts @@ -11,7 +11,10 @@ dependencies { tasks { val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.quartz.experimental-span-attributes=true") diff --git a/instrumentation/r2dbc-1.0/javaagent/build.gradle.kts b/instrumentation/r2dbc-1.0/javaagent/build.gradle.kts index d3688dd5d755..86f10ffed412 100644 --- a/instrumentation/r2dbc-1.0/javaagent/build.gradle.kts +++ b/instrumentation/r2dbc-1.0/javaagent/build.gradle.kts @@ -25,7 +25,12 @@ sourceSets { dependencies { library("io.r2dbc:r2dbc-spi:0.9.0.RELEASE") - compileOnly(project(path = ":instrumentation:r2dbc-1.0:library-instrumentation-shaded", configuration = "shadow")) + compileOnly( + project( + path = ":instrumentation:r2dbc-1.0:library-instrumentation-shaded", + configuration = "shadow", + ), + ) testImplementation(project(":instrumentation:r2dbc-1.0:testing")) testInstrumentation(project(":instrumentation:reactor:reactor-3.1:javaagent")) @@ -38,7 +43,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database,service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database,service.peer") diff --git a/instrumentation/r2dbc-1.0/library-instrumentation-shaded/build.gradle.kts b/instrumentation/r2dbc-1.0/library-instrumentation-shaded/build.gradle.kts index c750072d17ab..084061549716 100644 --- a/instrumentation/r2dbc-1.0/library-instrumentation-shaded/build.gradle.kts +++ b/instrumentation/r2dbc-1.0/library-instrumentation-shaded/build.gradle.kts @@ -12,7 +12,8 @@ dependencies { tasks { shadowJar { exclude { - it.path.startsWith("META-INF") && !it.path.startsWith("META-INF/io/opentelemetry/instrumentation/") + it.path.startsWith("META-INF") && + !it.path.startsWith("META-INF/io/opentelemetry/instrumentation/") } dependencies { @@ -22,11 +23,11 @@ tasks { } relocate( "io.r2dbc.proxy", - "io.opentelemetry.instrumentation.r2dbc.v1_0.internal.shaded.io.r2dbc.proxy" + "io.opentelemetry.instrumentation.r2dbc.v1_0.internal.shaded.io.r2dbc.proxy", ) relocate( "io.opentelemetry.instrumentation.r2dbc.v1_0", - "io.opentelemetry.instrumentation.r2dbc.v1_0.internal.shaded" + "io.opentelemetry.instrumentation.r2dbc.v1_0.internal.shaded", ) } diff --git a/instrumentation/r2dbc-1.0/library/build.gradle.kts b/instrumentation/r2dbc-1.0/library/build.gradle.kts index 7f16dd8efdc4..b486f21c40f6 100644 --- a/instrumentation/r2dbc-1.0/library/build.gradle.kts +++ b/instrumentation/r2dbc-1.0/library/build.gradle.kts @@ -17,7 +17,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") } diff --git a/instrumentation/r2dbc-1.0/testing/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/AbstractR2dbcStatementTest.java b/instrumentation/r2dbc-1.0/testing/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/AbstractR2dbcStatementTest.java index ac1ac088964f..c7aa9c9c0a33 100644 --- a/instrumentation/r2dbc-1.0/testing/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/AbstractR2dbcStatementTest.java +++ b/instrumentation/r2dbc-1.0/testing/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/AbstractR2dbcStatementTest.java @@ -227,8 +227,10 @@ private static Stream provideParameters() { system.system + " Create Table", new Parameter( system.system, - "CREATE TABLE person (id SERIAL PRIMARY KEY, first_name VARCHAR(255), last_name VARCHAR(255))", - "CREATE TABLE person (id SERIAL PRIMARY KEY, first_name VARCHAR(?), last_name VARCHAR(?))", + "CREATE TABLE person (id SERIAL PRIMARY KEY, first_name" + + " VARCHAR(255), last_name VARCHAR(255))", + "CREATE TABLE person (id SERIAL PRIMARY KEY, first_name VARCHAR(?)," + + " last_name VARCHAR(?))", emitStableDatabaseSemconv() ? "CREATE TABLE person" : "CREATE TABLE " + DB + ".person", @@ -239,7 +241,8 @@ private static Stream provideParameters() { system.system + " Insert", new Parameter( system.system, - "INSERT INTO person (id, first_name, last_name) values (1, 'tom', 'johnson')", + "INSERT INTO person (id, first_name, last_name) values (1, 'tom'," + + " 'johnson')", "INSERT INTO person (id, first_name, last_name) values (?, ?, ?)", emitStableDatabaseSemconv() ? "INSERT person" diff --git a/instrumentation/rabbitmq-2.7/javaagent/build.gradle.kts b/instrumentation/rabbitmq-2.7/javaagent/build.gradle.kts index 5245ee1fe83d..eab562765507 100644 --- a/instrumentation/rabbitmq-2.7/javaagent/build.gradle.kts +++ b/instrumentation/rabbitmq-2.7/javaagent/build.gradle.kts @@ -37,11 +37,17 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.rabbitmq.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.rabbitmq.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.rabbitmq.experimental-span-attributes=true", + ) } check { diff --git a/instrumentation/rabbitmq-2.7/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/ReactorRabbitMqTest.java b/instrumentation/rabbitmq-2.7/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/ReactorRabbitMqTest.java index 962c1cf95f86..0ab1ea7a774b 100644 --- a/instrumentation/rabbitmq-2.7/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/ReactorRabbitMqTest.java +++ b/instrumentation/rabbitmq-2.7/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/ReactorRabbitMqTest.java @@ -29,7 +29,8 @@ named = "testLatestDeps", matches = "true", disabledReason = - "reactor-rabbitmq 1.5.6 (and earlier) still calls `void useNio()` which was removed in 5.27.0") + "reactor-rabbitmq 1.5.6 (and earlier) still calls `void useNio()` which was removed in" + + " 5.27.0") class ReactorRabbitMqTest extends AbstractRabbitMqTest { @RegisterExtension private static final InstrumentationExtension testing = AgentInstrumentationExtension.create(); diff --git a/instrumentation/ratpack/ratpack-1.4/javaagent/build.gradle.kts b/instrumentation/ratpack/ratpack-1.4/javaagent/build.gradle.kts index fcc859b611ba..41637e6ad2a2 100644 --- a/instrumentation/ratpack/ratpack-1.4/javaagent/build.gradle.kts +++ b/instrumentation/ratpack/ratpack-1.4/javaagent/build.gradle.kts @@ -33,7 +33,10 @@ dependencies { // Requires old Guava. Can't use enforcedPlatform since predates BOM if (!otelProps.testLatestDeps) { - configurations.testRuntimeClasspath.get().resolutionStrategy.force("com.google.guava:guava:19.0") + configurations.testRuntimeClasspath + .get() + .resolutionStrategy + .force("com.google.guava:guava:19.0") } // to allow all tests to pass we need to choose a specific netty version @@ -59,7 +62,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/ratpack/ratpack-1.7/javaagent/build.gradle.kts b/instrumentation/ratpack/ratpack-1.7/javaagent/build.gradle.kts index a4f28502830c..7c9e457615a2 100644 --- a/instrumentation/ratpack/ratpack-1.7/javaagent/build.gradle.kts +++ b/instrumentation/ratpack/ratpack-1.7/javaagent/build.gradle.kts @@ -29,7 +29,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/ratpack/ratpack-1.7/library/build.gradle.kts b/instrumentation/ratpack/ratpack-1.7/library/build.gradle.kts index eef78b0286ea..ebcc8af4069d 100644 --- a/instrumentation/ratpack/ratpack-1.7/library/build.gradle.kts +++ b/instrumentation/ratpack/ratpack-1.7/library/build.gradle.kts @@ -24,7 +24,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/reactor/reactor-3.1/javaagent/build.gradle.kts b/instrumentation/reactor/reactor-3.1/javaagent/build.gradle.kts index a2b7c2ecd7af..c402a61d00a4 100644 --- a/instrumentation/reactor/reactor-3.1/javaagent/build.gradle.kts +++ b/instrumentation/reactor/reactor-3.1/javaagent/build.gradle.kts @@ -58,13 +58,19 @@ testing { tasks { val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=code") } val testBothSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=code/dup") } diff --git a/instrumentation/reactor/reactor-kafka-1.0/javaagent/build.gradle.kts b/instrumentation/reactor/reactor-kafka-1.0/javaagent/build.gradle.kts index 57038101af06..c37066e033d1 100644 --- a/instrumentation/reactor/reactor-kafka-1.0/javaagent/build.gradle.kts +++ b/instrumentation/reactor/reactor-kafka-1.0/javaagent/build.gradle.kts @@ -88,7 +88,10 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.kafka.experimental-span-attributes=true") @@ -97,7 +100,10 @@ tasks { } val testReceiveSpansDisabled by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath systemProperty("hasConsumerGroup", otelProps.testLatestDeps) diff --git a/instrumentation/reactor/reactor-netty/reactor-netty-0.9/javaagent/build.gradle.kts b/instrumentation/reactor/reactor-netty/reactor-netty-0.9/javaagent/build.gradle.kts index 79ba274545e7..e6ebb5fc7ed6 100644 --- a/instrumentation/reactor/reactor-netty/reactor-netty-0.9/javaagent/build.gradle.kts +++ b/instrumentation/reactor/reactor-netty/reactor-netty-0.9/javaagent/build.gradle.kts @@ -37,7 +37,10 @@ tasks { } val testConnectionSpan by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { includeTestsMatching("ReactorNettyConnectionSpanTest") @@ -53,7 +56,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/build.gradle.kts b/instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/build.gradle.kts index 4b1714e08951..2c47efa3dd3f 100644 --- a/instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/build.gradle.kts +++ b/instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/build.gradle.kts @@ -49,7 +49,10 @@ tasks { } val testConnectionSpan by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { includeTestsMatching("ReactorNettyConnectionSpanTest") @@ -68,7 +71,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/rediscala-1.8/javaagent/build.gradle.kts b/instrumentation/rediscala-1.8/javaagent/build.gradle.kts index 86a4010e6271..d2ba3854dedf 100644 --- a/instrumentation/rediscala-1.8/javaagent/build.gradle.kts +++ b/instrumentation/rediscala-1.8/javaagent/build.gradle.kts @@ -69,7 +69,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") diff --git a/instrumentation/redisson/redisson-3.0/javaagent/build.gradle.kts b/instrumentation/redisson/redisson-3.0/javaagent/build.gradle.kts index e75c725a4795..b8d9ff24741a 100644 --- a/instrumentation/redisson/redisson-3.0/javaagent/build.gradle.kts +++ b/instrumentation/redisson/redisson-3.0/javaagent/build.gradle.kts @@ -33,7 +33,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database") diff --git a/instrumentation/redisson/redisson-3.17/javaagent/build.gradle.kts b/instrumentation/redisson/redisson-3.17/javaagent/build.gradle.kts index a0b044e3b657..6846b19c82f5 100644 --- a/instrumentation/redisson/redisson-3.17/javaagent/build.gradle.kts +++ b/instrumentation/redisson/redisson-3.17/javaagent/build.gradle.kts @@ -32,7 +32,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database") diff --git a/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java b/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java index 9ee30f0b0739..7103f0ee7662 100644 --- a/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java +++ b/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java @@ -314,7 +314,8 @@ void hashCommand() { map.get("key1"); String script = - "local v = redis.call('hget', KEYS[1], ARGV[1]); redis.call('hset', KEYS[1], ARGV[1], ARGV[2]); return v"; + "local v = redis.call('hget', KEYS[1], ARGV[1]); redis.call('hset', KEYS[1], ARGV[1]," + + " ARGV[2]); return v"; testing.waitAndAssertSortedTraces( orderByRootSpanKind(SpanKind.INTERNAL, SpanKind.CLIENT), trace -> diff --git a/instrumentation/resources/library/build.gradle.kts b/instrumentation/resources/library/build.gradle.kts index cba98f80a24c..46437be4500c 100644 --- a/instrumentation/resources/library/build.gradle.kts +++ b/instrumentation/resources/library/build.gradle.kts @@ -45,19 +45,27 @@ for (version in mrJarVersions) { dependencies { // Common to reference classes in main sourceset from Java 9 one (e.g., to return a common interface) - add("java${version}Implementation", files(sourceSets.main.get().output.classesDirs)) + add( + "java${version}Implementation", + files( + sourceSets.main + .get() + .output.classesDirs, + ), + ) } } tasks { withType(Jar::class) { - val sourcePathProvider = if (name == "jar") { - { ss: SourceSet? -> ss?.output } - } else if (name == "sourcesJar") { - { ss: SourceSet? -> ss?.java } - } else { - { project.objects.fileCollection() } - } + val sourcePathProvider = + if (name == "jar") { + { ss: SourceSet? -> ss?.output } + } else if (name == "sourcesJar") { + { ss: SourceSet? -> ss?.java } + } else { + { project.objects.fileCollection() } + } for (version in mrJarVersions) { into("META-INF/versions/$version") { diff --git a/instrumentation/rmi/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rmi/context/ContextPayload.java b/instrumentation/rmi/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rmi/context/ContextPayload.java index 02612adf1533..491d5acdd296 100644 --- a/instrumentation/rmi/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rmi/context/ContextPayload.java +++ b/instrumentation/rmi/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rmi/context/ContextPayload.java @@ -53,7 +53,8 @@ public static ContextPayload read(ObjectInput oi) throws IOException { if (size > MAX_CONTEXT_ENTRIES) { logger.log( FINE, - "RMI context propagation entries count {0} exceeds maximum allowed of {1}, skipping context propagation.", + "RMI context propagation entries count {0} exceeds maximum allowed of {1}, skipping" + + " context propagation.", new Object[] {size, MAX_CONTEXT_ENTRIES}); return null; } @@ -66,7 +67,8 @@ public static ContextPayload read(ObjectInput oi) throws IOException { if (contextSize > MAX_CONTEXT_SIZE) { logger.log( FINE, - "RMI context propagation payload size exceeds maximum allowed of {0}, skipping context propagation.", + "RMI context propagation payload size exceeds maximum allowed of {0}, skipping context" + + " propagation.", new Object[] {MAX_CONTEXT_SIZE}); return null; } @@ -80,7 +82,8 @@ public void write(ObjectOutput out) throws IOException { if (size > MAX_CONTEXT_ENTRIES) { logger.log( FINE, - "RMI context propagation entries count {0} exceeds maximum allowed of {1}, skipping context propagation.", + "RMI context propagation entries count {0} exceeds maximum allowed of {1}, skipping" + + " context propagation.", new Object[] {size, MAX_CONTEXT_ENTRIES}); out.writeInt(0); return; diff --git a/instrumentation/rocketmq/rocketmq-client-4.8/javaagent/build.gradle.kts b/instrumentation/rocketmq/rocketmq-client-4.8/javaagent/build.gradle.kts index 38073d858829..dc221da2de03 100644 --- a/instrumentation/rocketmq/rocketmq-client-4.8/javaagent/build.gradle.kts +++ b/instrumentation/rocketmq/rocketmq-client-4.8/javaagent/build.gradle.kts @@ -39,11 +39,17 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.rocketmq-client.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.rocketmq-client.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.rocketmq-client.experimental-span-attributes=true", + ) } check { diff --git a/instrumentation/rocketmq/rocketmq-client-5.0/javaagent/build.gradle.kts b/instrumentation/rocketmq/rocketmq-client-5.0/javaagent/build.gradle.kts index d9d673d28c77..b1f8e2505cb4 100644 --- a/instrumentation/rocketmq/rocketmq-client-5.0/javaagent/build.gradle.kts +++ b/instrumentation/rocketmq/rocketmq-client-5.0/javaagent/build.gradle.kts @@ -27,7 +27,10 @@ tasks { } val testReceiveSpanDisabled by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { includeTestsMatching("RocketMqClientSuppressReceiveSpanTest") diff --git a/instrumentation/runtime-telemetry/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/runtimetelemetry/JarAnalyzerInstaller.java b/instrumentation/runtime-telemetry/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/runtimetelemetry/JarAnalyzerInstaller.java index c6d3f0d93f8e..5aab7409acb2 100644 --- a/instrumentation/runtime-telemetry/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/runtimetelemetry/JarAnalyzerInstaller.java +++ b/instrumentation/runtime-telemetry/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/runtimetelemetry/JarAnalyzerInstaller.java @@ -62,8 +62,8 @@ public void beforeAgent(AutoConfiguredOpenTelemetrySdk autoConfiguredOpenTelemet if (oldJarsPerSecond >= 0) { logger.warning( - "otel.instrumentation.runtime-telemetry.package-emitter.jars-per-second is deprecated" - + " and will be removed in 3.0. Use" + "otel.instrumentation.runtime-telemetry.package-emitter.jars-per-second is deprecated and" + + " will be removed in 3.0. Use" + " otel.instrumentation.runtime-telemetry.experimental.package-emitter.jars-per-second" + " instead."); } diff --git a/instrumentation/runtime-telemetry/library/build.gradle.kts b/instrumentation/runtime-telemetry/library/build.gradle.kts index e21e07a1ba25..5f8201748149 100644 --- a/instrumentation/runtime-telemetry/library/build.gradle.kts +++ b/instrumentation/runtime-telemetry/library/build.gradle.kts @@ -48,7 +48,14 @@ for (version in mrJarVersions) { dependencies { // Common to reference classes in main sourceset from Java 17 one - add("java${version}Implementation", files(sourceSets.main.get().output.classesDirs)) + add( + "java${version}Implementation", + files( + sourceSets.main + .get() + .output.classesDirs, + ), + ) } } @@ -82,13 +89,14 @@ tasks { } withType(Jar::class) { - val sourcePathProvider = if (name == "jar") { - { ss: SourceSet? -> ss?.output } - } else if (name == "sourcesJar") { - { ss: SourceSet? -> ss?.java } - } else { - { project.objects.fileCollection() } - } + val sourcePathProvider = + if (name == "jar") { + { ss: SourceSet? -> ss?.output } + } else if (name == "sourcesJar") { + { ss: SourceSet? -> ss?.java } + } else { + { project.objects.fileCollection() } + } for (version in mrJarVersions) { into("META-INF/versions/$version") { diff --git a/instrumentation/runtime-telemetry/library/src/main/java/io/opentelemetry/instrumentation/runtimetelemetry/internal/Internal.java b/instrumentation/runtime-telemetry/library/src/main/java/io/opentelemetry/instrumentation/runtimetelemetry/internal/Internal.java index e3c87f4a7862..eb5232b36468 100644 --- a/instrumentation/runtime-telemetry/library/src/main/java/io/opentelemetry/instrumentation/runtimetelemetry/internal/Internal.java +++ b/instrumentation/runtime-telemetry/library/src/main/java/io/opentelemetry/instrumentation/runtimetelemetry/internal/Internal.java @@ -283,9 +283,9 @@ public static RuntimeTelemetry configure(OpenTelemetry openTelemetry, boolean de private static void configureJava17EnableAll( RuntimeTelemetryBuilder builder, DeclarativeConfigProperties config) { logger.warning( - "otel.instrumentation.runtime-telemetry-java17.enable-all is deprecated and will be" - + " removed in 3.0. Use otel.instrumentation.runtime-telemetry.emit-experimental-metrics" - + " and otel.instrumentation.runtime-telemetry.experimental.prefer-jfr instead."); + "otel.instrumentation.runtime-telemetry-java17.enable-all is deprecated and will be removed" + + " in 3.0. Use otel.instrumentation.runtime-telemetry.emit-experimental-metrics and" + + " otel.instrumentation.runtime-telemetry.experimental.prefer-jfr instead."); // For backward compatibility: route JMX metrics to java8 scope, JFR metrics to java17 scope Internal.setJmxInstrumentationName(builder, "io.opentelemetry.runtime-telemetry-java8"); Internal.setJfrInstrumentationName(builder, "io.opentelemetry.runtime-telemetry-java17"); @@ -310,9 +310,9 @@ private static void configureJava17EnableAll( private static void configureJava17Enabled(RuntimeTelemetryBuilder builder) { logger.warning( - "otel.instrumentation.runtime-telemetry-java17.enabled is deprecated and will be" - + " removed in 3.0. Use otel.instrumentation.runtime-telemetry.emit-experimental-metrics" - + " for experimental JFR features."); + "otel.instrumentation.runtime-telemetry-java17.enabled is deprecated and will be removed in" + + " 3.0. Use otel.instrumentation.runtime-telemetry.emit-experimental-metrics for" + + " experimental JFR features."); // Enable default JFR features: context switches, CPU count, locks, allocations, network I/O Internal.setEnableJfrFeature(builder, "CONTEXT_SWITCH_METRICS"); Internal.setEnableJfrFeature(builder, "CPU_COUNT_METRICS"); diff --git a/instrumentation/runtime-telemetry/library/src/main/java/io/opentelemetry/instrumentation/runtimetelemetry/internal/MemoryPools.java b/instrumentation/runtime-telemetry/library/src/main/java/io/opentelemetry/instrumentation/runtimetelemetry/internal/MemoryPools.java index 3ec5ef8d325f..c15dd882f0c9 100644 --- a/instrumentation/runtime-telemetry/library/src/main/java/io/opentelemetry/instrumentation/runtimetelemetry/internal/MemoryPools.java +++ b/instrumentation/runtime-telemetry/library/src/main/java/io/opentelemetry/instrumentation/runtimetelemetry/internal/MemoryPools.java @@ -83,7 +83,8 @@ public static List registerObservers( meter .upDownCounterBuilder("jvm.memory.used_after_last_gc") .setDescription( - "Measure of memory used, as measured after the most recent garbage collection event on this pool.") + "Measure of memory used, as measured after the most recent garbage collection event" + + " on this pool.") .setUnit("By") .buildWithCallback( callback( diff --git a/instrumentation/runtime-telemetry/library/src/main/java17/io/opentelemetry/instrumentation/runtimetelemetry/internal/Constants.java b/instrumentation/runtime-telemetry/library/src/main/java17/io/opentelemetry/instrumentation/runtimetelemetry/internal/Constants.java index cfd35f63f3e5..a0a628ad05db 100644 --- a/instrumentation/runtime-telemetry/library/src/main/java17/io/opentelemetry/instrumentation/runtimetelemetry/internal/Constants.java +++ b/instrumentation/runtime-telemetry/library/src/main/java17/io/opentelemetry/instrumentation/runtimetelemetry/internal/Constants.java @@ -44,7 +44,8 @@ private Constants() {} public static final String METRIC_DESCRIPTION_MEMORY = "Measure of memory used."; public static final String METRIC_NAME_MEMORY_AFTER = "jvm.memory.used_after_last_gc"; public static final String METRIC_DESCRIPTION_MEMORY_AFTER = - "Measure of memory used, as measured after the most recent garbage collection event on this pool."; + "Measure of memory used, as measured after the most recent garbage collection event on this" + + " pool."; public static final String METRIC_NAME_MEMORY_ALLOCATION = "jvm.memory.allocation"; public static final String METRIC_DESCRIPTION_MEMORY_ALLOCATION = "Measure of memory allocations."; diff --git a/instrumentation/runtime-telemetry/library/src/test/java/io/opentelemetry/instrumentation/runtimetelemetry/internal/MemoryPoolsTest.java b/instrumentation/runtime-telemetry/library/src/test/java/io/opentelemetry/instrumentation/runtimetelemetry/internal/MemoryPoolsTest.java index e1935a1c5c71..0a3c75b5db3c 100644 --- a/instrumentation/runtime-telemetry/library/src/test/java/io/opentelemetry/instrumentation/runtimetelemetry/internal/MemoryPoolsTest.java +++ b/instrumentation/runtime-telemetry/library/src/test/java/io/opentelemetry/instrumentation/runtimetelemetry/internal/MemoryPoolsTest.java @@ -162,7 +162,8 @@ void registerObservers() { metricData -> assertThat(metricData) .hasDescription( - "Measure of memory used, as measured after the most recent garbage collection event on this pool.") + "Measure of memory used, as measured after the most recent garbage" + + " collection event on this pool.") .hasUnit("By") .hasLongSumSatisfying( sum -> diff --git a/instrumentation/runtime-telemetry/library/src/test/java/io/opentelemetry/instrumentation/runtimetelemetry/internal/SystemCpuTest.java b/instrumentation/runtime-telemetry/library/src/test/java/io/opentelemetry/instrumentation/runtimetelemetry/internal/SystemCpuTest.java index 0ee84a7e12ff..6e711c7dedee 100644 --- a/instrumentation/runtime-telemetry/library/src/test/java/io/opentelemetry/instrumentation/runtimetelemetry/internal/SystemCpuTest.java +++ b/instrumentation/runtime-telemetry/library/src/test/java/io/opentelemetry/instrumentation/runtimetelemetry/internal/SystemCpuTest.java @@ -42,7 +42,8 @@ void registerObservers() { metricData -> assertThat(metricData) .hasDescription( - "Average CPU load of the whole system for the last minute as reported by the JVM.") + "Average CPU load of the whole system for the last minute as reported" + + " by the JVM.") .hasUnit("{run_queue_item}") .hasDoubleGaugeSatisfying( gauge -> gauge.hasPointsSatisfying(point -> point.hasValue(2.2))))); diff --git a/instrumentation/runtime-telemetry/runtime-telemetry-java17/javaagent/build.gradle.kts b/instrumentation/runtime-telemetry/runtime-telemetry-java17/javaagent/build.gradle.kts index 87eb7e9497e8..632dac558bfe 100644 --- a/instrumentation/runtime-telemetry/runtime-telemetry-java17/javaagent/build.gradle.kts +++ b/instrumentation/runtime-telemetry/runtime-telemetry-java17/javaagent/build.gradle.kts @@ -10,7 +10,9 @@ otelJava { } dependencies { - testInstrumentation(project(":instrumentation:runtime-telemetry:runtime-telemetry-java8:javaagent")) + testInstrumentation( + project(":instrumentation:runtime-telemetry:runtime-telemetry-java8:javaagent"), + ) testInstrumentation(project(":instrumentation:runtime-telemetry:javaagent")) } diff --git a/instrumentation/runtime-telemetry/runtime-telemetry-java8/javaagent/build.gradle.kts b/instrumentation/runtime-telemetry/runtime-telemetry-java8/javaagent/build.gradle.kts index f5c4629e35b5..50d3f3ce2e44 100644 --- a/instrumentation/runtime-telemetry/runtime-telemetry-java8/javaagent/build.gradle.kts +++ b/instrumentation/runtime-telemetry/runtime-telemetry-java8/javaagent/build.gradle.kts @@ -9,7 +9,9 @@ dependencies { // used to verify jar analyzer package events testImplementation("commons-io:commons-io") testInstrumentation(project(":instrumentation:runtime-telemetry:javaagent")) - testInstrumentation(project(":instrumentation:runtime-telemetry:runtime-telemetry-java17:javaagent")) + testInstrumentation( + project(":instrumentation:runtime-telemetry:runtime-telemetry-java17:javaagent"), + ) } tasks { diff --git a/instrumentation/runtime-telemetry/testing/build.gradle.kts b/instrumentation/runtime-telemetry/testing/build.gradle.kts index 284dbdddf59a..d995310eb06a 100644 --- a/instrumentation/runtime-telemetry/testing/build.gradle.kts +++ b/instrumentation/runtime-telemetry/testing/build.gradle.kts @@ -35,8 +35,8 @@ tasks { environment( mapOf( // Expose dummy app war location to test - "DUMMY_APP_WAR" to "${layout.buildDirectory.asFile.get()}/libs/app.war" - ) + "DUMMY_APP_WAR" to "${layout.buildDirectory.asFile.get()}/libs/app.war", + ), ) } } diff --git a/instrumentation/rxjava/rxjava-2.0/javaagent/build.gradle.kts b/instrumentation/rxjava/rxjava-2.0/javaagent/build.gradle.kts index 6c42a79e5745..40cc8daec558 100644 --- a/instrumentation/rxjava/rxjava-2.0/javaagent/build.gradle.kts +++ b/instrumentation/rxjava/rxjava-2.0/javaagent/build.gradle.kts @@ -13,7 +13,10 @@ muzzle { tasks { val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.rxjava.experimental-span-attributes=true") diff --git a/instrumentation/rxjava/rxjava-3.0/javaagent/build.gradle.kts b/instrumentation/rxjava/rxjava-3.0/javaagent/build.gradle.kts index 052c4266996e..bd2de43efcd9 100644 --- a/instrumentation/rxjava/rxjava-3.0/javaagent/build.gradle.kts +++ b/instrumentation/rxjava/rxjava-3.0/javaagent/build.gradle.kts @@ -28,7 +28,10 @@ dependencies { tasks { val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.rxjava.experimental-span-attributes=true") diff --git a/instrumentation/rxjava/rxjava-3.1.1/javaagent/build.gradle.kts b/instrumentation/rxjava/rxjava-3.1.1/javaagent/build.gradle.kts index 2d7f90181ba2..9339519ee437 100644 --- a/instrumentation/rxjava/rxjava-3.1.1/javaagent/build.gradle.kts +++ b/instrumentation/rxjava/rxjava-3.1.1/javaagent/build.gradle.kts @@ -26,7 +26,10 @@ dependencies { tasks { val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.rxjava.experimental-span-attributes=true") diff --git a/instrumentation/spring/spring-batch-3.0/javaagent/build.gradle.kts b/instrumentation/spring/spring-batch-3.0/javaagent/build.gradle.kts index 9ca8c5414744..8e20e1e463e2 100644 --- a/instrumentation/spring/spring-batch-3.0/javaagent/build.gradle.kts +++ b/instrumentation/spring/spring-batch-3.0/javaagent/build.gradle.kts @@ -27,7 +27,10 @@ dependencies { tasks { val testChunkRootSpan by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { includeTestsMatching("*ChunkRootSpanTest") @@ -41,7 +44,10 @@ tasks { } val testItemLevelSpan by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { includeTestsMatching("*ItemLevelSpanTest") @@ -53,7 +59,10 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { excludeTestsMatching("*ChunkRootSpanTest") @@ -61,7 +70,10 @@ tasks { excludeTestsMatching("*CustomSpanEventTest") } jvmArgs("-Dotel.instrumentation.spring-batch.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.spring-batch.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.spring-batch.experimental-span-attributes=true", + ) } test { diff --git a/instrumentation/spring/spring-batch-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/spring/batch/v3_0/event/CustomSpanEventTest.java b/instrumentation/spring/spring-batch-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/spring/batch/v3_0/event/CustomSpanEventTest.java index 58d79344064f..e80e8828f6bd 100644 --- a/instrumentation/spring/spring-batch-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/spring/batch/v3_0/event/CustomSpanEventTest.java +++ b/instrumentation/spring/spring-batch-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/spring/batch/v3_0/event/CustomSpanEventTest.java @@ -75,7 +75,8 @@ void shouldBeAbleToCallSpanCurrentAndAddCustomInfoToSpans() { }), span -> span.hasName( - "BatchJob customSpanEventsItemsJob.customSpanEventsItemStep.Chunk") + "BatchJob" + + " customSpanEventsItemsJob.customSpanEventsItemStep.Chunk") .hasKind(SpanKind.INTERNAL) .hasParent(trace.getSpan(1)) .satisfies( diff --git a/instrumentation/spring/spring-boot-autoconfigure/build.gradle.kts b/instrumentation/spring/spring-boot-autoconfigure/build.gradle.kts index 59fa9d9b7481..a41844f13eb4 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/build.gradle.kts +++ b/instrumentation/spring/spring-boot-autoconfigure/build.gradle.kts @@ -16,7 +16,8 @@ sourceSets { val shadedDep = project(":instrumentation:r2dbc-1.0:library-instrumentation-shaded") output.dir( shadedDep.file("build/extracted/shadow-spring"), - "builtBy" to ":instrumentation:r2dbc-1.0:library-instrumentation-shaded:extractShadowJarSpring", + "builtBy" to + ":instrumentation:r2dbc-1.0:library-instrumentation-shaded:extractShadowJarSpring", ) } create("javaSpring3") { @@ -42,8 +43,12 @@ configurations { dependencies { compileOnly("org.springframework.boot:spring-boot-autoconfigure:$springBootVersion") - annotationProcessor("org.springframework.boot:spring-boot-autoconfigure-processor:$springBootVersion") - annotationProcessor("org.springframework.boot:spring-boot-configuration-processor:$springBootVersion") + annotationProcessor( + "org.springframework.boot:spring-boot-autoconfigure-processor:$springBootVersion", + ) + annotationProcessor( + "org.springframework.boot:spring-boot-configuration-processor:$springBootVersion", + ) implementation("javax.validation:validation-api") compileOnly("org.springframework.kafka:spring-kafka:2.9.0") @@ -53,8 +58,8 @@ dependencies { compileOnly( project( path = ":instrumentation:r2dbc-1.0:library-instrumentation-shaded", - configuration = "shadow" - ) + configuration = "shadow", + ), ) implementation(project(":instrumentation:spring:spring-kafka-2.7:library")) implementation(project(":instrumentation:spring:spring-web:spring-web-3.1:library")) @@ -115,26 +120,42 @@ dependencies { testImplementation(project(":instrumentation-annotations")) testImplementation(project(":instrumentation:spring:spring-boot-autoconfigure:testing")) - latestDepTestLibrary("org.springframework.boot:spring-boot-starter-micrometer-metrics:latest.release") + latestDepTestLibrary( + "org.springframework.boot:spring-boot-starter-micrometer-metrics:latest.release", + ) // needed for the Spring Boot 3 support implementation(project(":instrumentation:spring:spring-webmvc:spring-webmvc-6.0:library")) // give access to common classes, e.g. InstrumentationConfigUtil - add("javaSpring3CompileOnly", files(sourceSets.main.get().output.classesDirs)) + add( + "javaSpring3CompileOnly", + files( + sourceSets.main + .get() + .output.classesDirs, + ), + ) add("javaSpring3CompileOnly", "org.springframework.boot:spring-boot-starter-web:3.2.4") add("javaSpring3CompileOnly", "io.opentelemetry:opentelemetry-sdk-extension-autoconfigure") add( "javaSpring3CompileOnly", - project(":instrumentation:spring:spring-web:spring-web-3.1:library") + project(":instrumentation:spring:spring-web:spring-web-3.1:library"), ) add( "javaSpring3CompileOnly", - project(":instrumentation:spring:spring-webmvc:spring-webmvc-6.0:library") + project(":instrumentation:spring:spring-webmvc:spring-webmvc-6.0:library"), ) // Spring Boot 4 - add("javaSpring4CompileOnly", files(sourceSets.main.get().output.classesDirs)) + add( + "javaSpring4CompileOnly", + files( + sourceSets.main + .get() + .output.classesDirs, + ), + ) add("javaSpring4CompileOnly", "org.springframework.boot:spring-boot-starter-kafka:4.0.0") add("javaSpring4CompileOnly", "org.springframework.boot:spring-boot-autoconfigure:4.0.0") add("javaSpring4CompileOnly", "org.springframework.boot:spring-boot-jdbc:4.0.0") @@ -144,20 +165,23 @@ dependencies { add("javaSpring4CompileOnly", "org.springframework.boot:spring-boot-starter-data-mongodb:4.0.0") add( "javaSpring4CompileOnly", - "org.springframework.boot:spring-boot-starter-micrometer-metrics:4.0.0" + "org.springframework.boot:spring-boot-starter-micrometer-metrics:4.0.0", ) add( "javaSpring4CompileOnly", - project(":instrumentation:kafka:kafka-clients:kafka-clients-2.6:library") + project(":instrumentation:kafka:kafka-clients:kafka-clients-2.6:library"), ) add("javaSpring4CompileOnly", project(":instrumentation:spring:spring-kafka-2.7:library")) add("javaSpring4CompileOnly", project(":instrumentation:mongo:mongo-3.1:library")) add("javaSpring4CompileOnly", project(":instrumentation:micrometer:micrometer-1.5:library")) add( "javaSpring4CompileOnly", - project(":instrumentation:spring:spring-web:spring-web-3.1:library") + project(":instrumentation:spring:spring-web:spring-web-3.1:library"), + ) + add( + "javaSpring4CompileOnly", + project(":instrumentation:spring:spring-webflux:spring-webflux-5.3:library"), ) - add("javaSpring4CompileOnly", project(":instrumentation:spring:spring-webflux:spring-webflux-5.3:library")) } // spring 6 (spring boot 3) requires java 17 @@ -360,7 +384,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") } diff --git a/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/OpenTelemetryAutoConfigurationTest.java b/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/OpenTelemetryAutoConfigurationTest.java index 8f1d41d4e7c5..24183639555a 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/OpenTelemetryAutoConfigurationTest.java +++ b/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/OpenTelemetryAutoConfigurationTest.java @@ -62,7 +62,8 @@ void customOpenTelemetry() { @Test @DisplayName( - "when Application Context DOES NOT contain OpenTelemetry bean should initialize openTelemetry") + "when Application Context DOES NOT contain OpenTelemetry bean should initialize" + + " openTelemetry") void initializeProvidersAndOpenTelemetry() { this.contextRunner .withConfiguration(AutoConfigurations.of(OpenTelemetryAutoConfiguration.class)) @@ -125,7 +126,8 @@ void enabledProviders() { @Test @DisplayName( - "when Application Context DOES NOT contain OpenTelemetry bean but SpanExporter should initialize openTelemetry") + "when Application Context DOES NOT contain OpenTelemetry bean but SpanExporter should" + + " initialize openTelemetry") void initializeOpenTelemetryWithCustomProviders() { OtlpSpanExporterProvider spanExporterProvider = mock( diff --git a/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal/instrumentation/annotations/InstrumentationWithSpanAspectTest.java b/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal/instrumentation/annotations/InstrumentationWithSpanAspectTest.java index 75a919b37fa2..760267c15afa 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal/instrumentation/annotations/InstrumentationWithSpanAspectTest.java +++ b/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal/instrumentation/annotations/InstrumentationWithSpanAspectTest.java @@ -115,7 +115,8 @@ void withSpanName() { @Test @DisplayName( - "when method is annotated with @WithSpan AND an exception is thrown span should record the exception") + "when method is annotated with @WithSpan AND an exception is thrown span should record the" + + " exception") void withSpanError() { assertThatThrownBy(() -> withSpanTester.testWithSpanWithException()) .isInstanceOf(Exception.class); @@ -134,7 +135,8 @@ void withSpanError() { @Test @DisplayName( - "when method is annotated with @WithSpan(kind=CLIENT) should build span with the declared SpanKind") + "when method is annotated with @WithSpan(kind=CLIENT) should build span with the declared" + + " SpanKind") void withSpanKind() { // when testing.runWithSpan("parent", () -> withSpanTester.testWithClientSpan()); @@ -179,7 +181,8 @@ void withSpanAttributes() { @Test @DisplayName( - "when method is annotated with @WithSpan(inheritContext=false) should build span without parent") + "when method is annotated with @WithSpan(inheritContext=false) should build span without" + + " parent") void withSpanWithoutParent() { // when testing.runWithSpan("parent", withSpanTester::testWithoutParentSpan); diff --git a/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal/instrumentation/scheduling/SchedulingInstrumentationAspectTest.java b/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal/instrumentation/scheduling/SchedulingInstrumentationAspectTest.java index 4573fa15e043..fffc01a573ac 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal/instrumentation/scheduling/SchedulingInstrumentationAspectTest.java +++ b/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal/instrumentation/scheduling/SchedulingInstrumentationAspectTest.java @@ -128,7 +128,8 @@ void nestedSpanInScheduled() { @Test @DisplayName( - "when method is annotated with @Scheduled AND an exception is thrown span should record the exception") + "when method is annotated with @Scheduled AND an exception is thrown span should record the" + + " exception") void scheduledError() { assertThatThrownBy(() -> schedulingTester.testScheduledWithException()) .isInstanceOf(Exception.class); diff --git a/instrumentation/spring/spring-boot-autoconfigure/src/testDeclarativeConfig/java/io/opentelemetry/instrumentation/spring/autoconfigure/DeclarativeConfigTest.java b/instrumentation/spring/spring-boot-autoconfigure/src/testDeclarativeConfig/java/io/opentelemetry/instrumentation/spring/autoconfigure/DeclarativeConfigTest.java index 8fc355852787..a6acbc8d303e 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/src/testDeclarativeConfig/java/io/opentelemetry/instrumentation/spring/autoconfigure/DeclarativeConfigTest.java +++ b/instrumentation/spring/spring-boot-autoconfigure/src/testDeclarativeConfig/java/io/opentelemetry/instrumentation/spring/autoconfigure/DeclarativeConfigTest.java @@ -54,7 +54,8 @@ void customOpenTelemetry() { @Test @DisplayName( - "when Application Context DOES NOT contain OpenTelemetry bean should initialize openTelemetry") + "when Application Context DOES NOT contain OpenTelemetry bean should initialize" + + " openTelemetry") void initializeProvidersAndOpenTelemetry() { this.contextRunner.run( context -> diff --git a/instrumentation/spring/spring-boot-autoconfigure/testing/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal/AbstractR2DbcInstrumentationAutoConfigurationTest.java b/instrumentation/spring/spring-boot-autoconfigure/testing/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal/AbstractR2DbcInstrumentationAutoConfigurationTest.java index 4c8489afa564..ef36bd3a0a7a 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/testing/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal/AbstractR2DbcInstrumentationAutoConfigurationTest.java +++ b/instrumentation/spring/spring-boot-autoconfigure/testing/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal/AbstractR2DbcInstrumentationAutoConfigurationTest.java @@ -34,7 +34,8 @@ void querySanitizerEnabledByDefault() { DatabaseClient client = context.getBean(DatabaseClient.class); client .sql( - "CREATE TABLE IF NOT EXISTS player(id INT NOT NULL AUTO_INCREMENT, name VARCHAR(255), age INT, PRIMARY KEY (id))") + "CREATE TABLE IF NOT EXISTS player(id INT NOT NULL AUTO_INCREMENT, name" + + " VARCHAR(255), age INT, PRIMARY KEY (id))") .fetch() .all() .blockLast(); @@ -46,7 +47,9 @@ void querySanitizerEnabledByDefault() { span -> span.hasAttribute( maybeStable(DB_STATEMENT), - "CREATE TABLE IF NOT EXISTS player(id INT NOT NULL AUTO_INCREMENT, name VARCHAR(?), age INT, PRIMARY KEY (id))")), + "CREATE TABLE IF NOT EXISTS player(id INT NOT NULL" + + " AUTO_INCREMENT, name VARCHAR(?), age INT, PRIMARY KEY" + + " (id))")), trace -> trace.hasSpansSatisfyingExactly( span -> diff --git a/instrumentation/spring/spring-boot-resources/javaagent-unit-tests/build.gradle.kts b/instrumentation/spring/spring-boot-resources/javaagent-unit-tests/build.gradle.kts index c88fb41391a9..96bb5fc382f9 100644 --- a/instrumentation/spring/spring-boot-resources/javaagent-unit-tests/build.gradle.kts +++ b/instrumentation/spring/spring-boot-resources/javaagent-unit-tests/build.gradle.kts @@ -7,5 +7,7 @@ dependencies { testImplementation(project(":instrumentation:spring:spring-boot-resources:javaagent")) testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi") - testImplementation(project(path = ":smoke-tests:images:spring-boot", configuration = "springBootJar")) + testImplementation( + project(path = ":smoke-tests:images:spring-boot", configuration = "springBootJar"), + ) } diff --git a/instrumentation/spring/spring-cloud-gateway/spring-cloud-gateway-2.0/javaagent/build.gradle.kts b/instrumentation/spring/spring-cloud-gateway/spring-cloud-gateway-2.0/javaagent/build.gradle.kts index 6ac75a31df84..5ecdb111b6d4 100644 --- a/instrumentation/spring/spring-cloud-gateway/spring-cloud-gateway-2.0/javaagent/build.gradle.kts +++ b/instrumentation/spring/spring-cloud-gateway/spring-cloud-gateway-2.0/javaagent/build.gradle.kts @@ -24,14 +24,20 @@ muzzle { dependencies { library("org.springframework.cloud:spring-cloud-starter-gateway:2.0.0.RELEASE") - implementation(project(":instrumentation:spring:spring-cloud-gateway:spring-cloud-gateway-common:javaagent")) + implementation( + project(":instrumentation:spring:spring-cloud-gateway:spring-cloud-gateway-common:javaagent"), + ) testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent")) testInstrumentation(project(":instrumentation:reactor:reactor-3.1:javaagent")) testInstrumentation(project(":instrumentation:reactor:reactor-netty:reactor-netty-1.0:javaagent")) - testInstrumentation(project(":instrumentation:spring:spring-webflux:spring-webflux-5.0:javaagent")) + testInstrumentation( + project(":instrumentation:spring:spring-webflux:spring-webflux-5.0:javaagent"), + ) - testImplementation(project(":instrumentation:spring:spring-cloud-gateway:spring-cloud-gateway-common:testing")) + testImplementation( + project(":instrumentation:spring:spring-cloud-gateway:spring-cloud-gateway-common:testing"), + ) testLibrary("org.springframework.boot:spring-boot-starter-test:2.0.0.RELEASE") diff --git a/instrumentation/spring/spring-cloud-gateway/spring-cloud-gateway-2.2/testing/build.gradle.kts b/instrumentation/spring/spring-cloud-gateway/spring-cloud-gateway-2.2/testing/build.gradle.kts index 750de2ac15ce..a05340846d93 100644 --- a/instrumentation/spring/spring-cloud-gateway/spring-cloud-gateway-2.2/testing/build.gradle.kts +++ b/instrumentation/spring/spring-cloud-gateway/spring-cloud-gateway-2.2/testing/build.gradle.kts @@ -3,13 +3,19 @@ plugins { } dependencies { - testInstrumentation(project(":instrumentation:spring:spring-cloud-gateway:spring-cloud-gateway-2.0:javaagent")) + testInstrumentation( + project(":instrumentation:spring:spring-cloud-gateway:spring-cloud-gateway-2.0:javaagent"), + ) testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent")) testInstrumentation(project(":instrumentation:reactor:reactor-3.1:javaagent")) testInstrumentation(project(":instrumentation:reactor:reactor-netty:reactor-netty-1.0:javaagent")) - testInstrumentation(project(":instrumentation:spring:spring-webflux:spring-webflux-5.0:javaagent")) + testInstrumentation( + project(":instrumentation:spring:spring-webflux:spring-webflux-5.0:javaagent"), + ) - testImplementation(project(":instrumentation:spring:spring-cloud-gateway:spring-cloud-gateway-common:testing")) + testImplementation( + project(":instrumentation:spring:spring-cloud-gateway:spring-cloud-gateway-common:testing"), + ) testLibrary("org.springframework.cloud:spring-cloud-starter-gateway:2.2.0.RELEASE") testLibrary("org.springframework.boot:spring-boot-starter-test:2.2.0.RELEASE") diff --git a/instrumentation/spring/spring-cloud-gateway/spring-cloud-gateway-webflux-4.3/testing/build.gradle.kts b/instrumentation/spring/spring-cloud-gateway/spring-cloud-gateway-webflux-4.3/testing/build.gradle.kts index 7617192bb63c..866c4759f612 100644 --- a/instrumentation/spring/spring-cloud-gateway/spring-cloud-gateway-webflux-4.3/testing/build.gradle.kts +++ b/instrumentation/spring/spring-cloud-gateway/spring-cloud-gateway-webflux-4.3/testing/build.gradle.kts @@ -3,14 +3,20 @@ plugins { } dependencies { - testInstrumentation(project(":instrumentation:spring:spring-cloud-gateway:spring-cloud-gateway-2.0:javaagent")) + testInstrumentation( + project(":instrumentation:spring:spring-cloud-gateway:spring-cloud-gateway-2.0:javaagent"), + ) testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent")) testInstrumentation(project(":instrumentation:reactor:reactor-3.1:javaagent")) testInstrumentation(project(":instrumentation:reactor:reactor-netty:reactor-netty-1.0:javaagent")) - testInstrumentation(project(":instrumentation:spring:spring-webflux:spring-webflux-5.0:javaagent")) + testInstrumentation( + project(":instrumentation:spring:spring-webflux:spring-webflux-5.0:javaagent"), + ) - testImplementation(project(":instrumentation:spring:spring-cloud-gateway:spring-cloud-gateway-common:testing")) + testImplementation( + project(":instrumentation:spring:spring-cloud-gateway:spring-cloud-gateway-common:testing"), + ) // classes in test setup require 5.0+ testLibrary("org.springframework.cloud:spring-cloud-starter-gateway-server-webflux:5.0.0") diff --git a/instrumentation/spring/spring-cloud-gateway/spring-cloud-gateway-webmvc-4.3/javaagent/build.gradle.kts b/instrumentation/spring/spring-cloud-gateway/spring-cloud-gateway-webmvc-4.3/javaagent/build.gradle.kts index 368787c4e4de..f05e108909d3 100644 --- a/instrumentation/spring/spring-cloud-gateway/spring-cloud-gateway-webmvc-4.3/javaagent/build.gradle.kts +++ b/instrumentation/spring/spring-cloud-gateway/spring-cloud-gateway-webmvc-4.3/javaagent/build.gradle.kts @@ -15,12 +15,16 @@ muzzle { dependencies { library("org.springframework.cloud:spring-cloud-starter-gateway-server-webmvc:4.3.0") - implementation(project(":instrumentation:spring:spring-cloud-gateway:spring-cloud-gateway-common:javaagent")) + implementation( + project(":instrumentation:spring:spring-cloud-gateway:spring-cloud-gateway-common:javaagent"), + ) testInstrumentation(project(":instrumentation:spring:spring-webmvc:spring-webmvc-6.0:javaagent")) testInstrumentation(project(":instrumentation:tomcat:tomcat-10.0:javaagent")) - testImplementation(project(":instrumentation:spring:spring-cloud-gateway:spring-cloud-gateway-common:testing")) + testImplementation( + project(":instrumentation:spring:spring-cloud-gateway:spring-cloud-gateway-common:testing"), + ) testLibrary("org.springframework.cloud:spring-cloud-starter-gateway-server-webmvc:5.0.0") testLibrary("org.springframework.boot:spring-boot-starter-test:4.0.0") diff --git a/instrumentation/spring/spring-data/spring-data-1.8/javaagent/build.gradle.kts b/instrumentation/spring/spring-data/spring-data-1.8/javaagent/build.gradle.kts index fe82d095e19b..faf2e38fcb56 100644 --- a/instrumentation/spring/spring-data/spring-data-1.8/javaagent/build.gradle.kts +++ b/instrumentation/spring/spring-data/spring-data-1.8/javaagent/build.gradle.kts @@ -56,7 +56,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database") diff --git a/instrumentation/spring/spring-data/spring-data-3.0/kotlin-testing/src/test/kotlin/io/opentelemetry/javaagent/instrumentation/spring/data/v3_0/KotlinSpringDataTest.kt b/instrumentation/spring/spring-data/spring-data-3.0/kotlin-testing/src/test/kotlin/io/opentelemetry/javaagent/instrumentation/spring/data/v3_0/KotlinSpringDataTest.kt index 7ca9242e51d2..f8b4e486e8e5 100644 --- a/instrumentation/spring/spring-data/spring-data-3.0/kotlin-testing/src/test/kotlin/io/opentelemetry/javaagent/instrumentation/spring/data/v3_0/KotlinSpringDataTest.kt +++ b/instrumentation/spring/spring-data/spring-data-3.0/kotlin-testing/src/test/kotlin/io/opentelemetry/javaagent/instrumentation/spring/data/v3_0/KotlinSpringDataTest.kt @@ -20,7 +20,6 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext @TestInstance(TestInstance.Lifecycle.PER_CLASS) class KotlinSpringDataTest { - companion object { @JvmStatic @RegisterExtension diff --git a/instrumentation/spring/spring-data/spring-data-3.0/kotlin-testing/src/test/kotlin/io/opentelemetry/javaagent/instrumentation/spring/data/v3_0/repository/PersistenceConfig.kt b/instrumentation/spring/spring-data/spring-data-3.0/kotlin-testing/src/test/kotlin/io/opentelemetry/javaagent/instrumentation/spring/data/v3_0/repository/PersistenceConfig.kt index 4f43f1bfb7b5..217677cf606f 100644 --- a/instrumentation/spring/spring-data/spring-data-3.0/kotlin-testing/src/test/kotlin/io/opentelemetry/javaagent/instrumentation/spring/data/v3_0/repository/PersistenceConfig.kt +++ b/instrumentation/spring/spring-data/spring-data-3.0/kotlin-testing/src/test/kotlin/io/opentelemetry/javaagent/instrumentation/spring/data/v3_0/repository/PersistenceConfig.kt @@ -21,19 +21,20 @@ import java.nio.charset.StandardCharsets @EnableR2dbcRepositories(basePackages = ["io.opentelemetry.javaagent.instrumentation.spring.data.v3_0.repository"]) class PersistenceConfig { - @Bean - fun connectionFactory(): ConnectionFactory = ConnectionFactories.find( - ConnectionFactoryOptions.builder() - .option(ConnectionFactoryOptions.DRIVER, "h2") - .option(ConnectionFactoryOptions.PROTOCOL, "mem") - .option(ConnectionFactoryOptions.HOST, "localhost") - .option(ConnectionFactoryOptions.USER, "sa") - .option(ConnectionFactoryOptions.PASSWORD, "") - .option(ConnectionFactoryOptions.DATABASE, "db") - .option(Option.valueOf("DB_CLOSE_DELAY"), "-1") - .build() - ) + fun connectionFactory(): ConnectionFactory = + ConnectionFactories.find( + ConnectionFactoryOptions + .builder() + .option(ConnectionFactoryOptions.DRIVER, "h2") + .option(ConnectionFactoryOptions.PROTOCOL, "mem") + .option(ConnectionFactoryOptions.HOST, "localhost") + .option(ConnectionFactoryOptions.USER, "sa") + .option(ConnectionFactoryOptions.PASSWORD, "") + .option(ConnectionFactoryOptions.DATABASE, "db") + .option(Option.valueOf("DB_CLOSE_DELAY"), "-1") + .build() + ) @Bean fun initializer(connectionFactory: ConnectionFactory): ConnectionFactoryInitializer { diff --git a/instrumentation/spring/spring-data/spring-data-3.0/testing/build.gradle.kts b/instrumentation/spring/spring-data/spring-data-3.0/testing/build.gradle.kts index 8d69bc72b756..441a37007890 100644 --- a/instrumentation/spring/spring-data/spring-data-3.0/testing/build.gradle.kts +++ b/instrumentation/spring/spring-data/spring-data-3.0/testing/build.gradle.kts @@ -48,14 +48,15 @@ tasks { jvmArgs("-XX:+IgnoreUnrecognizedVMOptions") } - val stableSemconvSuites = testing.suites.withType(JvmTestSuite::class).map { suite -> - register("${suite.name}StableSemconv") { - testClassesDirs = suite.sources.output.classesDirs - classpath = suite.sources.runtimeClasspath + val stableSemconvSuites = + testing.suites.withType(JvmTestSuite::class).map { suite -> + register("${suite.name}StableSemconv") { + testClassesDirs = suite.sources.output.classesDirs + classpath = suite.sources.runtimeClasspath - jvmArgs("-Dotel.semconv-stability.opt-in=database,service.peer") + jvmArgs("-Dotel.semconv-stability.opt-in=database,service.peer") + } } - } check { dependsOn(testing.suites, stableSemconvSuites) diff --git a/instrumentation/spring/spring-data/spring-data-3.0/testing/src/reactiveTest/java/io/opentelemetry/javaagent/instrumentation/spring/data/v3_0/repository/PersistenceConfig.java b/instrumentation/spring/spring-data/spring-data-3.0/testing/src/reactiveTest/java/io/opentelemetry/javaagent/instrumentation/spring/data/v3_0/repository/PersistenceConfig.java index bd4f9e9894d1..be1c1b31e4fb 100644 --- a/instrumentation/spring/spring-data/spring-data-3.0/testing/src/reactiveTest/java/io/opentelemetry/javaagent/instrumentation/spring/data/v3_0/repository/PersistenceConfig.java +++ b/instrumentation/spring/spring-data/spring-data-3.0/testing/src/reactiveTest/java/io/opentelemetry/javaagent/instrumentation/spring/data/v3_0/repository/PersistenceConfig.java @@ -51,8 +51,9 @@ ConnectionFactoryInitializer initializer(ConnectionFactory connectionFactory) { initializer.setDatabasePopulator( new ResourceDatabasePopulator( new ByteArrayResource( - ("CREATE TABLE customer (id INT PRIMARY KEY, firstname VARCHAR(100) NOT NULL, lastname VARCHAR(100) NOT NULL);" - + "INSERT INTO customer (id, firstname, lastname) VALUES ('1', 'First', 'Last');") + ("CREATE TABLE customer (id INT PRIMARY KEY, firstname VARCHAR(100) NOT NULL," + + " lastname VARCHAR(100) NOT NULL);INSERT INTO customer (id, firstname," + + " lastname) VALUES ('1', 'First', 'Last');") .getBytes(UTF_8)))); return initializer; diff --git a/instrumentation/spring/spring-integration-4.1/javaagent/build.gradle.kts b/instrumentation/spring/spring-integration-4.1/javaagent/build.gradle.kts index f4d1ed3f30f1..18057eb28c21 100644 --- a/instrumentation/spring/spring-integration-4.1/javaagent/build.gradle.kts +++ b/instrumentation/spring/spring-integration-4.1/javaagent/build.gradle.kts @@ -43,7 +43,10 @@ dependencies { tasks { val testWithRabbitInstrumentation by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { includeTestsMatching("SpringIntegrationAndRabbitTest") @@ -55,7 +58,10 @@ tasks { } val testWithProducerInstrumentation by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { includeTestsMatching("SpringCloudStreamProducerTest") @@ -64,7 +70,10 @@ tasks { jvmArgs("-Dotel.instrumentation.rabbitmq.enabled=false") jvmArgs("-Dotel.instrumentation.spring-rabbit.enabled=false") jvmArgs("-Dotel.instrumentation.spring-integration.producer.enabled=true") - systemProperty("metadataConfig", "otel.instrumentation.spring-integration.producer.enabled=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.spring-integration.producer.enabled=true", + ) } test { diff --git a/instrumentation/spring/spring-jms/spring-jms-6.0/javaagent/build.gradle.kts b/instrumentation/spring/spring-jms/spring-jms-6.0/javaagent/build.gradle.kts index 503f0a1aaa6f..05a6618e1205 100644 --- a/instrumentation/spring/spring-jms/spring-jms-6.0/javaagent/build.gradle.kts +++ b/instrumentation/spring/spring-jms/spring-jms-6.0/javaagent/build.gradle.kts @@ -42,7 +42,10 @@ tasks { } val testReceiveSpansDisabled by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { includeTestsMatching("SpringListenerSuppressReceiveSpansTest") diff --git a/instrumentation/spring/spring-kafka-2.7/javaagent/build.gradle.kts b/instrumentation/spring/spring-kafka-2.7/javaagent/build.gradle.kts index b93e1b6dc24a..f84aae2602f6 100644 --- a/instrumentation/spring/spring-kafka-2.7/javaagent/build.gradle.kts +++ b/instrumentation/spring/spring-kafka-2.7/javaagent/build.gradle.kts @@ -72,7 +72,10 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.messaging.experimental.receive-telemetry.enabled=true") @@ -102,15 +105,14 @@ if (!otelProps.testLatestDeps) { listOf( testRuntimeClasspath, named("testNoReceiveTelemetryRuntimeClasspath"), - ) - .forEach { - it.configure { - resolutionStrategy { - // requires old logback (and therefore also old slf4j) - force("ch.qos.logback:logback-classic:1.2.11") - force("org.slf4j:slf4j-api:1.7.36") - } + ).forEach { + it.configure { + resolutionStrategy { + // requires old logback (and therefore also old slf4j) + force("ch.qos.logback:logback-classic:1.2.11") + force("org.slf4j:slf4j-api:1.7.36") } } + } } } diff --git a/instrumentation/spring/spring-scheduling-3.1/javaagent/build.gradle.kts b/instrumentation/spring/spring-scheduling-3.1/javaagent/build.gradle.kts index a1dc67be10ac..d13d0ff668cf 100644 --- a/instrumentation/spring/spring-scheduling-3.1/javaagent/build.gradle.kts +++ b/instrumentation/spring/spring-scheduling-3.1/javaagent/build.gradle.kts @@ -31,10 +31,16 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.spring-scheduling.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.spring-scheduling.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.spring-scheduling.experimental-span-attributes=true", + ) } check { diff --git a/instrumentation/spring/spring-web/spring-web-3.1/library/build.gradle.kts b/instrumentation/spring/spring-web/spring-web-3.1/library/build.gradle.kts index 8dff05ffd495..8193353484b6 100644 --- a/instrumentation/spring/spring-web/spring-web-3.1/library/build.gradle.kts +++ b/instrumentation/spring/spring-web/spring-web-3.1/library/build.gradle.kts @@ -24,7 +24,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/spring/spring-web/spring-web-3.1/testing/build.gradle.kts b/instrumentation/spring/spring-web/spring-web-3.1/testing/build.gradle.kts index da16dbde2c70..cfc1ee3c4b02 100644 --- a/instrumentation/spring/spring-web/spring-web-3.1/testing/build.gradle.kts +++ b/instrumentation/spring/spring-web/spring-web-3.1/testing/build.gradle.kts @@ -13,7 +13,10 @@ dependencies { tasks { val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/spring/spring-web/spring-web-6.0/javaagent/build.gradle.kts b/instrumentation/spring/spring-web/spring-web-6.0/javaagent/build.gradle.kts index dad4bad8444b..b3a56dc8ad6c 100644 --- a/instrumentation/spring/spring-web/spring-web-6.0/javaagent/build.gradle.kts +++ b/instrumentation/spring/spring-web/spring-web-6.0/javaagent/build.gradle.kts @@ -29,14 +29,23 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.http.client.emit-experimental-telemetry=true") - systemProperty("metadataConfig", "otel.instrumentation.http.client.emit-experimental-telemetry=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.http.client.emit-experimental-telemetry=true", + ) } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/spring/spring-webflux/spring-webflux-5.0/javaagent/build.gradle.kts b/instrumentation/spring/spring-webflux/spring-webflux-5.0/javaagent/build.gradle.kts index 1a06d5cab6ed..3608ef3a246a 100644 --- a/instrumentation/spring/spring-webflux/spring-webflux-5.0/javaagent/build.gradle.kts +++ b/instrumentation/spring/spring-webflux/spring-webflux-5.0/javaagent/build.gradle.kts @@ -74,19 +74,25 @@ tasks { jvmArgs("-XX:+IgnoreUnrecognizedVMOptions") jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true") - systemProperty("metadataConfig", "otel.instrumentation.common.experimental.controller-telemetry.enabled") + systemProperty( + "metadataConfig", + "otel.instrumentation.common.experimental.controller-telemetry.enabled", + ) systemProperty("testLatestDeps", otelProps.testLatestDeps) systemProperty("collectMetadata", otelProps.collectMetadata) } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty( "metadataConfig", "otel.instrumentation.common.experimental.controller-telemetry.enabled," + - "otel.semconv-stability.opt-in=service.peer" + "otel.semconv-stability.opt-in=service.peer", ) } diff --git a/instrumentation/spring/spring-webflux/spring-webflux-5.0/testing-webflux7/build.gradle.kts b/instrumentation/spring/spring-webflux/spring-webflux-5.0/testing-webflux7/build.gradle.kts index f0b4dc1ba9da..6d65279496ce 100644 --- a/instrumentation/spring/spring-webflux/spring-webflux-5.0/testing-webflux7/build.gradle.kts +++ b/instrumentation/spring/spring-webflux/spring-webflux-5.0/testing-webflux7/build.gradle.kts @@ -4,7 +4,9 @@ plugins { dependencies { testInstrumentation(project(":instrumentation:spring:spring-core-2.0:javaagent")) - testInstrumentation(project(":instrumentation:spring:spring-webflux:spring-webflux-5.0:javaagent")) + testInstrumentation( + project(":instrumentation:spring:spring-webflux:spring-webflux-5.0:javaagent"), + ) testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent")) testInstrumentation(project(":instrumentation:reactor:reactor-3.1:javaagent")) testInstrumentation(project(":instrumentation:reactor:reactor-netty:reactor-netty-1.0:javaagent")) diff --git a/instrumentation/spring/spring-webflux/spring-webflux-5.3/library/build.gradle.kts b/instrumentation/spring/spring-webflux/spring-webflux-5.3/library/build.gradle.kts index 8292066de3a7..459194e43590 100644 --- a/instrumentation/spring/spring-webflux/spring-webflux-5.3/library/build.gradle.kts +++ b/instrumentation/spring/spring-webflux/spring-webflux-5.3/library/build.gradle.kts @@ -39,7 +39,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/spring/spring-webflux/spring-webflux-5.3/testing/build.gradle.kts b/instrumentation/spring/spring-webflux/spring-webflux-5.3/testing/build.gradle.kts index 0fc385e348b2..9797697baee0 100644 --- a/instrumentation/spring/spring-webflux/spring-webflux-5.3/testing/build.gradle.kts +++ b/instrumentation/spring/spring-webflux/spring-webflux-5.3/testing/build.gradle.kts @@ -4,7 +4,9 @@ plugins { dependencies { implementation("io.opentelemetry.javaagent:opentelemetry-testing-common") - implementation(project(":instrumentation:spring:spring-webflux:spring-webflux-5.3:testing-webflux7")) + implementation( + project(":instrumentation:spring:spring-webflux:spring-webflux-5.3:testing-webflux7"), + ) compileOnly("org.springframework:spring-webflux:5.0.0.RELEASE") diff --git a/instrumentation/spring/spring-webmvc/spring-webmvc-3.1/javaagent/build.gradle.kts b/instrumentation/spring/spring-webmvc/spring-webmvc-3.1/javaagent/build.gradle.kts index edcec2ffbc60..0e919d2a8ce2 100644 --- a/instrumentation/spring/spring-webmvc/spring-webmvc-3.1/javaagent/build.gradle.kts +++ b/instrumentation/spring/spring-webmvc/spring-webmvc-3.1/javaagent/build.gradle.kts @@ -54,9 +54,15 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath - systemProperty("metadataConfig", "otel.instrumentation.spring-webmvc.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.spring-webmvc.experimental-span-attributes=true", + ) jvmArgs("-Dotel.instrumentation.spring-webmvc.experimental-span-attributes=true") } diff --git a/instrumentation/spring/spring-webmvc/spring-webmvc-3.1/wildfly-testing/build.gradle.kts b/instrumentation/spring/spring-webmvc/spring-webmvc-3.1/wildfly-testing/build.gradle.kts index 6790308c4495..ca0a3b8e0ce5 100644 --- a/instrumentation/spring/spring-webmvc/spring-webmvc-3.1/wildfly-testing/build.gradle.kts +++ b/instrumentation/spring/spring-webmvc/spring-webmvc-3.1/wildfly-testing/build.gradle.kts @@ -75,8 +75,10 @@ tasks { jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true") // remove logback-classic from classpath and add modified copy - classpath = classpath.filter { - !it.absolutePath.contains("logback-classic") - }.plus(files(layout.buildDirectory.file("tmp/logback-classic-modified.jar"))) + classpath = + classpath + .filter { + !it.absolutePath.contains("logback-classic") + }.plus(files(layout.buildDirectory.file("tmp/logback-classic-modified.jar"))) } } diff --git a/instrumentation/spring/spring-webmvc/spring-webmvc-6.0/javaagent/build.gradle.kts b/instrumentation/spring/spring-webmvc/spring-webmvc-6.0/javaagent/build.gradle.kts index b65eea5652b9..5d88f78fa823 100644 --- a/instrumentation/spring/spring-webmvc/spring-webmvc-6.0/javaagent/build.gradle.kts +++ b/instrumentation/spring/spring-webmvc/spring-webmvc-6.0/javaagent/build.gradle.kts @@ -53,9 +53,15 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath - systemProperty("metadataConfig", "otel.instrumentation.spring-webmvc.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.spring-webmvc.experimental-span-attributes=true", + ) jvmArgs("-Dotel.instrumentation.spring-webmvc.experimental-span-attributes=true") } diff --git a/instrumentation/spring/spring-ws-2.0/javaagent/build.gradle.kts b/instrumentation/spring/spring-ws-2.0/javaagent/build.gradle.kts index 43638ce32ee3..874579f808c0 100644 --- a/instrumentation/spring/spring-ws-2.0/javaagent/build.gradle.kts +++ b/instrumentation/spring/spring-ws-2.0/javaagent/build.gradle.kts @@ -48,11 +48,17 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true") - systemProperty("metadataConfig", "otel.instrumentation.common.experimental.controller-telemetry.enabled=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.common.experimental.controller-telemetry.enabled=true", + ) } check { diff --git a/instrumentation/spymemcached-2.12/javaagent/build.gradle.kts b/instrumentation/spymemcached-2.12/javaagent/build.gradle.kts index ba61486bdd35..07264f30e673 100644 --- a/instrumentation/spymemcached-2.12/javaagent/build.gradle.kts +++ b/instrumentation/spymemcached-2.12/javaagent/build.gradle.kts @@ -27,15 +27,24 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.spymemcached.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.spymemcached.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.spymemcached.experimental-span-attributes=true", + ) } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database") diff --git a/instrumentation/struts/struts-2.3/javaagent/build.gradle.kts b/instrumentation/struts/struts-2.3/javaagent/build.gradle.kts index bcbc3ac68c1c..bf8f153d1d8d 100644 --- a/instrumentation/struts/struts-2.3/javaagent/build.gradle.kts +++ b/instrumentation/struts/struts-2.3/javaagent/build.gradle.kts @@ -30,6 +30,9 @@ dependencies { tasks.withType().configureEach { jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true") - systemProperty("metadataConfig", "otel.instrumentation.common.experimental.controller-telemetry.enabled=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.common.experimental.controller-telemetry.enabled=true", + ) systemProperty("collectMetadata", otelProps.collectMetadata) } diff --git a/instrumentation/struts/struts-2.3/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/struts/v2_3/GreetingAction.java b/instrumentation/struts/struts-2.3/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/struts/v2_3/GreetingAction.java index 21abf1d876e0..ad5596d3be8d 100644 --- a/instrumentation/struts/struts-2.3/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/struts/v2_3/GreetingAction.java +++ b/instrumentation/struts/struts-2.3/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/struts/v2_3/GreetingAction.java @@ -51,7 +51,8 @@ public String path_param() { controller( ServerEndpoint.PATH_PARAM, () -> - "this does nothing, as responseBody is set in setId, but we need this controller span nevertheless"); + "this does nothing, as responseBody is set in setId, but we need this controller span" + + " nevertheless"); return "greeting"; } diff --git a/instrumentation/struts/struts-7.0/javaagent/build.gradle.kts b/instrumentation/struts/struts-7.0/javaagent/build.gradle.kts index edc67ec439fe..a6e75f4a6d6d 100644 --- a/instrumentation/struts/struts-7.0/javaagent/build.gradle.kts +++ b/instrumentation/struts/struts-7.0/javaagent/build.gradle.kts @@ -33,6 +33,9 @@ dependencies { tasks.withType().configureEach { jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true") - systemProperty("metadataConfig", "otel.instrumentation.common.experimental.controller-telemetry.enabled=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.common.experimental.controller-telemetry.enabled=true", + ) systemProperty("collectMetadata", otelProps.collectMetadata) } diff --git a/instrumentation/struts/struts-7.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/struts/v7_0/GreetingAction.java b/instrumentation/struts/struts-7.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/struts/v7_0/GreetingAction.java index 4b3631be08c6..d104e04d8575 100644 --- a/instrumentation/struts/struts-7.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/struts/v7_0/GreetingAction.java +++ b/instrumentation/struts/struts-7.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/struts/v7_0/GreetingAction.java @@ -52,7 +52,8 @@ public String path_param() { controller( ServerEndpoint.PATH_PARAM, () -> - "this does nothing, as responseBody is set in setId, but we need this controller span nevertheless"); + "this does nothing, as responseBody is set in setId, but we need this controller span" + + " nevertheless"); return "greeting"; } diff --git a/instrumentation/tapestry-5.4/javaagent/build.gradle.kts b/instrumentation/tapestry-5.4/javaagent/build.gradle.kts index 9719b1999758..ca812b41d18b 100644 --- a/instrumentation/tapestry-5.4/javaagent/build.gradle.kts +++ b/instrumentation/tapestry-5.4/javaagent/build.gradle.kts @@ -30,6 +30,9 @@ dependencies { tasks.withType().configureEach { jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true") - systemProperty("metadataConfig", "otel.instrumentation.common.experimental.controller-telemetry.enabled=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.common.experimental.controller-telemetry.enabled=true", + ) systemProperty("collectMetadata", otelProps.collectMetadata) } diff --git a/instrumentation/tomcat/tomcat-jdbc/javaagent/build.gradle.kts b/instrumentation/tomcat/tomcat-jdbc/javaagent/build.gradle.kts index 29579dee2b57..0743af29902d 100644 --- a/instrumentation/tomcat/tomcat-jdbc/javaagent/build.gradle.kts +++ b/instrumentation/tomcat/tomcat-jdbc/javaagent/build.gradle.kts @@ -22,7 +22,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database") diff --git a/instrumentation/twilio-6.6/javaagent/build.gradle.kts b/instrumentation/twilio-6.6/javaagent/build.gradle.kts index ee0556d37d03..2f0850216fc0 100644 --- a/instrumentation/twilio-6.6/javaagent/build.gradle.kts +++ b/instrumentation/twilio-6.6/javaagent/build.gradle.kts @@ -27,11 +27,17 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.twilio.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.twilio.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.twilio.experimental-span-attributes=true", + ) } check { diff --git a/instrumentation/twilio-6.6/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/twilio/TwilioClientTest.java b/instrumentation/twilio-6.6/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/twilio/TwilioClientTest.java index 18005535d4d4..367d5162aa2d 100644 --- a/instrumentation/twilio-6.6/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/twilio/TwilioClientTest.java +++ b/instrumentation/twilio-6.6/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/twilio/TwilioClientTest.java @@ -77,10 +77,12 @@ class TwilioClientTest { + " \"sid\": \"MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\",\n" + " \"status\": \"sent\",\n" + " \"subresource_uris\": {\n" - + " \"media\": \"/2010-04-01/Accounts/AC14984e09e497506cf0d5eb59b1f6ace7/Messages/SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Media.json\"\n" + + " \"media\":" + + " \"/2010-04-01/Accounts/AC14984e09e497506cf0d5eb59b1f6ace7/Messages/SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Media.json\"\n" + " },\n" + " \"to\": \"+14155552345\",\n" - + " \"uri\": \"/2010-04-01/Accounts/AC14984e09e497506cf0d5eb59b1f6ace7/Messages/SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json\"\n" + + " \"uri\":" + + " \"/2010-04-01/Accounts/AC14984e09e497506cf0d5eb59b1f6ace7/Messages/SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json\"\n" + " }"; private static final String CALL_RESPONSE_BODY = " {\n" @@ -106,14 +108,19 @@ class TwilioClientTest { + " \"start_time\": \"Tue, 31 Aug 2010 20:36:29 +0000\",\n" + " \"status\": \"completed\",\n" + " \"subresource_uris\": {\n" - + " \"notifications\": \"/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Notifications.json\",\n" - + " \"recordings\": \"/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Recordings.json\",\n" - + " \"feedback\": \"/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Feedback.json\",\n" - + " \"feedback_summaries\": \"/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/FeedbackSummary.json\"\n" + + " \"notifications\":" + + " \"/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Notifications.json\",\n" + + " \"recordings\":" + + " \"/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Recordings.json\",\n" + + " \"feedback\":" + + " \"/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Feedback.json\",\n" + + " \"feedback_summaries\":" + + " \"/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/FeedbackSummary.json\"\n" + " },\n" + " \"to\": \"+15558675310\",\n" + " \"to_formatted\": \"(555) 867-5310\",\n" - + " \"uri\": \"/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json\"\n" + + " \"uri\":" + + " \"/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json\"\n" + " }"; private static final String ERROR_RESPONSE_BODY = "{\n" diff --git a/instrumentation/vaadin-14.2/javaagent/build.gradle.kts b/instrumentation/vaadin-14.2/javaagent/build.gradle.kts index 9947661d5414..2d56fa9c8f16 100644 --- a/instrumentation/vaadin-14.2/javaagent/build.gradle.kts +++ b/instrumentation/vaadin-14.2/javaagent/build.gradle.kts @@ -91,7 +91,10 @@ tasks { check { if (otelProps.testLatestDeps) { - dependsOn(testing.suites.named("vaadin14LatestTest"), testing.suites.named("vaadinLatestTest")) + dependsOn( + testing.suites.named("vaadin14LatestTest"), + testing.suites.named("vaadinLatestTest"), + ) } else { dependsOn(testing.suites.named("vaadin142Test"), testing.suites.named("vaadin16Test")) } diff --git a/instrumentation/vertx/vertx-http-client/vertx-http-client-3.0/javaagent/build.gradle.kts b/instrumentation/vertx/vertx-http-client/vertx-http-client-3.0/javaagent/build.gradle.kts index 6686ababbed6..3344c68af6d7 100644 --- a/instrumentation/vertx/vertx-http-client/vertx-http-client-3.0/javaagent/build.gradle.kts +++ b/instrumentation/vertx/vertx-http-client/vertx-http-client-3.0/javaagent/build.gradle.kts @@ -21,13 +21,19 @@ dependencies { compileOnly("com.google.auto.value:auto-value-annotations") annotationProcessor("com.google.auto.value:auto-value") - implementation(project(":instrumentation:vertx:vertx-http-client:vertx-http-client-common:javaagent")) + implementation( + project(":instrumentation:vertx:vertx-http-client:vertx-http-client-common:javaagent"), + ) // We need both version as different versions of Vert.x use different versions of Netty testInstrumentation(project(":instrumentation:netty:netty-4.0:javaagent")) testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent")) - testInstrumentation(project(":instrumentation:vertx:vertx-http-client:vertx-http-client-4.0:javaagent")) - testInstrumentation(project(":instrumentation:vertx:vertx-http-client:vertx-http-client-5.0:javaagent")) + testInstrumentation( + project(":instrumentation:vertx:vertx-http-client:vertx-http-client-4.0:javaagent"), + ) + testInstrumentation( + project(":instrumentation:vertx:vertx-http-client:vertx-http-client-5.0:javaagent"), + ) // 3.9.7 Requires Netty 4.1.60, no other version works with it. latestDepTestLibrary(enforcedPlatform("io.netty:netty-bom:4.1.60.Final")) // see vertx-http-client-4.0 module @@ -43,7 +49,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/vertx/vertx-http-client/vertx-http-client-4.0/javaagent/build.gradle.kts b/instrumentation/vertx/vertx-http-client/vertx-http-client-4.0/javaagent/build.gradle.kts index 8300a4000d64..6d8e7aacdde3 100644 --- a/instrumentation/vertx/vertx-http-client/vertx-http-client-4.0/javaagent/build.gradle.kts +++ b/instrumentation/vertx/vertx-http-client/vertx-http-client-4.0/javaagent/build.gradle.kts @@ -17,11 +17,17 @@ dependencies { // vertx-codegen dependency is needed for Xlint's annotation checking library("io.vertx:vertx-codegen:4.0.0") - implementation(project(":instrumentation:vertx:vertx-http-client:vertx-http-client-common:javaagent")) + implementation( + project(":instrumentation:vertx:vertx-http-client:vertx-http-client-common:javaagent"), + ) testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent")) - testInstrumentation(project(":instrumentation:vertx:vertx-http-client:vertx-http-client-3.0:javaagent")) - testInstrumentation(project(":instrumentation:vertx:vertx-http-client:vertx-http-client-5.0:javaagent")) + testInstrumentation( + project(":instrumentation:vertx:vertx-http-client:vertx-http-client-3.0:javaagent"), + ) + testInstrumentation( + project(":instrumentation:vertx:vertx-http-client:vertx-http-client-5.0:javaagent"), + ) latestDepTestLibrary("io.vertx:vertx-core:4.+") // see vertx-http-client-5.0 module latestDepTestLibrary("io.vertx:vertx-codegen:4.+") // see vertx-http-client-5.0 module @@ -33,7 +39,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/vertx/vertx-http-client/vertx-http-client-5.0/javaagent/build.gradle.kts b/instrumentation/vertx/vertx-http-client/vertx-http-client-5.0/javaagent/build.gradle.kts index 34116fad7872..492805bf52c1 100644 --- a/instrumentation/vertx/vertx-http-client/vertx-http-client-5.0/javaagent/build.gradle.kts +++ b/instrumentation/vertx/vertx-http-client/vertx-http-client-5.0/javaagent/build.gradle.kts @@ -21,11 +21,17 @@ dependencies { // vertx-codegen dependency is needed for Xlint's annotation checking library("io.vertx:vertx-codegen:5.0.0") - implementation(project(":instrumentation:vertx:vertx-http-client:vertx-http-client-common:javaagent")) + implementation( + project(":instrumentation:vertx:vertx-http-client:vertx-http-client-common:javaagent"), + ) testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent")) - testInstrumentation(project(":instrumentation:vertx:vertx-http-client:vertx-http-client-3.0:javaagent")) - testInstrumentation(project(":instrumentation:vertx:vertx-http-client:vertx-http-client-4.0:javaagent")) + testInstrumentation( + project(":instrumentation:vertx:vertx-http-client:vertx-http-client-3.0:javaagent"), + ) + testInstrumentation( + project(":instrumentation:vertx:vertx-http-client:vertx-http-client-4.0:javaagent"), + ) } tasks { @@ -34,7 +40,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=service.peer") diff --git a/instrumentation/vertx/vertx-kafka-client-3.6/vertx-kafka-client-3.6-testing/build.gradle.kts b/instrumentation/vertx/vertx-kafka-client-3.6/vertx-kafka-client-3.6-testing/build.gradle.kts index 5eb9b305129f..9ddfc8ca0de8 100644 --- a/instrumentation/vertx/vertx-kafka-client-3.6/vertx-kafka-client-3.6-testing/build.gradle.kts +++ b/instrumentation/vertx/vertx-kafka-client-3.6/vertx-kafka-client-3.6-testing/build.gradle.kts @@ -55,7 +55,10 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.messaging.experimental.receive-telemetry.enabled=true") diff --git a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/build.gradle.kts b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/build.gradle.kts index 20bc7207d230..f21dd5166c0f 100644 --- a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/build.gradle.kts +++ b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/build.gradle.kts @@ -27,7 +27,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database,service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database,service.peer") diff --git a/instrumentation/vertx/vertx-rx-java-3.5/javaagent/build.gradle.kts b/instrumentation/vertx/vertx-rx-java-3.5/javaagent/build.gradle.kts index eb631b7044ef..73e9f03242a3 100644 --- a/instrumentation/vertx/vertx-rx-java-3.5/javaagent/build.gradle.kts +++ b/instrumentation/vertx/vertx-rx-java-3.5/javaagent/build.gradle.kts @@ -22,11 +22,21 @@ dependencies { testInstrumentation(project(":instrumentation:jdbc:javaagent")) testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent")) testInstrumentation(project(":instrumentation:rxjava:rxjava-2.0:javaagent")) - testInstrumentation(project(":instrumentation:vertx:vertx-http-client:vertx-http-client-3.0:javaagent")) - testInstrumentation(project(":instrumentation:vertx:vertx-http-client:vertx-http-client-4.0:javaagent")) - testInstrumentation(project(":instrumentation:vertx:vertx-http-client:vertx-http-client-5.0:javaagent")) - testInstrumentation(project(":instrumentation:vertx:vertx-sql-client:vertx-sql-client-4.0:javaagent")) - testInstrumentation(project(":instrumentation:vertx:vertx-sql-client:vertx-sql-client-5.0:javaagent")) + testInstrumentation( + project(":instrumentation:vertx:vertx-http-client:vertx-http-client-3.0:javaagent"), + ) + testInstrumentation( + project(":instrumentation:vertx:vertx-http-client:vertx-http-client-4.0:javaagent"), + ) + testInstrumentation( + project(":instrumentation:vertx:vertx-http-client:vertx-http-client-5.0:javaagent"), + ) + testInstrumentation( + project(":instrumentation:vertx:vertx-sql-client:vertx-sql-client-4.0:javaagent"), + ) + testInstrumentation( + project(":instrumentation:vertx:vertx-sql-client:vertx-sql-client-5.0:javaagent"), + ) testInstrumentation(project(":instrumentation:vertx:vertx-web-3.0:javaagent")) } @@ -78,14 +88,15 @@ tasks { options.release.set(11) } - val stableSemconvSuites = testing.suites.withType(JvmTestSuite::class).map { suite -> - register("${suite.name}StableSemconv") { - testClassesDirs = suite.sources.output.classesDirs - classpath = suite.sources.runtimeClasspath + val stableSemconvSuites = + testing.suites.withType(JvmTestSuite::class).map { suite -> + register("${suite.name}StableSemconv") { + testClassesDirs = suite.sources.output.classesDirs + classpath = suite.sources.runtimeClasspath - jvmArgs("-Dotel.semconv-stability.opt-in=database") + jvmArgs("-Dotel.semconv-stability.opt-in=database") + } } - } val testJavaVersion = otelProps.testJavaVersion ?: JavaVersion.current() if (!testJavaVersion.isCompatibleWith(JavaVersion.VERSION_11)) { diff --git a/instrumentation/vertx/vertx-rx-java-3.5/javaagent/src/version35Test/java/io/opentelemetry/javaagent/instrumentation/vertx/reactive/server/VertxReactiveWebServer.java b/instrumentation/vertx/vertx-rx-java-3.5/javaagent/src/version35Test/java/io/opentelemetry/javaagent/instrumentation/vertx/reactive/server/VertxReactiveWebServer.java index 03df196662f3..1a1a13f88991 100644 --- a/instrumentation/vertx/vertx-rx-java-3.5/javaagent/src/version35Test/java/io/opentelemetry/javaagent/instrumentation/vertx/reactive/server/VertxReactiveWebServer.java +++ b/instrumentation/vertx/vertx-rx-java-3.5/javaagent/src/version35Test/java/io/opentelemetry/javaagent/instrumentation/vertx/reactive/server/VertxReactiveWebServer.java @@ -160,7 +160,8 @@ private static void setUpInitialData(Handler done, Handler onEr SQLConnection conn = res.result(); conn.execute( - "CREATE TABLE IF NOT EXISTS products(id INT IDENTITY, name VARCHAR(255), price FLOAT, weight INT)", + "CREATE TABLE IF NOT EXISTS products(id INT IDENTITY, name VARCHAR(255), price FLOAT," + + " weight INT)", ddl -> { if (ddl.failed()) { onError.handle(ddl.cause()); @@ -168,7 +169,8 @@ private static void setUpInitialData(Handler done, Handler onEr } conn.execute( - "INSERT INTO products (name, price, weight) VALUES ('Egg Whisk', 3.99, 150), ('Tea Cosy', 5.99, 100), ('Spatula', 1.00, 80)", + "INSERT INTO products (name, price, weight) VALUES ('Egg Whisk', 3.99, 150)," + + " ('Tea Cosy', 5.99, 100), ('Spatula', 1.00, 80)", fixtures -> { if (fixtures.failed()) { onError.handle(fixtures.cause()); diff --git a/instrumentation/vertx/vertx-rx-java-3.5/javaagent/src/version41Test/java/io/opentelemetry/javaagent/instrumentation/vertx/reactive/server/VertxReactiveWebServer.java b/instrumentation/vertx/vertx-rx-java-3.5/javaagent/src/version41Test/java/io/opentelemetry/javaagent/instrumentation/vertx/reactive/server/VertxReactiveWebServer.java index c50b55cd2ad6..8652d7ccbd59 100644 --- a/instrumentation/vertx/vertx-rx-java-3.5/javaagent/src/version41Test/java/io/opentelemetry/javaagent/instrumentation/vertx/reactive/server/VertxReactiveWebServer.java +++ b/instrumentation/vertx/vertx-rx-java-3.5/javaagent/src/version41Test/java/io/opentelemetry/javaagent/instrumentation/vertx/reactive/server/VertxReactiveWebServer.java @@ -160,7 +160,8 @@ private static void setUpInitialData(Handler done, Handler onEr SQLConnection conn = res.result(); conn.execute( - "CREATE TABLE IF NOT EXISTS products(id INT IDENTITY, name VARCHAR(255), price FLOAT, weight INT)", + "CREATE TABLE IF NOT EXISTS products(id INT IDENTITY, name VARCHAR(255), price FLOAT," + + " weight INT)", ddl -> { if (ddl.failed()) { onError.handle(ddl.cause()); @@ -168,7 +169,8 @@ private static void setUpInitialData(Handler done, Handler onEr } conn.execute( - "INSERT INTO products (name, price, weight) VALUES ('Egg Whisk', 3.99, 150), ('Tea Cosy', 5.99, 100), ('Spatula', 1.00, 80)", + "INSERT INTO products (name, price, weight) VALUES ('Egg Whisk', 3.99, 150)," + + " ('Tea Cosy', 5.99, 100), ('Spatula', 1.00, 80)", fixtures -> { if (fixtures.failed()) { onError.handle(fixtures.cause()); diff --git a/instrumentation/vertx/vertx-rx-java-3.5/javaagent/src/version5Test/java/io/opentelemetry/javaagent/instrumentation/vertx/reactive/server/VertxReactiveWebServer.java b/instrumentation/vertx/vertx-rx-java-3.5/javaagent/src/version5Test/java/io/opentelemetry/javaagent/instrumentation/vertx/reactive/server/VertxReactiveWebServer.java index ccf1c2e23db0..3fa6a02f08a7 100644 --- a/instrumentation/vertx/vertx-rx-java-3.5/javaagent/src/version5Test/java/io/opentelemetry/javaagent/instrumentation/vertx/reactive/server/VertxReactiveWebServer.java +++ b/instrumentation/vertx/vertx-rx-java-3.5/javaagent/src/version5Test/java/io/opentelemetry/javaagent/instrumentation/vertx/reactive/server/VertxReactiveWebServer.java @@ -175,7 +175,8 @@ private static void setUpInitialData(Handler done, Handler onEr SqlConnection conn = res.result(); conn.query( - "CREATE TABLE IF NOT EXISTS products(id INT IDENTITY, name VARCHAR(255), price FLOAT, weight INT)") + "CREATE TABLE IF NOT EXISTS products(id INT IDENTITY, name VARCHAR(255)," + + " price FLOAT, weight INT)") .execute() .onComplete( ddl -> { @@ -185,7 +186,8 @@ private static void setUpInitialData(Handler done, Handler onEr } conn.query( - "INSERT INTO products (name, price, weight) VALUES ('Egg Whisk', 3.99, 150), ('Tea Cosy', 5.99, 100), ('Spatula', 1.00, 80)") + "INSERT INTO products (name, price, weight) VALUES ('Egg Whisk'," + + " 3.99, 150), ('Tea Cosy', 5.99, 100), ('Spatula', 1.00, 80)") .execute() .onComplete( fixtures -> { diff --git a/instrumentation/vertx/vertx-sql-client/vertx-sql-client-4.0/javaagent/build.gradle.kts b/instrumentation/vertx/vertx-sql-client/vertx-sql-client-4.0/javaagent/build.gradle.kts index 5c294808539b..24c02319da1f 100644 --- a/instrumentation/vertx/vertx-sql-client/vertx-sql-client-4.0/javaagent/build.gradle.kts +++ b/instrumentation/vertx/vertx-sql-client/vertx-sql-client-4.0/javaagent/build.gradle.kts @@ -16,11 +16,15 @@ dependencies { library("io.vertx:vertx-sql-client:$version") library("io.vertx:vertx-codegen:$version") - implementation(project(":instrumentation:vertx:vertx-sql-client:vertx-sql-client-common:javaagent")) + implementation( + project(":instrumentation:vertx:vertx-sql-client:vertx-sql-client-common:javaagent"), + ) testInstrumentation(project(":instrumentation:jdbc:javaagent")) testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent")) - testInstrumentation(project(":instrumentation:vertx:vertx-sql-client:vertx-sql-client-5.0:javaagent")) + testInstrumentation( + project(":instrumentation:vertx:vertx-sql-client:vertx-sql-client-5.0:javaagent"), + ) testLibrary("io.vertx:vertx-pg-client:$version") testImplementation("io.vertx:vertx-jdbc-client:$version") @@ -40,7 +44,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database,service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database,service.peer") diff --git a/instrumentation/vertx/vertx-sql-client/vertx-sql-client-5.0/javaagent/build.gradle.kts b/instrumentation/vertx/vertx-sql-client/vertx-sql-client-5.0/javaagent/build.gradle.kts index c63bd509cf08..9461840750c0 100644 --- a/instrumentation/vertx/vertx-sql-client/vertx-sql-client-5.0/javaagent/build.gradle.kts +++ b/instrumentation/vertx/vertx-sql-client/vertx-sql-client-5.0/javaagent/build.gradle.kts @@ -20,11 +20,15 @@ dependencies { library("io.vertx:vertx-sql-client:$version") library("io.vertx:vertx-codegen:$version") - implementation(project(":instrumentation:vertx:vertx-sql-client:vertx-sql-client-common:javaagent")) + implementation( + project(":instrumentation:vertx:vertx-sql-client:vertx-sql-client-common:javaagent"), + ) testInstrumentation(project(":instrumentation:jdbc:javaagent")) testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent")) - testInstrumentation(project(":instrumentation:vertx:vertx-sql-client:vertx-sql-client-4.0:javaagent")) + testInstrumentation( + project(":instrumentation:vertx:vertx-sql-client:vertx-sql-client-4.0:javaagent"), + ) testLibrary("io.vertx:vertx-pg-client:$version") testImplementation("io.vertx:vertx-jdbc-client:$version") @@ -39,7 +43,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database,service.peer") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database,service.peer") diff --git a/instrumentation/vibur-dbcp-11.0/javaagent/build.gradle.kts b/instrumentation/vibur-dbcp-11.0/javaagent/build.gradle.kts index 976c29b2a528..21e8e5a7200d 100644 --- a/instrumentation/vibur-dbcp-11.0/javaagent/build.gradle.kts +++ b/instrumentation/vibur-dbcp-11.0/javaagent/build.gradle.kts @@ -25,7 +25,10 @@ tasks { } val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database") diff --git a/instrumentation/vibur-dbcp-11.0/library/build.gradle.kts b/instrumentation/vibur-dbcp-11.0/library/build.gradle.kts index 41cd2789b194..b39f04c7f5de 100644 --- a/instrumentation/vibur-dbcp-11.0/library/build.gradle.kts +++ b/instrumentation/vibur-dbcp-11.0/library/build.gradle.kts @@ -11,7 +11,10 @@ dependencies { tasks { val testStableSemconv by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.semconv-stability.opt-in=database") } diff --git a/instrumentation/xxl-job/xxl-job-1.9.2/javaagent/build.gradle.kts b/instrumentation/xxl-job/xxl-job-1.9.2/javaagent/build.gradle.kts index 2210f874d392..7a2348b141e5 100644 --- a/instrumentation/xxl-job/xxl-job-1.9.2/javaagent/build.gradle.kts +++ b/instrumentation/xxl-job/xxl-job-1.9.2/javaagent/build.gradle.kts @@ -29,7 +29,8 @@ dependencies { // It needs the javax.annotation-api in xxl-job-core 1.9.2. testImplementation("javax.annotation:javax.annotation-api:1.3.2") testImplementation(project(":instrumentation:xxl-job:xxl-job-common:testing")) - latestDepTestLibrary("com.xuxueli:xxl-job-core:2.1.1") { // see xxl-job-2.1.2 module + latestDepTestLibrary("com.xuxueli:xxl-job-core:2.1.1") { + // see xxl-job-2.1.2 module exclude("org.codehaus.groovy", "groovy") } } @@ -43,11 +44,17 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.xxl-job.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.xxl-job.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.xxl-job.experimental-span-attributes=true", + ) } check { diff --git a/instrumentation/xxl-job/xxl-job-2.1.2/javaagent/build.gradle.kts b/instrumentation/xxl-job/xxl-job-2.1.2/javaagent/build.gradle.kts index 50dc0c32a227..ac54c1cceaf2 100644 --- a/instrumentation/xxl-job/xxl-job-2.1.2/javaagent/build.gradle.kts +++ b/instrumentation/xxl-job/xxl-job-2.1.2/javaagent/build.gradle.kts @@ -27,7 +27,8 @@ dependencies { testImplementation("org.apache.groovy:groovy") testImplementation(project(":instrumentation:xxl-job:xxl-job-common:testing")) - latestDepTestLibrary("com.xuxueli:xxl-job-core:2.2.+") { // see xxl-job-2.3.0 module + latestDepTestLibrary("com.xuxueli:xxl-job-core:2.2.+") { + // see xxl-job-2.3.0 module exclude("org.codehaus.groovy", "groovy") } } @@ -41,11 +42,17 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.xxl-job.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.xxl-job.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.xxl-job.experimental-span-attributes=true", + ) } check { diff --git a/instrumentation/xxl-job/xxl-job-2.3.0/javaagent/build.gradle.kts b/instrumentation/xxl-job/xxl-job-2.3.0/javaagent/build.gradle.kts index 6f2dd49586b7..24af3c59c009 100644 --- a/instrumentation/xxl-job/xxl-job-2.3.0/javaagent/build.gradle.kts +++ b/instrumentation/xxl-job/xxl-job-2.3.0/javaagent/build.gradle.kts @@ -52,11 +52,17 @@ tasks { } val testExperimental by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath jvmArgs("-Dotel.instrumentation.xxl-job.experimental-span-attributes=true") - systemProperty("metadataConfig", "otel.instrumentation.xxl-job.experimental-span-attributes=true") + systemProperty( + "metadataConfig", + "otel.instrumentation.xxl-job.experimental-span-attributes=true", + ) } named("compileXxlJob33TestJava", JavaCompile::class).configure { diff --git a/instrumentation/zio/zio-2.0/javaagent/build.gradle.kts b/instrumentation/zio/zio-2.0/javaagent/build.gradle.kts index 7e75590d9042..23a8aa94ab94 100644 --- a/instrumentation/zio/zio-2.0/javaagent/build.gradle.kts +++ b/instrumentation/zio/zio-2.0/javaagent/build.gradle.kts @@ -34,6 +34,8 @@ dependencies { tasks { withType().configureEach { - jvmArgs("-Dio.opentelemetry.javaagent.shaded.io.opentelemetry.context.enableStrictContext=false") + jvmArgs( + "-Dio.opentelemetry.javaagent.shaded.io.opentelemetry.context.enableStrictContext=false", + ) } } diff --git a/javaagent-tooling/build.gradle.kts b/javaagent-tooling/build.gradle.kts index 530f1da46301..4d43d43280c5 100644 --- a/javaagent-tooling/build.gradle.kts +++ b/javaagent-tooling/build.gradle.kts @@ -121,7 +121,7 @@ testing { all { testTask.configure { jvmArgs( - "-Dotel.config.file=$projectDir/src/testDistributionConfig/resources/distribution-config.yaml" + "-Dotel.config.file=$projectDir/src/testDistributionConfig/resources/distribution-config.yaml", ) } } diff --git a/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/config/MethodsConfigurationParser.java b/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/config/MethodsConfigurationParser.java index 7f727fbd2b21..a786eca2b662 100644 --- a/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/config/MethodsConfigurationParser.java +++ b/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/config/MethodsConfigurationParser.java @@ -83,7 +83,8 @@ public static Map> parse(String configString) { } else if (!validateConfigString(configString)) { logger.log( WARNING, - "Invalid trace method config \"{0}\". Must match 'package.Class$Name[method1,method2];*'.", + "Invalid trace method config \"{0}\". Must match" + + " 'package.Class$Name[method1,method2];*'.", configString); return emptyMap(); } else { diff --git a/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/field/VirtualFieldFindRewriter.java b/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/field/VirtualFieldFindRewriter.java index 42c35cca177b..830cc781a52f 100644 --- a/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/field/VirtualFieldFindRewriter.java +++ b/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/field/VirtualFieldFindRewriter.java @@ -127,13 +127,17 @@ public void visitMethodInsn( if (virtualFieldImplementationClass == null) { throw new IllegalStateException( String.format( - "Incorrect VirtualField usage detected. Cannot find implementation for VirtualField<%s, %s>. Was that field registered in %s#registerMuzzleVirtualFields()?", + "Incorrect VirtualField usage detected. Cannot find implementation for" + + " VirtualField<%s, %s>. Was that field registered in" + + " %s#registerMuzzleVirtualFields()?", typeName, fieldTypeName, instrumentationModuleClass.getName())); } if (!virtualFieldMappings.hasMapping(typeName, fieldTypeName)) { throw new IllegalStateException( String.format( - "Incorrect VirtualField usage detected. Cannot find mapping for VirtualField<%s, %s>. Was that field registered in %s#registerMuzzleVirtualFields()?", + "Incorrect VirtualField usage detected. Cannot find mapping for" + + " VirtualField<%s, %s>. Was that field registered in" + + " %s#registerMuzzleVirtualFields()?", typeName, fieldTypeName, instrumentationModuleClass.getName())); } // stack: fieldType | type @@ -146,7 +150,9 @@ public void visitMethodInsn( return; } throw new IllegalStateException( - "Incorrect VirtualField usage detected. Type and field type must be class-literals. Example of correct usage: VirtualField.find(Runnable.class, RunnableContext.class)"); + "Incorrect VirtualField usage detected. Type and field type must be" + + " class-literals. Example of correct usage:" + + " VirtualField.find(Runnable.class, RunnableContext.class)"); } else { super.visitMethodInsn(opcode, owner, name, descriptor, isInterface); } diff --git a/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/instrumentation/http/UrlTemplateRules.java b/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/instrumentation/http/UrlTemplateRules.java index 66071bec0a84..340791d34309 100644 --- a/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/instrumentation/http/UrlTemplateRules.java +++ b/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/instrumentation/http/UrlTemplateRules.java @@ -23,7 +23,8 @@ static List getRules() { static void addRule(Pattern pattern, String replacement, boolean override) { logger.log( FINE, - "Adding http client url template customization rule: pattern=\"{0}\", replacement=\"{1}\", override={2}.", + "Adding http client url template customization rule: pattern=\"{0}\", replacement=\"{1}\"," + + " override={2}.", new Object[] {pattern, replacement, override}); rules.add(new Rule(pattern, replacement, override)); diff --git a/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/instrumentation/indy/IndyBootstrap.java b/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/instrumentation/indy/IndyBootstrap.java index 3f09dfe7fdbf..0b95852d971b 100644 --- a/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/instrumentation/indy/IndyBootstrap.java +++ b/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/instrumentation/indy/IndyBootstrap.java @@ -210,7 +210,8 @@ private static CallSite bootstrapAdvice( // Update the callsite of those to run the actual instrumentation logger.log( FINE, - "Fixing nested instrumentation invokedynamic instruction bootstrapping for instrumented class {0} and advice {1}.{2}, the instrumentation should be active now", + "Fixing nested instrumentation invokedynamic instruction bootstrapping for instrumented" + + " class {0} and advice {1}.{2}, the instrumentation should be active now", new Object[] {lookup.lookupClass().getName(), adviceClassName, adviceMethodName}); nestedBootstrapCallSite.setTarget(methodHandle); MutableCallSite.syncAll(new MutableCallSite[] {nestedBootstrapCallSite}); diff --git a/javaagent-tooling/src/test/java/io/opentelemetry/javaagent/tooling/muzzle/HelperClassPredicateTest.java b/javaagent-tooling/src/test/java/io/opentelemetry/javaagent/tooling/muzzle/HelperClassPredicateTest.java index 1464df66a9c0..003a449fb724 100644 --- a/javaagent-tooling/src/test/java/io/opentelemetry/javaagent/tooling/muzzle/HelperClassPredicateTest.java +++ b/javaagent-tooling/src/test/java/io/opentelemetry/javaagent/tooling/muzzle/HelperClassPredicateTest.java @@ -15,9 +15,11 @@ class HelperClassPredicateTest { @ParameterizedTest(name = "should collect references for {0}") @CsvSource({ - "javaagent instrumentation class, io.opentelemetry.javaagent.instrumentation.some_instrumentation.Advice", + "javaagent instrumentation class," + + " io.opentelemetry.javaagent.instrumentation.some_instrumentation.Advice", "library instrumentation class, io.opentelemetry.instrumentation.LibraryClass", - "additional library instrumentation class, com.example.instrumentation.library.ThirdPartyExternalInstrumentation" + "additional library instrumentation class," + + " com.example.instrumentation.library.ThirdPartyExternalInstrumentation" }) void shouldCollectReferencesFor(String desc, String className) { Predicate additionalLibraryPredicate = diff --git a/javaagent/build.gradle.kts b/javaagent/build.gradle.kts index 435ca4ebcd88..50494bdb09d8 100644 --- a/javaagent/build.gradle.kts +++ b/javaagent/build.gradle.kts @@ -93,17 +93,23 @@ dependencies { baseJavaagentLibs(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.57:javaagent")) baseJavaagentLibs(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.59:javaagent")) baseJavaagentLibs(project(":instrumentation:opentelemetry-instrumentation-api:javaagent")) - baseJavaagentLibs(project(":instrumentation:opentelemetry-instrumentation-annotations-1.16:javaagent")) + baseJavaagentLibs( + project(":instrumentation:opentelemetry-instrumentation-annotations-1.16:javaagent"), + ) baseJavaagentLibs(project(":instrumentation:executors:javaagent")) baseJavaagentLibs(project(":instrumentation:internal:internal-application-logger:javaagent")) - baseJavaagentLibs(project(":instrumentation:internal:internal-class-loader:javaagent", configuration = "shaded")) + baseJavaagentLibs( + project(":instrumentation:internal:internal-class-loader:javaagent", configuration = "shaded"), + ) baseJavaagentLibs(project(":instrumentation:internal:internal-eclipse-osgi-3.6:javaagent")) baseJavaagentLibs(project(":instrumentation:internal:internal-lambda:javaagent")) baseJavaagentLibs(project(":instrumentation:internal:internal-reflection:javaagent")) baseJavaagentLibs(project(":instrumentation:internal:internal-url-class-loader:javaagent")) // concurrentlinkedhashmap-lru and weak-lock-free are copied in to the instrumentation-api module - licenseReportDependencies("com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2") + licenseReportDependencies( + "com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2", + ) licenseReportDependencies("com.blogspot.mydailyjava:weak-lock-free:0.18") licenseReportDependencies(project(":javaagent-internal-logging-simple")) // need the non-shadow versions @@ -265,7 +271,14 @@ tasks { jvmArgs("-Dotel.metrics.exporter=none") jvmArgs("-Dotel.logs.exporter=none") - jvmArgumentProviders.add(JavaagentProvider(shadowJar.flatMap { it.archiveFile }.map { it.asFile.absolutePath })) + jvmArgumentProviders.add( + JavaagentProvider( + shadowJar + .flatMap { + it.archiveFile + }.map { it.asFile.absolutePath }, + ), + ) testLogging { events("started") @@ -282,11 +295,13 @@ tasks { doLast { if (Files.exists(licenseFile)) { val content = String(Files.readAllBytes(licenseFile), Charsets.UTF_8) - val normalized = content.lineSequence() - .map { it.trimEnd() } - .toList() - .dropLastWhile { it.isEmpty() } - .joinToString(newline) + newline + val normalized = + content + .lineSequence() + .map { it.trimEnd() } + .toList() + .dropLastWhile { it.isEmpty() } + .joinToString(newline) + newline Files.write(licenseFile, normalized.toByteArray(Charsets.UTF_8)) } } @@ -311,9 +326,10 @@ tasks { } } - val generateLicenseReportEnabled = providers.provider { - gradle.startParameter.taskNames.any { it.equals("generateLicenseReport") } - } + val generateLicenseReportEnabled = + providers.provider { + gradle.startParameter.taskNames.any { it.equals("generateLicenseReport") } + } val generateLicenseReportTask = named("generateLicenseReport") generateLicenseReportTask.configure { dependsOn(cleanLicenses) @@ -380,7 +396,9 @@ project.afterEvaluate { mustRunAfter(tasks.withType()) } tasks.withType().configureEach { - this.publication.artifact("${layout.buildDirectory.get()}/spdx/opentelemetry-javaagent.spdx.json") { + this.publication.artifact( + "${layout.buildDirectory.get()}/spdx/opentelemetry-javaagent.spdx.json", + ) { classifier = "spdx" extension = "json" } @@ -388,7 +406,10 @@ project.afterEvaluate { } licenseReport { - outputDir = rootProject.layout.projectDirectory.dir("licenses").asFile.absolutePath + outputDir = + rootProject.layout.projectDirectory + .dir("licenses") + .asFile.absolutePath renderers = arrayOf(InventoryMarkdownReportRenderer()) @@ -396,16 +417,18 @@ licenseReport { excludeBoms = true - excludeGroups = arrayOf( - "io\\.opentelemetry\\.instrumentation", - "io\\.opentelemetry\\.javaagent", - "io\\.opentelemetry\\.dummy\\..*", - ) + excludeGroups = + arrayOf( + "io\\.opentelemetry\\.instrumentation", + "io\\.opentelemetry\\.javaagent", + "io\\.opentelemetry\\.dummy\\..*", + ) - excludes = arrayOf( - "io.opentelemetry:opentelemetry-bom-alpha", - "opentelemetry-java-instrumentation:dependencyManagement", - ) + excludes = + arrayOf( + "io.opentelemetry:opentelemetry-bom-alpha", + "opentelemetry-java-instrumentation:dependencyManagement", + ) filters = arrayOf(LicenseBundleNormalizer("$projectDir/license-normalizer-bundle.json", true)) } @@ -442,8 +465,9 @@ class JavaagentProvider( @Input val agentJarPath: Provider, ) : CommandLineArgumentProvider { - override fun asArguments(): Iterable = listOf( - "-javaagent:${agentJarPath.get()}", - "-Dotel.javaagent.testing.transform-safe-logging.enabled=true" - ) + override fun asArguments(): Iterable = + listOf( + "-javaagent:${agentJarPath.get()}", + "-Dotel.javaagent.testing.transform-safe-logging.enabled=true", + ) } diff --git a/mise.toml b/mise.toml index 6334e3b5366c..d2e95f4167be 100644 --- a/mise.toml +++ b/mise.toml @@ -1,6 +1,24 @@ [tools] + +# Linters +actionlint = "1.7.12" +biome = "2.4.12" +"cargo:xmloxide" = "0.4.2" +"cargo:yaml-lint" = "0.1.0" +editorconfig-checker = "3.6.1" +"github:google/google-java-format" = "1.35.0" +"github:grafana/flint" = "0.20.4" +"github:pinterest/ktlint" = "1.8.0" +hadolint = "2.14.0" lychee = "0.23.0" -markdownlint-cli2 = "0.22.0" +"pipx:codespell" = "2.4.2" +"pipx:ruff" = "0.15.11" +rumdl = "0.1.80" +shellcheck = "0.11.0" +shfmt = "3.13.1" + +[env] +FLINT_CONFIG_DIR = ".github/config" [settings] # Only install tools explicitly defined in the [tools] section above @@ -12,7 +30,11 @@ windows_executable_extensions = ["sh"] windows_default_file_shell_args = "bash" use_file_shell_for_executable_tasks = true -# Pick the tasks you need from flint (https://github.com/grafana/flint) -[tasks."lint:links"] -description = "Check for broken links in changed files + all local links" -file = "https://raw.githubusercontent.com/grafana/flint/eded4cd370c729289a6de327a1a26831e10a39b9/tasks/lint/links.sh" # v0.20.2 +[tasks.lint] +run = "flint run" + +[tasks."lint:fix"] +run = "flint run --fix" + +[tasks."lint:pre-commit"] +run = "flint run --fix --fast-only" diff --git a/muzzle/src/test/java/io/opentelemetry/javaagent/tooling/muzzle/ReferenceMatcherTest.java b/muzzle/src/test/java/io/opentelemetry/javaagent/tooling/muzzle/ReferenceMatcherTest.java index d0cfa7e1bedd..389e67d18845 100644 --- a/muzzle/src/test/java/io/opentelemetry/javaagent/tooling/muzzle/ReferenceMatcherTest.java +++ b/muzzle/src/test/java/io/opentelemetry/javaagent/tooling/muzzle/ReferenceMatcherTest.java @@ -467,10 +467,14 @@ void shouldCheckHelperClassWhetherUsedFieldsAreDeclaredInTheSuperClass(String cl @CsvSource( delimiter = '|', value = { - "internal helper, different field name | io.opentelemetry.instrumentation.Helper | differentField | Ljava/lang/Integer;", - "internal helper, different field type | io.opentelemetry.instrumentation.Helper | field | Lcom/external/DifferentType;", - "external helper, different field name | com.external.otel.instrumentation.Helper | differentField | Ljava/lang/Integer;", - "external helper, different field type | com.external.otel.instrumentation.Helper | field | Lcom/external/DifferentType;" + "internal helper, different field name | io.opentelemetry.instrumentation.Helper |" + + " differentField | Ljava/lang/Integer;", + "internal helper, different field type | io.opentelemetry.instrumentation.Helper | field |" + + " Lcom/external/DifferentType;", + "external helper, different field name | com.external.otel.instrumentation.Helper |" + + " differentField | Ljava/lang/Integer;", + "external helper, different field type | com.external.otel.instrumentation.Helper | field |" + + " Lcom/external/DifferentType;" }) void shouldFailHelperClassWhenItUsesFieldsUndeclaredInTheSuperClass( String testName, String className, String fieldName, String fieldType) { diff --git a/opentelemetry-ext-annotations-shaded-for-instrumenting/build.gradle.kts b/opentelemetry-ext-annotations-shaded-for-instrumenting/build.gradle.kts index f7dfbb6e66f6..e7ae17695c47 100644 --- a/opentelemetry-ext-annotations-shaded-for-instrumenting/build.gradle.kts +++ b/opentelemetry-ext-annotations-shaded-for-instrumenting/build.gradle.kts @@ -17,7 +17,13 @@ dependencies { // (see more explanation in opentelemetry-api-1.0.gradle) tasks { shadowJar { - relocate("io.opentelemetry.extension.annotations", "application.io.opentelemetry.extension.annotations") - relocate("io.opentelemetry.api.trace.SpanKind", "application.io.opentelemetry.api.trace.SpanKind") + relocate( + "io.opentelemetry.extension.annotations", + "application.io.opentelemetry.extension.annotations", + ) + relocate( + "io.opentelemetry.api.trace.SpanKind", + "application.io.opentelemetry.api.trace.SpanKind", + ) } } diff --git a/opentelemetry-instrumentation-annotations-shaded-for-instrumenting/build.gradle.kts b/opentelemetry-instrumentation-annotations-shaded-for-instrumenting/build.gradle.kts index beccba0fb933..9a2aec9a6995 100644 --- a/opentelemetry-instrumentation-annotations-shaded-for-instrumenting/build.gradle.kts +++ b/opentelemetry-instrumentation-annotations-shaded-for-instrumenting/build.gradle.kts @@ -17,7 +17,13 @@ dependencies { // (see more explanation in opentelemetry-api-1.0.gradle) tasks { shadowJar { - relocate("io.opentelemetry.instrumentation.annotations", "application.io.opentelemetry.instrumentation.annotations") - relocate("io.opentelemetry.api.trace.SpanKind", "application.io.opentelemetry.api.trace.SpanKind") + relocate( + "io.opentelemetry.instrumentation.annotations", + "application.io.opentelemetry.instrumentation.annotations", + ) + relocate( + "io.opentelemetry.api.trace.SpanKind", + "application.io.opentelemetry.api.trace.SpanKind", + ) } } diff --git a/opentelemetry-instrumentation-api-shaded-for-instrumenting/build.gradle.kts b/opentelemetry-instrumentation-api-shaded-for-instrumenting/build.gradle.kts index a632509dab14..abc79076c0ee 100644 --- a/opentelemetry-instrumentation-api-shaded-for-instrumenting/build.gradle.kts +++ b/opentelemetry-instrumentation-api-shaded-for-instrumenting/build.gradle.kts @@ -17,6 +17,9 @@ dependencies { // (see more explanation in opentelemetry-api-1.0.gradle) tasks { shadowJar { - relocate("io.opentelemetry.instrumentation.api", "application.io.opentelemetry.instrumentation.api") + relocate( + "io.opentelemetry.instrumentation.api", + "application.io.opentelemetry.instrumentation.api", + ) } } diff --git a/settings.gradle.kts b/settings.gradle.kts index 215967cd25be..ca5eb909fcfa 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -32,7 +32,11 @@ dependencyResolutionManagement { } versionCatalogs { - fun addSpringBootCatalog(name: String, minVersion: String, maxVersion: String) { + fun addSpringBootCatalog( + name: String, + minVersion: String, + maxVersion: String, + ) { val latestDepTest = gradle.startParameter.projectProperties["testLatestDeps"] == "true" create(name) { val version = diff --git a/smoke-tests-otel-starter/spring-boot-3.2/build.gradle.kts b/smoke-tests-otel-starter/spring-boot-3.2/build.gradle.kts index d921db5fee2f..d1b60d15eb6c 100644 --- a/smoke-tests-otel-starter/spring-boot-3.2/build.gradle.kts +++ b/smoke-tests-otel-starter/spring-boot-3.2/build.gradle.kts @@ -66,7 +66,8 @@ plugins.withId("org.graalvm.buildtools.native") { } // See https://github.com/graalvm/native-build-tools/issues/572 - (extensions.getByName("graalvmNative") as ExtensionAware).extensions + (extensions.getByName("graalvmNative") as ExtensionAware) + .extensions .configure { enabled.set(false) } diff --git a/smoke-tests-otel-starter/spring-boot-3/build.gradle.kts b/smoke-tests-otel-starter/spring-boot-3/build.gradle.kts index 7751daaec1c3..89b001e39139 100644 --- a/smoke-tests-otel-starter/spring-boot-3/build.gradle.kts +++ b/smoke-tests-otel-starter/spring-boot-3/build.gradle.kts @@ -70,7 +70,8 @@ plugins.withId("org.graalvm.buildtools.native") { } // See https://github.com/graalvm/native-build-tools/issues/572 - (extensions.getByName("graalvmNative") as ExtensionAware).extensions + (extensions.getByName("graalvmNative") as ExtensionAware) + .extensions .configure { enabled.set(false) } diff --git a/smoke-tests-otel-starter/spring-boot-4/build.gradle.kts b/smoke-tests-otel-starter/spring-boot-4/build.gradle.kts index e16baa43b517..2f46ae1ca5c2 100644 --- a/smoke-tests-otel-starter/spring-boot-4/build.gradle.kts +++ b/smoke-tests-otel-starter/spring-boot-4/build.gradle.kts @@ -92,7 +92,8 @@ plugins.withId("org.graalvm.buildtools.native") { } // See https://github.com/graalvm/native-build-tools/issues/572 - (extensions.getByName("graalvmNative") as ExtensionAware).extensions + (extensions.getByName("graalvmNative") as ExtensionAware) + .extensions .configure { enabled.set(false) } diff --git a/smoke-tests-otel-starter/spring-boot-common/src/main/java/io/opentelemetry/spring/smoketest/AbstractOtelSpringStarterSmokeTest.java b/smoke-tests-otel-starter/spring-boot-common/src/main/java/io/opentelemetry/spring/smoketest/AbstractOtelSpringStarterSmokeTest.java index 6734e333c962..5cbef7881735 100644 --- a/smoke-tests-otel-starter/spring-boot-common/src/main/java/io/opentelemetry/spring/smoketest/AbstractOtelSpringStarterSmokeTest.java +++ b/smoke-tests-otel-starter/spring-boot-common/src/main/java/io/opentelemetry/spring/smoketest/AbstractOtelSpringStarterSmokeTest.java @@ -106,7 +106,8 @@ public void loadData() { jdbcTemplate .getObject() .execute( - "create table customer (id bigint not null, name varchar not null, primary key (id))"); + "create table customer (id bigint not null, name varchar not null, primary key" + + " (id))"); } @Bean @@ -188,7 +189,8 @@ void shouldSendTelemetry() throws InterruptedException, TimeoutException { .hasKind(SpanKind.CLIENT) .hasAttribute( DB_STATEMENT, - "create table customer (id bigint not null, name varchar not null, primary key (id))")), + "create table customer (id bigint not null, name varchar not null," + + " primary key (id))")), traceAssert -> traceAssert.hasSpansSatisfyingExactly( clientSpan -> diff --git a/smoke-tests-otel-starter/spring-boot-reactive-2/build.gradle.kts b/smoke-tests-otel-starter/spring-boot-reactive-2/build.gradle.kts index 7830061a1987..1a6dd41b7fac 100644 --- a/smoke-tests-otel-starter/spring-boot-reactive-2/build.gradle.kts +++ b/smoke-tests-otel-starter/spring-boot-reactive-2/build.gradle.kts @@ -6,7 +6,12 @@ description = "smoke-tests-otel-starter-spring-boot-reactive-2" dependencies { implementation(project(":instrumentation:spring:starters:spring-boot-starter")) - implementation(platform("org.springframework.boot:spring-boot-dependencies:" + if (otelProps.testLatestDeps) "2.+" else "2.6.15")) + implementation( + platform( + "org.springframework.boot:spring-boot-dependencies:" + + if (otelProps.testLatestDeps) "2.+" else "2.6.15", + ), + ) implementation(project(":smoke-tests-otel-starter:spring-boot-reactive-common")) implementation("org.springframework.boot:spring-boot-starter-webflux") diff --git a/smoke-tests-otel-starter/spring-boot-reactive-3/build.gradle.kts b/smoke-tests-otel-starter/spring-boot-reactive-3/build.gradle.kts index 9b6d99f306c2..9d4ecb7dc5be 100644 --- a/smoke-tests-otel-starter/spring-boot-reactive-3/build.gradle.kts +++ b/smoke-tests-otel-starter/spring-boot-reactive-3/build.gradle.kts @@ -61,7 +61,8 @@ plugins.withId("org.graalvm.buildtools.native") { } // See https://github.com/graalvm/native-build-tools/issues/572 - (extensions.getByName("graalvmNative") as ExtensionAware).extensions + (extensions.getByName("graalvmNative") as ExtensionAware) + .extensions .configure { enabled.set(false) } diff --git a/smoke-tests-otel-starter/spring-smoke-testing/src/main/java/io/opentelemetry/spring/smoketest/AbstractSpringStarterSmokeTest.java b/smoke-tests-otel-starter/spring-smoke-testing/src/main/java/io/opentelemetry/spring/smoketest/AbstractSpringStarterSmokeTest.java index 6fd9f57f67be..a8a350a7b64f 100644 --- a/smoke-tests-otel-starter/spring-smoke-testing/src/main/java/io/opentelemetry/spring/smoketest/AbstractSpringStarterSmokeTest.java +++ b/smoke-tests-otel-starter/spring-smoke-testing/src/main/java/io/opentelemetry/spring/smoketest/AbstractSpringStarterSmokeTest.java @@ -30,7 +30,10 @@ public abstract class AbstractSpringStarterSmokeTest { "The DescribeTopicPartitions API is not supported, using Metadata API to describe topics", // triggered by // https://github.com/spring-projects/spring-data-mongodb/blob/9a40b7e701871affb88c691b8ac8c044155e421b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MongoConverters.java#L473 - "Registering converter from interface java.util.List to interface org.springframework.data.domain.Vector as reading converter although it doesn't convert from a store-supported type; You might want to check your annotation setup at the converter implementation", + "Registering converter from interface java.util.List to interface" + + " org.springframework.data.domain.Vector as reading converter although it doesn't" + + " convert from a store-supported type; You might want to check your annotation" + + " setup at the converter implementation", "Node may not be available.", "Could not configure topics", "(id: -1 rack: null isFenced: false) disconnected"); diff --git a/smoke-tests/build.gradle.kts b/smoke-tests/build.gradle.kts index 0f97ef2e2678..07796f41a45d 100644 --- a/smoke-tests/build.gradle.kts +++ b/smoke-tests/build.gradle.kts @@ -43,15 +43,16 @@ tasks { // In addition to that we disable them on normal test task to only run when explicitly requested. enabled = enabled && gradle.startParameter.taskNames.any { it.startsWith(":smoke-tests:") } - val suites = mapOf( - "payara" to listOf("**/Payara*.*"), - "jetty" to listOf("**/Jetty*.*"), - "liberty" to listOf("**/Liberty*.*"), - "tomcat" to listOf("**/Tomcat*.*"), - "tomee" to listOf("**/Tomee*.*"), - "websphere" to listOf("**/Websphere*.*"), - "wildfly" to listOf("**/Wildfly*.*"), - ) + val suites = + mapOf( + "payara" to listOf("**/Payara*.*"), + "jetty" to listOf("**/Jetty*.*"), + "liberty" to listOf("**/Liberty*.*"), + "tomcat" to listOf("**/Tomcat*.*"), + "tomee" to listOf("**/Tomee*.*"), + "websphere" to listOf("**/Websphere*.*"), + "wildfly" to listOf("**/Wildfly*.*"), + ) val smokeTestSuite: String? by project val skipOpenJ9SmokeTests = (findProperty("skipOpenJ9SmokeTests") as String?) == "true" @@ -78,7 +79,8 @@ tasks { val shadowTask = project(":javaagent").tasks.named("shadowJar") val agentJarPath = shadowTask.flatMap { it.archiveFile } - inputs.files(agentJarPath) + inputs + .files(agentJarPath) .withPropertyName("javaagent") .withNormalizer(ClasspathNormalizer::class) @@ -94,7 +96,7 @@ tasks { jvmArgs( "-Dio.opentelemetry.smoketest.agent.shadowJar.path=${agentJarPath.get()}", "-Dio.opentelemetry.smoketest.extension.path=${extensionJarPath.get()}", - "-Dio.opentelemetry.smoketest.extension.testapp.path=${extensionTestAppJarPath.get()}" + "-Dio.opentelemetry.smoketest.extension.testapp.path=${extensionTestAppJarPath.get()}", ) } } diff --git a/smoke-tests/images/early-jdk8/build.gradle.kts b/smoke-tests/images/early-jdk8/build.gradle.kts index bcffd705ffb1..ad02904261eb 100644 --- a/smoke-tests/images/early-jdk8/build.gradle.kts +++ b/smoke-tests/images/early-jdk8/build.gradle.kts @@ -7,8 +7,9 @@ plugins { id("com.bmuschko.docker-remote-api") } -val extraTag = findProperty("extraTag") - ?: DateTimeFormatter.ofPattern("yyyyMMdd.HHmmSS").format(LocalDateTime.now()) +val extraTag = + findProperty("extraTag") + ?: DateTimeFormatter.ofPattern("yyyyMMdd.HHmmSS").format(LocalDateTime.now()) tasks { val dockerWorkingDir = layout.buildDirectory.dir("docker") @@ -18,7 +19,8 @@ tasks { from("Dockerfile") } - val repo = System.getenv("GITHUB_REPOSITORY") ?: "open-telemetry/opentelemetry-java-instrumentation" + val repo = + System.getenv("GITHUB_REPOSITORY") ?: "open-telemetry/opentelemetry-java-instrumentation" val imageBuild by registering(DockerBuildImage::class) { dependsOn(imagePrepare) diff --git a/smoke-tests/images/fake-backend/build.gradle.kts b/smoke-tests/images/fake-backend/build.gradle.kts index 00d2e8e71abc..ea172378701c 100644 --- a/smoke-tests/images/fake-backend/build.gradle.kts +++ b/smoke-tests/images/fake-backend/build.gradle.kts @@ -17,8 +17,9 @@ dependencies { runtimeOnly("org.slf4j:slf4j-simple") } -val extraTag = findProperty("extraTag") - ?: DateTimeFormatter.ofPattern("yyyyMMdd.HHmmSS").format(LocalDateTime.now()) +val extraTag = + findProperty("extraTag") + ?: DateTimeFormatter.ofPattern("yyyyMMdd.HHmmSS").format(LocalDateTime.now()) val repo = System.getenv("GITHUB_REPOSITORY") ?: "open-telemetry/opentelemetry-java-instrumentation" diff --git a/smoke-tests/images/grpc/build.gradle.kts b/smoke-tests/images/grpc/build.gradle.kts index 825eb7f3202a..96336599ba20 100644 --- a/smoke-tests/images/grpc/build.gradle.kts +++ b/smoke-tests/images/grpc/build.gradle.kts @@ -26,8 +26,9 @@ dependencies { val targetJDK = project.findProperty("targetJDK") ?: "11" -val tag = findProperty("tag") - ?: DateTimeFormatter.ofPattern("yyyyMMdd.HHmmSS").format(LocalDateTime.now()) +val tag = + findProperty("tag") + ?: DateTimeFormatter.ofPattern("yyyyMMdd.HHmmSS").format(LocalDateTime.now()) java { // this is needed to avoid jib failing with diff --git a/smoke-tests/images/play/build.gradle.kts b/smoke-tests/images/play/build.gradle.kts index 6853404a1c71..f494b613ceff 100644 --- a/smoke-tests/images/play/build.gradle.kts +++ b/smoke-tests/images/play/build.gradle.kts @@ -31,8 +31,9 @@ dependencies { val targetJDK = (project.findProperty("targetJDK") as String?) ?: "17" val javaLanguageVersion = targetJDK.toIntOrNull() ?: 17 -val tag = findProperty("tag") - ?: DateTimeFormatter.ofPattern("yyyyMMdd.HHmmSS").format(LocalDateTime.now()) +val tag = + findProperty("tag") + ?: DateTimeFormatter.ofPattern("yyyyMMdd.HHmmSS").format(LocalDateTime.now()) java { toolchain.languageVersion.set(JavaLanguageVersion.of(javaLanguageVersion)) diff --git a/smoke-tests/images/quarkus/build.gradle.kts b/smoke-tests/images/quarkus/build.gradle.kts index 911f2fcbc717..cfec938bb1ab 100644 --- a/smoke-tests/images/quarkus/build.gradle.kts +++ b/smoke-tests/images/quarkus/build.gradle.kts @@ -28,8 +28,9 @@ dependencies { // Quarkus 3.7+ requires Java 17+ val targetJDK = project.findProperty("targetJDK") ?: "17" -val tag = findProperty("tag") - ?: DateTimeFormatter.ofPattern("yyyyMMdd.HHmmSS").format(LocalDateTime.now()) +val tag = + findProperty("tag") + ?: DateTimeFormatter.ofPattern("yyyyMMdd.HHmmSS").format(LocalDateTime.now()) java { // this is needed to avoid jib failing with diff --git a/smoke-tests/images/security-manager/build.gradle.kts b/smoke-tests/images/security-manager/build.gradle.kts index 2fd845a538b9..9ddfedf2c97a 100644 --- a/smoke-tests/images/security-manager/build.gradle.kts +++ b/smoke-tests/images/security-manager/build.gradle.kts @@ -16,8 +16,9 @@ dependencies { val targetJDK = project.findProperty("targetJDK") ?: "11" -val tag = findProperty("tag") - ?: DateTimeFormatter.ofPattern("yyyyMMdd.HHmmSS").format(LocalDateTime.now()) +val tag = + findProperty("tag") + ?: DateTimeFormatter.ofPattern("yyyyMMdd.HHmmSS").format(LocalDateTime.now()) java { // needed by jib to detect java version used in project @@ -32,7 +33,8 @@ jib { from.image = "eclipse-temurin:$targetJDK" to.image = "ghcr.io/$repo/smoke-test-security-manager:jdk$targetJDK-$tag" container.mainClass = "io.opentelemetry.smoketest.securitymanager.Main" - container.jvmFlags = listOf("-Djava.security.manager", "-Djava.security.policy=/app/resources/security.policy") + container.jvmFlags = + listOf("-Djava.security.manager", "-Djava.security.policy=/app/resources/security.policy") } tasks { diff --git a/smoke-tests/images/servlet/build.gradle.kts b/smoke-tests/images/servlet/build.gradle.kts index 43e3aab81ada..3e8ae380b936 100644 --- a/smoke-tests/images/servlet/build.gradle.kts +++ b/smoke-tests/images/servlet/build.gradle.kts @@ -15,7 +15,7 @@ data class ImageTarget( val jdk: List, val args: Map = emptyMap(), val war: String = "servlet-3.0", - val windows: Boolean = true + val windows: Boolean = true, ) abstract class DockerBuildService : BuildService @@ -24,162 +24,186 @@ gradle.sharedServices.registerIfAbsent("dockerBuildService", DockerBuildService: maxParallelUsages.set(1) } -val extraTag = findProperty("extraTag") - ?: java.time.format.DateTimeFormatter.ofPattern("yyyyMMdd.HHmmSS").format(java.time.LocalDateTime.now()) +val extraTag = + findProperty("extraTag") + ?: java.time.format.DateTimeFormatter + .ofPattern( + "yyyyMMdd.HHmmSS", + ).format(java.time.LocalDateTime.now()) val latestJava = "25" // renovate(java-version) // Each line under appserver describes one matrix of (version x vm x jdk), dockerfile key overrides // Dockerfile name, args key passes raw arguments to docker build -val targets = mapOf( - "jetty" to listOf( - ImageTarget( - listOf("9.4.58"), - listOf("hotspot", "openj9"), - listOf("8", "11", "17", "21", latestJava), - mapOf("sourceVersion" to "9.4.58.v20250814") - ), - ImageTarget( - listOf("10.0.26"), - listOf("hotspot", "openj9"), - listOf("11", "17", "21", latestJava), - mapOf("sourceVersion" to "10.0.26") - ), - ImageTarget( - listOf("11.0.26"), - listOf("hotspot", "openj9"), - listOf("11", "17", "21", latestJava), - mapOf("sourceVersion" to "11.0.26"), - "servlet-5.0" - ), - ImageTarget( - listOf("12.0.28"), - listOf("hotspot", "openj9"), - listOf("17", "21", latestJava), - mapOf("sourceVersion" to "12.0.28"), - "servlet-5.0" - ), - ), - "liberty" to listOf( - ImageTarget( - listOf("open-liberty:20.0.0.12-full-java11-openj9@sha256:2fa4af95d6c48e3db79edfd2b8a9c71e26c63a68c3fcae92f222fbb42c469ed2"), - listOf("hotspot", "openj9"), - listOf("8", "11") - ), - ImageTarget( - listOf("open-liberty:21.0.0.12-full-java11-openj9@sha256:eb014c600b5e08b799cb0c5781e606cf1e7a28ad913ba956c9d9e7f8a2f528dc"), - listOf("hotspot", "openj9"), - listOf("8", "11", "17") - ), - ImageTarget( - listOf("open-liberty:22.0.0.12-full-java11-openj9@sha256:a06f1da35a564f00354b86c7d01d8cc9d6eef156ce88d5b59605c5c02bf48c72"), - listOf("hotspot", "openj9"), - listOf("8", "11", "17") - ), - ImageTarget( - listOf("open-liberty:23.0.0.12-full-java11-openj9@sha256:cd6aa69cffffb45427cbb6a5640cd00b13c98064f296a66894ea1decd181e1c3"), - listOf("hotspot", "openj9"), - listOf("8", "11", "17", "21") - ), - ), - "payara" to listOf( - ImageTarget( +val targets = + mapOf( + "jetty" to listOf( - "payara/server-full:5.2020.6@sha256:8c8f054ecbfb340b60961d7ffea2d223cea1afe6183f6986f4806de5c0bc9419", - "payara/server-full:5.2021.8@sha256:ffc915a7243b27504c13c4bd4adb3da55c6c08a93ac05685afea3ea77380109d" + ImageTarget( + listOf("9.4.58"), + listOf("hotspot", "openj9"), + listOf("8", "11", "17", "21", latestJava), + mapOf("sourceVersion" to "9.4.58.v20250814"), + ), + ImageTarget( + listOf("10.0.26"), + listOf("hotspot", "openj9"), + listOf("11", "17", "21", latestJava), + mapOf("sourceVersion" to "10.0.26"), + ), + ImageTarget( + listOf("11.0.26"), + listOf("hotspot", "openj9"), + listOf("11", "17", "21", latestJava), + mapOf("sourceVersion" to "11.0.26"), + "servlet-5.0", + ), + ImageTarget( + listOf("12.0.28"), + listOf("hotspot", "openj9"), + listOf("17", "21", latestJava), + mapOf("sourceVersion" to "12.0.28"), + "servlet-5.0", + ), ), - listOf("hotspot", "openj9"), - listOf("8", "11") - ), - // Test application is not deployed when server is sarted with hotspot jdk version 21 - ImageTarget( - listOf("payara/server-full:6.2023.12@sha256:5c382db1f5bad8bef693dbcd0fed299844690839f4894e07c248de5f4b186b9b"), - listOf("hotspot"), - listOf("11", "17"), - war = "servlet-5.0" - ), - ImageTarget( - listOf("payara/server-full:6.2023.12@sha256:5c382db1f5bad8bef693dbcd0fed299844690839f4894e07c248de5f4b186b9b"), - listOf("openj9"), - listOf("11", "17", "21"), - war = "servlet-5.0" - ) - ), - "tomcat" to listOf( - ImageTarget( - listOf("7.0.109"), - listOf("hotspot", "openj9"), - listOf("8"), - mapOf("majorVersion" to "7") - ), - ImageTarget( - listOf("8.5.98"), - listOf("hotspot", "openj9"), - listOf("8", "11", "17", "21", latestJava), - mapOf("majorVersion" to "8") - ), - ImageTarget( - listOf("9.0.111"), - listOf("hotspot", "openj9"), - listOf("8", "11", "17", "21", latestJava), - mapOf("majorVersion" to "9") - ), - ImageTarget( - listOf("10.1.48"), - listOf("hotspot", "openj9"), - listOf("11", "17", "21", latestJava), - mapOf("majorVersion" to "10"), - "servlet-5.0" - ), - ), - "tomee" to listOf( - ImageTarget( - listOf("7.0.9", "7.1.4"), - listOf("hotspot", "openj9"), - listOf("8") - ), - ImageTarget( - listOf("8.0.16"), - listOf("hotspot", "openj9"), - listOf("8", "11", "17", "21", latestJava) - ), - ImageTarget( - listOf("9.1.3"), - listOf("hotspot", "openj9"), - listOf("11", "17", "21", latestJava), - war = "servlet-5.0" - ), - ), - "websphere" to listOf( - ImageTarget( + "liberty" to listOf( - "ibmcom/websphere-traditional:8.5.5.22@sha256:2a385c56f3e6781cc595d873473efd5ef7cb4f34e88c6cf8381121332fb49c9c", - "ibmcom/websphere-traditional:9.0.5.14@sha256:7e569af2f4050bb0f3ac0fcab113e2dee20d9d6bdc4061cef4b97b79c2ea4fdd" + ImageTarget( + listOf( + "open-liberty:20.0.0.12-full-java11-openj9@sha256:2fa4af95d6c48e3db79edfd2b8a9c71e26c63a68c3fcae92f222fbb42c469ed2", + ), + listOf("hotspot", "openj9"), + listOf("8", "11"), + ), + ImageTarget( + listOf( + "open-liberty:21.0.0.12-full-java11-openj9@sha256:eb014c600b5e08b799cb0c5781e606cf1e7a28ad913ba956c9d9e7f8a2f528dc", + ), + listOf("hotspot", "openj9"), + listOf("8", "11", "17"), + ), + ImageTarget( + listOf( + "open-liberty:22.0.0.12-full-java11-openj9@sha256:a06f1da35a564f00354b86c7d01d8cc9d6eef156ce88d5b59605c5c02bf48c72", + ), + listOf("hotspot", "openj9"), + listOf("8", "11", "17"), + ), + ImageTarget( + listOf( + "open-liberty:23.0.0.12-full-java11-openj9@sha256:cd6aa69cffffb45427cbb6a5640cd00b13c98064f296a66894ea1decd181e1c3", + ), + listOf("hotspot", "openj9"), + listOf("8", "11", "17", "21"), + ), ), - listOf("openj9"), - listOf("8"), - windows = false - ), - ), - "wildfly" to listOf( - ImageTarget( - listOf("13.0.0.Final"), - listOf("hotspot", "openj9"), - listOf("8") - ), - ImageTarget( - listOf("17.0.1.Final", "21.0.0.Final"), - listOf("hotspot", "openj9"), - listOf("8", "11", "17", "21") - ), - ImageTarget( - listOf("28.0.1.Final", "29.0.1.Final", "30.0.1.Final"), - listOf("hotspot", "openj9"), - listOf("11", "17", "21"), - war = "servlet-5.0" - ), - ), -) + "payara" to + listOf( + ImageTarget( + listOf( + "payara/server-full:5.2020.6@sha256:8c8f054ecbfb340b60961d7ffea2d223cea1afe6183f6986f4806de5c0bc9419", + "payara/server-full:5.2021.8@sha256:ffc915a7243b27504c13c4bd4adb3da55c6c08a93ac05685afea3ea77380109d", + ), + listOf("hotspot", "openj9"), + listOf("8", "11"), + ), + // Test application is not deployed when server is sarted with hotspot jdk version 21 + ImageTarget( + listOf( + "payara/server-full:6.2023.12@sha256:5c382db1f5bad8bef693dbcd0fed299844690839f4894e07c248de5f4b186b9b", + ), + listOf("hotspot"), + listOf("11", "17"), + war = "servlet-5.0", + ), + ImageTarget( + listOf( + "payara/server-full:6.2023.12@sha256:5c382db1f5bad8bef693dbcd0fed299844690839f4894e07c248de5f4b186b9b", + ), + listOf("openj9"), + listOf("11", "17", "21"), + war = "servlet-5.0", + ), + ), + "tomcat" to + listOf( + ImageTarget( + listOf("7.0.109"), + listOf("hotspot", "openj9"), + listOf("8"), + mapOf("majorVersion" to "7"), + ), + ImageTarget( + listOf("8.5.98"), + listOf("hotspot", "openj9"), + listOf("8", "11", "17", "21", latestJava), + mapOf("majorVersion" to "8"), + ), + ImageTarget( + listOf("9.0.111"), + listOf("hotspot", "openj9"), + listOf("8", "11", "17", "21", latestJava), + mapOf("majorVersion" to "9"), + ), + ImageTarget( + listOf("10.1.48"), + listOf("hotspot", "openj9"), + listOf("11", "17", "21", latestJava), + mapOf("majorVersion" to "10"), + "servlet-5.0", + ), + ), + "tomee" to + listOf( + ImageTarget( + listOf("7.0.9", "7.1.4"), + listOf("hotspot", "openj9"), + listOf("8"), + ), + ImageTarget( + listOf("8.0.16"), + listOf("hotspot", "openj9"), + listOf("8", "11", "17", "21", latestJava), + ), + ImageTarget( + listOf("9.1.3"), + listOf("hotspot", "openj9"), + listOf("11", "17", "21", latestJava), + war = "servlet-5.0", + ), + ), + "websphere" to + listOf( + ImageTarget( + listOf( + "ibmcom/websphere-traditional:8.5.5.22@sha256:2a385c56f3e6781cc595d873473efd5ef7cb4f34e88c6cf8381121332fb49c9c", + "ibmcom/websphere-traditional:9.0.5.14@sha256:7e569af2f4050bb0f3ac0fcab113e2dee20d9d6bdc4061cef4b97b79c2ea4fdd", + ), + listOf("openj9"), + listOf("8"), + windows = false, + ), + ), + "wildfly" to + listOf( + ImageTarget( + listOf("13.0.0.Final"), + listOf("hotspot", "openj9"), + listOf("8"), + ), + ImageTarget( + listOf("17.0.1.Final", "21.0.0.Final"), + listOf("hotspot", "openj9"), + listOf("8", "11", "17", "21"), + ), + ImageTarget( + listOf("28.0.1.Final", "29.0.1.Final", "30.0.1.Final"), + listOf("hotspot", "openj9"), + listOf("11", "17", "21"), + war = "servlet-5.0", + ), + ), + ) tasks { val buildLinuxTestImages by registering { @@ -224,8 +248,12 @@ tasks { val majorVersion = if (dotIndex != -1) version.substring(0, dotIndex) else version for (jdk in entry.jdk) { for (vm in entry.vm) { - println("@AppServer(version = \"$version\", jdk = \"$jdk${if (vm == "hotspot") "" else "-openj9"}\")") - println("class ${serverName}${majorVersion}Jdk${jdk}${if (vm == "hotspot") "" else "Openj9"} extends ${serverName}SmokeTest {") + println( + "@AppServer(version = \"$version\", jdk = \"$jdk${if (vm == "hotspot") "" else "-openj9"}\")", + ) + println( + "class ${serverName}${majorVersion}Jdk${jdk}${if (vm == "hotspot") "" else "Openj9"} extends ${serverName}SmokeTest {", + ) println("}") } } @@ -245,18 +273,19 @@ fun configureImage( jdk: String, warProject: String, args: Map, - isWindows: Boolean + isWindows: Boolean, ): String { val versionParts = fullVersion.split("@") val imageNameWithTag = versionParts[0] val serverImageHash = if (versionParts.size > 1) versionParts[1].removePrefix("sha256:") else "" // Extract just the version (tag) from the full image reference - var version = if (imageNameWithTag.contains(":")) { - imageNameWithTag.substringAfterLast(":") - } else { - imageNameWithTag - } + var version = + if (imageNameWithTag.contains(":")) { + imageNameWithTag.substringAfterLast(":") + } else { + imageNameWithTag + } // Extract just the version number from tags with suffixes // (e.g., "20.0.0.12" from "20.0.0.12-full-java11-openj9") @@ -268,66 +297,72 @@ fun configureImage( val platformSuffix = if (isWindows) "-windows" else "" // Using separate build directory for different images - val dockerWorkingDir = layout.buildDirectory.dir("docker-$server-$version-jdk$jdk-$vm-$warProject-$platformSuffix") - - val prepareTask = tasks.register("${server}ImagePrepare-$version-jdk$jdk-$vm$platformSuffix") { - val warTask = project(":smoke-tests:images:servlet:$warProject").tasks.named("war") - dependsOn(warTask) - into(dockerWorkingDir) - from("src/$dockerFileName") - from("src/main/docker/$server") - from(warTask.get().archiveFile) { - rename { "app.war" } + val dockerWorkingDir = + layout.buildDirectory.dir( + "docker-$server-$version-jdk$jdk-$vm-$warProject-$platformSuffix", + ) + + val prepareTask = + tasks.register("${server}ImagePrepare-$version-jdk$jdk-$vm$platformSuffix") { + val warTask = project(":smoke-tests:images:servlet:$warProject").tasks.named("war") + dependsOn(warTask) + into(dockerWorkingDir) + from("src/$dockerFileName") + from("src/main/docker/$server") + from(warTask.get().archiveFile) { + rename { "app.war" } + } } - } - val repo = System.getenv("GITHUB_REPOSITORY") ?: "open-telemetry/opentelemetry-java-instrumentation" + val repo = + System.getenv("GITHUB_REPOSITORY") ?: "open-telemetry/opentelemetry-java-instrumentation" val vmSuffix = if (vm == "hotspot") "" else "-$vm" val image = "ghcr.io/$repo/smoke-test-servlet-$server:$version-jdk$jdk$vmSuffix$platformSuffix-$extraTag" - val jdkImage = if (vm == "hotspot") { - if (jdk == "26-ea") { - // "The only tags which will continue to receive updates beyond July 2022 will be Early Access - // builds (which are sourced from jdk.java.net), as those are not published/supported by any - // of the above projects." - // (see https://hub.docker.com/_/openjdk) - "openjdk:$jdk" - } else if (isWindows) { - when (jdk) { - "8" -> "eclipse-temurin:8u472-b08-jdk-windowsservercore-ltsc2022@sha256:2f2dc58147a9877ecde8644961b1e3c0f26f838af038ec8b8fc04dfbea61a4d0" - "11" -> "eclipse-temurin:11.0.30_7-jdk-windowsservercore-ltsc2022@sha256:972f72b443c5bd05a034edf9c1cb37b22c708c78d218bdb6cdda3e9a343bc915" - "17" -> "eclipse-temurin:17.0.18_8-jdk-windowsservercore-ltsc2022@sha256:cbe66e06b7bf584712c4149c70f1249c3b40e063b4f981002edbe845593248fb" - "21" -> "eclipse-temurin:21.0.10_7-jdk-windowsservercore-ltsc2022@sha256:f67fb0a74dfd10d5a54d31b232ed74e3941fcc40345de5e03378693f3f5f5d3e" - "25" -> "eclipse-temurin:25.0.2_10-jdk-windowsservercore-ltsc2022@sha256:6c8cc9cd5b5dc4c03130f0cf782854246859099777ebe551e546d853866333b7" - else -> throw GradleException("Unexpected jdk version for Windows: $jdk") + val jdkImage = + if (vm == "hotspot") { + if (jdk == "26-ea") { + // "The only tags which will continue to receive updates beyond July 2022 will be Early Access + // builds (which are sourced from jdk.java.net), as those are not published/supported by any + // of the above projects." + // (see https://hub.docker.com/_/openjdk) + "openjdk:$jdk" + } else if (isWindows) { + when (jdk) { + "8" -> "eclipse-temurin:8u472-b08-jdk-windowsservercore-ltsc2022@sha256:2f2dc58147a9877ecde8644961b1e3c0f26f838af038ec8b8fc04dfbea61a4d0" + "11" -> "eclipse-temurin:11.0.30_7-jdk-windowsservercore-ltsc2022@sha256:972f72b443c5bd05a034edf9c1cb37b22c708c78d218bdb6cdda3e9a343bc915" + "17" -> "eclipse-temurin:17.0.18_8-jdk-windowsservercore-ltsc2022@sha256:cbe66e06b7bf584712c4149c70f1249c3b40e063b4f981002edbe845593248fb" + "21" -> "eclipse-temurin:21.0.10_7-jdk-windowsservercore-ltsc2022@sha256:f67fb0a74dfd10d5a54d31b232ed74e3941fcc40345de5e03378693f3f5f5d3e" + "25" -> "eclipse-temurin:25.0.2_10-jdk-windowsservercore-ltsc2022@sha256:6c8cc9cd5b5dc4c03130f0cf782854246859099777ebe551e546d853866333b7" + else -> throw GradleException("Unexpected jdk version for Windows: $jdk") + } + } else { + when (jdk) { + "8" -> "eclipse-temurin:8u472-b08-jdk@sha256:0b793df1b9217f3d25c5f820d47e85a20b0a78b0ccd0ab6deb9051502493c855" + "11" -> "eclipse-temurin:11.0.30_7-jdk@sha256:a5bb1bf3e5aec3f09f80293258eabc513151173e70982f4d45691583981de18e" + "17" -> "eclipse-temurin:17.0.18_8-jdk@sha256:aae0b1494a5637b2c1b933080088ccc196dec7ffb83ce1cd524211ea4f640ff4" + "21" -> "eclipse-temurin:21.0.10_7-jdk@sha256:e58e492628c1428ceb838afc1a1b8762673d5eaa09296f560c363daea0fdcf3b" + "25" -> "eclipse-temurin:25.0.2_10-jdk@sha256:1bda4d9e668f44f399abed30636c34e0befb727408fba27b1e6aaefcf9df346b" + else -> throw GradleException("Unexpected jdk version for Linux: $jdk") + } } - } else { - when (jdk) { - "8" -> "eclipse-temurin:8u472-b08-jdk@sha256:0b793df1b9217f3d25c5f820d47e85a20b0a78b0ccd0ab6deb9051502493c855" - "11" -> "eclipse-temurin:11.0.30_7-jdk@sha256:a5bb1bf3e5aec3f09f80293258eabc513151173e70982f4d45691583981de18e" - "17" -> "eclipse-temurin:17.0.18_8-jdk@sha256:aae0b1494a5637b2c1b933080088ccc196dec7ffb83ce1cd524211ea4f640ff4" - "21" -> "eclipse-temurin:21.0.10_7-jdk@sha256:e58e492628c1428ceb838afc1a1b8762673d5eaa09296f560c363daea0fdcf3b" - "25" -> "eclipse-temurin:25.0.2_10-jdk@sha256:1bda4d9e668f44f399abed30636c34e0befb727408fba27b1e6aaefcf9df346b" - else -> throw GradleException("Unexpected jdk version for Linux: $jdk") + } else if (vm == "openj9") { + if (isWindows) { + // ibm-semeru-runtimes doesn't publish windows images + throw GradleException("Unexpected vm: $vm") + } else { + when (jdk) { + "8" -> "ibm-semeru-runtimes:open-8u472-b08-jdk@sha256:779c0c1133ebac0d599012c5a908e67adaa993352072eac21d7ced8d6a47f14d" + "11" -> "ibm-semeru-runtimes:open-11.0.29_7-jdk@sha256:00bbefbb2cf3690546338c0e4ba4cf85ec658f40de5b292e77774b55e8267d66" + "17" -> "ibm-semeru-runtimes:open-17-jdk@sha256:1a3a5328d0e751986755722367ca09b965b2c50190cb1da8dbea000341acd6b5" + "21" -> "ibm-semeru-runtimes:open-21.0.9_10-jdk@sha256:2edabc89c49cfa2b9f0c051aced57ca6dee81c2e6b8820a1257182e779b58a48" + "25" -> "ibm-semeru-runtimes:open-25-jdk@sha256:6838afe391338d1cb91ea689d622bd2f6cb35ac9c621fce60c6fd029b5d43e3c" + else -> throw GradleException("Unexpected jdk version for openj9: $jdk") + } } - } - } else if (vm == "openj9") { - if (isWindows) { - // ibm-semeru-runtimes doesn't publish windows images - throw GradleException("Unexpected vm: $vm") } else { - when (jdk) { - "8" -> "ibm-semeru-runtimes:open-8u472-b08-jdk@sha256:779c0c1133ebac0d599012c5a908e67adaa993352072eac21d7ced8d6a47f14d" - "11" -> "ibm-semeru-runtimes:open-11.0.29_7-jdk@sha256:00bbefbb2cf3690546338c0e4ba4cf85ec658f40de5b292e77774b55e8267d66" - "17" -> "ibm-semeru-runtimes:open-17-jdk@sha256:1a3a5328d0e751986755722367ca09b965b2c50190cb1da8dbea000341acd6b5" - "21" -> "ibm-semeru-runtimes:open-21.0.9_10-jdk@sha256:2edabc89c49cfa2b9f0c051aced57ca6dee81c2e6b8820a1257182e779b58a48" - "25" -> "ibm-semeru-runtimes:open-25-jdk@sha256:6838afe391338d1cb91ea689d622bd2f6cb35ac9c621fce60c6fd029b5d43e3c" - else -> throw GradleException("Unexpected jdk version for openj9: $jdk") - } + throw GradleException("Unexpected vm: $vm") } - } else { - throw GradleException("Unexpected vm: $vm") - } val jdkImageParts = jdkImage.split("@") val jdkImageName = jdkImageParts[0] @@ -342,7 +377,8 @@ fun configureImage( if (server == "wildfly") { // wildfly url without .zip or .tar.gz suffix - extraArgs["baseDownloadUrl"] = "https://repo1.maven.org/maven2/org/wildfly/wildfly-dist/$version/wildfly-dist-$version" + extraArgs["baseDownloadUrl"] = + "https://repo1.maven.org/maven2/org/wildfly/wildfly-dist/$version/wildfly-dist-$version" } else if (server == "payara") { if (version == "5.2020.6") { extraArgs["domainName"] = "production" @@ -351,18 +387,30 @@ fun configureImage( } } - val buildTask = tasks.register("${server}Image-$version-jdk$jdk$vmSuffix$platformSuffix") { - dependsOn(prepareTask) - group = "build" - description = "Builds Docker image with $server $version on JDK $jdk-$vm${if (isWindows) " on Windows" else ""}" - - usesService(gradle.sharedServices.registrations["dockerBuildService"].service) - - inputDir.set(dockerWorkingDir) - images.add(image) - dockerFile.set(File(dockerWorkingDir.get().asFile, dockerFileName)) - buildArgs.set(extraArgs + mapOf("jdk" to jdk, "vm" to vm, "version" to version, "jdkImageName" to jdkImageName, "jdkImageHash" to jdkImageHash, "imageHash" to serverImageHash)) - } + val buildTask = + tasks.register("${server}Image-$version-jdk$jdk$vmSuffix$platformSuffix") { + dependsOn(prepareTask) + group = "build" + description = + "Builds Docker image with $server $version on JDK $jdk-$vm${if (isWindows) " on Windows" else ""}" + + usesService(gradle.sharedServices.registrations["dockerBuildService"].service) + + inputDir.set(dockerWorkingDir) + images.add(image) + dockerFile.set(File(dockerWorkingDir.get().asFile, dockerFileName)) + buildArgs.set( + extraArgs + + mapOf( + "jdk" to jdk, + "vm" to vm, + "version" to version, + "jdkImageName" to jdkImageName, + "jdkImageHash" to jdkImageHash, + "imageHash" to serverImageHash, + ), + ) + } parentTask.configure { dependsOn(buildTask) @@ -370,7 +418,10 @@ fun configureImage( return image } -fun createDockerTasks(parentTask: TaskProvider, isWindows: Boolean): Set { +fun createDockerTasks( + parentTask: TaskProvider, + isWindows: Boolean, +): Set { val resultImages = mutableSetOf() for ((server, matrices) in targets) { val smokeTestServer = findProperty("smokeTestServer") @@ -392,7 +443,19 @@ fun createDockerTasks(parentTask: TaskProvider, isWindows: Boolean): S } for (jdk in entry.jdk) { if (supportsWindows || !isWindows) { - resultImages.add(configureImage(parentTask, server, dockerfile, version, vm, jdk, warProject, extraArgs, isWindows)) + resultImages.add( + configureImage( + parentTask, + server, + dockerfile, + version, + vm, + jdk, + warProject, + extraArgs, + isWindows, + ), + ) } } } diff --git a/smoke-tests/images/spring-boot/build.gradle.kts b/smoke-tests/images/spring-boot/build.gradle.kts index c5402156d380..dbb0be6c8a9c 100644 --- a/smoke-tests/images/spring-boot/build.gradle.kts +++ b/smoke-tests/images/spring-boot/build.gradle.kts @@ -30,8 +30,9 @@ configurations.runtimeClasspath { val targetJDK = project.findProperty("targetJDK") ?: "17" -val tag = findProperty("tag") - ?: DateTimeFormatter.ofPattern("yyyyMMdd.HHmmSS").format(LocalDateTime.now()) +val tag = + findProperty("tag") + ?: DateTimeFormatter.ofPattern("yyyyMMdd.HHmmSS").format(LocalDateTime.now()) java { // Jib detects the Java version from sourceCompatibility to determine the entrypoint format. @@ -76,7 +77,13 @@ jib { extraDirectories { paths { path { - setFrom(layout.buildDirectory.dir("jib-extra").get().asFile.toPath()) + setFrom( + layout.buildDirectory + .dir("jib-extra") + .get() + .asFile + .toPath(), + ) into = "/" } } diff --git a/testing-common/build.gradle.kts b/testing-common/build.gradle.kts index 50ec4897c56d..9d206b79d7f2 100644 --- a/testing-common/build.gradle.kts +++ b/testing-common/build.gradle.kts @@ -11,7 +11,7 @@ sourceSets { val shadedDeps = project(":testing:dependencies-shaded-for-testing") output.dir( shadedDeps.file("build/extracted/shadow"), - "builtBy" to ":testing:dependencies-shaded-for-testing:extractShadowJar" + "builtBy" to ":testing:dependencies-shaded-for-testing:extractShadowJar", ) } } diff --git a/testing-common/integration-tests/build.gradle.kts b/testing-common/integration-tests/build.gradle.kts index 615a7e1cd76e..a8bc1c6c626b 100644 --- a/testing-common/integration-tests/build.gradle.kts +++ b/testing-common/integration-tests/build.gradle.kts @@ -29,7 +29,10 @@ dependencies { tasks { val testFieldInjectionDisabled by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { includeTestsMatching("context.FieldInjectionDisabledTest") @@ -39,7 +42,10 @@ tasks { } val testFieldBackedImplementation by registering(Test::class) { - testClassesDirs = sourceSets.test.get().output.classesDirs + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs classpath = sourceSets.test.get().runtimeClasspath filter { includeTestsMatching("context.FieldBackedImplementationTest") @@ -59,7 +65,9 @@ tasks { excludeTestsMatching("context.FieldBackedImplementationTest") } // this is needed for AgentInstrumentationTest - jvmArgs("-Dotel.javaagent.exclude-classes=config.exclude.packagename.*,config.exclude.SomeClass,config.exclude.SomeClass\$NestedClass") + jvmArgs( + "-Dotel.javaagent.exclude-classes=config.exclude.packagename.*,config.exclude.SomeClass,config.exclude.SomeClass\$NestedClass", + ) } check { diff --git a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/DbConnectionPoolMetricsAssertions.java b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/DbConnectionPoolMetricsAssertions.java index a40f0b985c2b..1365b9c6d90c 100644 --- a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/DbConnectionPoolMetricsAssertions.java +++ b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/DbConnectionPoolMetricsAssertions.java @@ -137,7 +137,8 @@ private void verifyUsageMetric(MetricData metric) { assertThat(metric) .hasUnit(emitStableDatabaseSemconv() ? "{connection}" : "{connections}") .hasDescription( - "The number of connections that are currently in state described by the state attribute.") + "The number of connections that are currently in state described by the state" + + " attribute.") .hasLongSumSatisfying( sum -> sum.isNotMonotonic() @@ -216,7 +217,8 @@ private void verifyPendingRequestsMetric(MetricData metric) { .hasDescription( emitStableDatabaseSemconv() ? "The number of current pending requests for an open connection." - : "The number of pending requests for an open connection, cumulative for the entire pool.") + : "The number of pending requests for an open connection, cumulative for the entire" + + " pool.") .hasLongSumSatisfying(this::verifyPoolName); } @@ -233,7 +235,8 @@ private void verifyTimeoutsMetric(MetricData metric) { assertThat(metric) .hasUnit(emitStableDatabaseSemconv() ? "{timeout}" : "{timeouts}") .hasDescription( - "The number of connection timeouts that have occurred trying to obtain a connection from the pool.") + "The number of connection timeouts that have occurred trying to obtain a connection" + + " from the pool.") .hasLongSumSatisfying( sum -> sum.isMonotonic() diff --git a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpServerUsingTest.java b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpServerUsingTest.java index 02ecf52dc8c9..9d3cf24eec19 100644 --- a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpServerUsingTest.java +++ b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpServerUsingTest.java @@ -82,7 +82,8 @@ protected URI buildAddress() { void verifyExtension() { if (testing == null) { throw new AssertionError( - "Subclasses of AbstractHttpServerUsingTest must register HttpServerInstrumentationExtension"); + "Subclasses of AbstractHttpServerUsingTest must register" + + " HttpServerInstrumentationExtension"); } } diff --git a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/recording/YamlFileMappingsSource.java b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/recording/YamlFileMappingsSource.java index 3a1d863da414..d66d4f1021bf 100644 --- a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/recording/YamlFileMappingsSource.java +++ b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/recording/YamlFileMappingsSource.java @@ -140,7 +140,8 @@ public void remove(StubMapping stubMapping) { public void removeAll() { if (anyFilesAreMultiMapping()) { throw new NotWritableException( - "Some stubs were loaded from multi-mapping files which are read-only, so remove all cannot be performed"); + "Some stubs were loaded from multi-mapping files which are read-only, so remove all" + + " cannot be performed"); } for (StubMappingFileMetadata fileMetadata : fileNameMap.values()) { diff --git a/testing/agent-exporter/src/main/java/io/opentelemetry/javaagent/testing/messaging/CapturedMessagingHeadersTestConfigSupplier.java b/testing/agent-exporter/src/main/java/io/opentelemetry/javaagent/testing/messaging/CapturedMessagingHeadersTestConfigSupplier.java index 9bb2b7813e29..84aff5c67768 100644 --- a/testing/agent-exporter/src/main/java/io/opentelemetry/javaagent/testing/messaging/CapturedMessagingHeadersTestConfigSupplier.java +++ b/testing/agent-exporter/src/main/java/io/opentelemetry/javaagent/testing/messaging/CapturedMessagingHeadersTestConfigSupplier.java @@ -28,7 +28,8 @@ private static Map getTestProperties() { // most tests use "Test-Message-Header". "Test_Message_Header" is used for JMS2+ because // '-' is not allowed in a JMS property name. JMS property name should be a valid java // identifier. - "Test-Message-Header, Test-Message-Int-Header, Test_Message_Header, Test_Message_Int_Header"); + "Test-Message-Header, Test-Message-Int-Header, Test_Message_Header," + + " Test_Message_Int_Header"); return testConfig; } } diff --git a/testing/agent-for-testing/build.gradle.kts b/testing/agent-for-testing/build.gradle.kts index 142a1e04bc82..3feabb149909 100644 --- a/testing/agent-for-testing/build.gradle.kts +++ b/testing/agent-for-testing/build.gradle.kts @@ -48,9 +48,10 @@ tasks { into("extensions") } - val manifestFileProvider = extractAgent.flatMap { task -> - layout.buildDirectory.file("extracted-agent/META-INF/MANIFEST.MF") - } + val manifestFileProvider = + extractAgent.flatMap { task -> + layout.buildDirectory.file("extracted-agent/META-INF/MANIFEST.MF") + } doFirst { manifest.from(manifestFileProvider.get().asFile) @@ -71,7 +72,8 @@ class JavaagentProvider( @PathSensitive(PathSensitivity.RELATIVE) val agentJar: Provider, ) : CommandLineArgumentProvider { - override fun asArguments(): Iterable = listOf( - "-javaagent:${agentJar.get().asFile.absolutePath}", - ) + override fun asArguments(): Iterable = + listOf( + "-javaagent:${agentJar.get().asFile.absolutePath}", + ) } diff --git a/testing/dependencies-shaded-for-testing/build.gradle.kts b/testing/dependencies-shaded-for-testing/build.gradle.kts index 51011ec12acc..a8809a610c6b 100644 --- a/testing/dependencies-shaded-for-testing/build.gradle.kts +++ b/testing/dependencies-shaded-for-testing/build.gradle.kts @@ -32,7 +32,7 @@ tasks { if (otelProps.denyUnsafe) { relocate( "com.github.benmanes.caffeine", - "io.opentelemetry.testing.internal.armeria.internal.shaded.caffeine" + "io.opentelemetry.testing.internal.armeria.internal.shaded.caffeine", ) } relocate("com.fasterxml.jackson", "io.opentelemetry.testing.internal.jackson") @@ -46,7 +46,10 @@ tasks { // https://github.com/netty/netty/blob/e69107ceaf247099ad9a198b8ef557bdff994a99/common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java#L120 relocate("io.netty", "io.opentelemetry.testing.internal.io.netty") exclude("META-INF/maven/**") - relocate("META-INF/native/libnetty", "META-INF/native/libio_opentelemetry_testing_internal_netty") + relocate( + "META-INF/native/libnetty", + "META-INF/native/libio_opentelemetry_testing_internal_netty", + ) relocate("META-INF/native/netty", "META-INF/native/io_opentelemetry_testing_internal_netty") // relocate micrometer and its dependencies so that it doesn't conflict with instrumentation tests