Merge remote-tracking branch 'upstream/main' into modernize-junit

This commit is contained in:
Trask Stalnaker 2025-10-14 13:16:17 -07:00
commit 841b8c16ea
33 changed files with 174 additions and 135 deletions

View File

@ -4,6 +4,8 @@
'config:best-practices',
'helpers:pinGitHubActionDigestsToSemver',
],
ignorePaths: [], // overwrite default ignore which includes **/test/**
// used to update docker image versions used in Java test files
ignorePresets: [
':ignoreModulesAndTests', // needed to keep maven-extension test pom files up-to-date
'workarounds:javaLTSVersions', // Allow all Java major versions, not just LTS
@ -243,5 +245,17 @@
'"https://github.com/(?<depName>[^/]+/[^/]+)/zipball/(?<currentValue>.+?)"',
],
},
{
customType: 'regex',
datasourceTemplate: 'docker',
managerFilePatterns: [
'**/*.java',
],
matchStrings: [
'"(?<depName>otel/opentelemetry-collector-contrib):(?<currentValue>[^@"]+)(?:@(?<currentDigest>sha256:[a-f0-9]+))?"',
],
autoReplaceStringTemplate: '"{{depName}}:{{newValue}}{{#if newDigest}}@{{newDigest}}{{/if}}"',
versioningTemplate: 'docker',
},
],
}

View File

@ -111,7 +111,7 @@ jobs:
- name: Test
run: >
./gradlew test
./gradlew check -x spotlessCheck
"-PtestJavaVersion=${{ matrix.test-java-version }}"
"-Porg.gradle.java.installations.paths=${{ steps.setup-java-test.outputs.path }}"
"-Porg.gradle.java.installations.auto-download=false"
@ -122,36 +122,6 @@ jobs:
if: ${{ !cancelled() && hashFiles('build-scan.txt') != '' }}
run: cat build-scan.txt
integration-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Set up JDK for running Gradle
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
with:
distribution: temurin
java-version: 17
- name: Set up Gradle
uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
with:
cache-read-only: ${{ inputs.cache-read-only }}
- name: Integration test
run: ./gradlew integrationTest "-PmaxTestRetries=${{ inputs.max-test-retries }}" ${{ inputs.no-build-cache && '--no-build-cache' || '' }}
- name: Build scan
if: ${{ !cancelled() && hashFiles('build-scan.txt') != '' }}
run: cat build-scan.txt
- name: Save integration test results
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
if: always()
with:
name: integration-test-results
path: jmx-metrics/build/reports/tests/integrationTest
markdown-lint-check:
uses: ./.github/workflows/reusable-markdown-lint.yml

View File

@ -50,7 +50,7 @@ jobs:
uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
- name: Initialize CodeQL
uses: github/codeql-action/init@a8d1ac45b9a34d11fe398d5503176af0d06b303e # v3.30.7
uses: github/codeql-action/init@f443b600d91635bebf5b0d9ebc620189c0d6fba5 # v4.30.8
with:
languages: ${{ matrix.language }}
# using "linked" helps to keep up with the latest Kotlin support
@ -65,6 +65,6 @@ jobs:
run: ./gradlew assemble --no-build-cache --no-daemon
- name: Perform CodeQL analysis
uses: github/codeql-action/analyze@a8d1ac45b9a34d11fe398d5503176af0d06b303e # v3.30.7
uses: github/codeql-action/analyze@f443b600d91635bebf5b0d9ebc620189c0d6fba5 # v4.30.8
with:
category: "/language:${{matrix.language}}"

View File

@ -45,9 +45,9 @@ jobs:
exempt-issue-labels: "needs author feedback"
days-before-pr-stale: -1
days-before-pr-close: -1
days-before-stale: 365
days-before-close: 0
close-issue-label: stale
days-before-issue-stale: 365
days-before-issue-close: 0
stale-issue-label: stale
close-issue-message: >
Since there has been no activity on this enhancement for the past year we are closing it to help maintain our backlog.
Anyone who would like to work on it is still welcome to do so, and we can re-open it at that time.

View File

@ -52,6 +52,6 @@ jobs:
# Upload the results to GitHub's code scanning dashboard (optional).
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@a8d1ac45b9a34d11fe398d5503176af0d06b303e # v3.30.7
uses: github/codeql-action/upload-sarif@f443b600d91635bebf5b0d9ebc620189c0d6fba5 # v4.30.8
with:
sarif_file: results.sarif

View File

@ -12,7 +12,7 @@ jobs:
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0 # needed for merge-base below
fetch-depth: 0 # needed for merge-base used in lint:links-in-modified-files
- uses: jdx/mise-action@e3d7b8d67a7958d1207f6ed871e83b1ea780e7b0 # v3.3.1

View File

@ -17,12 +17,12 @@ fi
config_modified=$(git diff --name-only --merge-base "$usage_base" $usage_head \
| grep -E '^(\.github/config/lychee\.toml|\.mise/tasks/lint/.*|mise\.toml)$' || true)
if [ -n "$config_modified" ] ; then
if [ "$usage_event" != "pull_request" ] ; then
echo "Not a PR - checking all files."
mise run lint:links
elif [ -n "$config_modified" ] ; then
echo "config changes, checking all files."
mise run lint:links
elif [ "$usage_event" != "pull_request" ] ; then
echo "Not a PR - skipping link linting."
exit 0
else
# Using lychee's default extension filter here to match when it runs against all files
# Note: --diff-filter=d filters out deleted files

View File

@ -5,4 +5,9 @@ set -e
#USAGE arg "<file>" var=#true help="files to check" default="."
lychee --verbose --config .github/config/lychee.toml "$usage_file"
for f in $usage_file; do
echo "Checking links in file: $f"
done
# shellcheck disable=SC2086
lychee --verbose --config .github/config/lychee.toml $usage_file

View File

@ -5,4 +5,9 @@ set -e
#USAGE arg "<file>" var=#true help="files to check" default="."
lychee --verbose --scheme file --include-fragments "$usage_file"
for f in $usage_file; do
echo "Checking links in file: $f"
done
# shellcheck disable=SC2086
lychee --verbose --scheme file --include-fragments $usage_file

View File

@ -31,12 +31,6 @@ To run the tests:
./gradlew test
```
Some modules include integration tests that can be run with:
```bash
./gradlew integrationTest
```
## Snapshot Builds
Snapshot builds of the `main` branch are available from the Sonatype snapshot repository at:

View File

@ -54,7 +54,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md).
### Maintainers
- [Jack Berg](https://github.com/jack-berg), New Relic
- [Jack Berg](https://github.com/jack-berg), Grafana Labs
- [Jason Plumb](https://github.com/breedx-splk), Splunk
- [Lauri Tulmin](https://github.com/laurit), Splunk
- [Trask Stalnaker](https://github.com/trask), Microsoft
@ -63,7 +63,7 @@ For more information about the maintainer role, see the [community repository](h
### Approvers
- [Jay DeLuca](https://github.com/jaydeluca), Grafana
- [Jay DeLuca](https://github.com/jaydeluca), Grafana Labs
- [John Watson](https://github.com/jkwatson), Cloudera
For more information about the approver role, see the [community repository](https://github.com/open-telemetry/community/blob/main/guides/contributor/membership.md#approver).

View File

@ -16,13 +16,13 @@ import io.opentelemetry.sdk.trace.samplers.SamplingResult;
import java.time.Duration;
import java.util.Collections;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import org.testcontainers.utility.DockerImageName;
import org.testcontainers.utility.MountableFile;
@ -31,15 +31,21 @@ import org.testcontainers.utility.MountableFile;
// to update sampling rules and assert rough ratios of sampling decisions. In the meantime, it
// expects you to update the rules through the dashboard to see the effect on the sampling decisions
// that are printed.
@Testcontainers(disabledWithoutDocker = true)
@EnabledIf("hasAwsCredentials")
class AwsXrayRemoteSamplerIntegrationTest {
static boolean hasAwsCredentials() {
return System.getenv("AWS_ACCESS_KEY_ID") != null;
}
private static final Logger logger =
LoggerFactory.getLogger(AwsXrayRemoteSamplerIntegrationTest.class);
@Container
private static final GenericContainer<?> otelCollector =
new GenericContainer<>(DockerImageName.parse("otel/opentelemetry-collector-contrib:latest"))
new GenericContainer<>(
DockerImageName.parse(
"otel/opentelemetry-collector-contrib:0.137.0@sha256:886722fe0f37af9d1fe24d29529253ec59fbf263b3b1df4facaf221373e19d23"))
.withExposedPorts(13133, 2000)
.waitingFor(Wait.forHttp("/").forPort(13133))
.withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger("otel-collector")))

View File

@ -15,9 +15,9 @@ dependencies {
implementation("com.diffplug.spotless:com.diffplug.spotless.gradle.plugin:8.0.0")
implementation("net.ltgt.errorprone:net.ltgt.errorprone.gradle.plugin:4.3.0")
implementation("net.ltgt.nullaway:net.ltgt.nullaway.gradle.plugin:2.3.0")
implementation("org.owasp.dependencycheck:org.owasp.dependencycheck.gradle.plugin:12.1.6")
implementation("org.owasp.dependencycheck:org.owasp.dependencycheck.gradle.plugin:12.1.8")
implementation("ru.vyarus.animalsniffer:ru.vyarus.animalsniffer.gradle.plugin:2.0.1")
implementation("com.gradle.develocity:com.gradle.develocity.gradle.plugin:4.2.1")
implementation("com.gradle.develocity:com.gradle.develocity.gradle.plugin:4.2.2")
implementation("me.champeau.gradle.japicmp:me.champeau.gradle.japicmp.gradle.plugin:0.4.6")
implementation("com.google.auto.value:auto-value-annotations:1.11.0")
}

View File

@ -150,7 +150,7 @@ testing {
useJUnitJupiter()
dependencies {
implementation(project(project.path))
implementation(project())
// this is only needed to establish the version of JUnit we want to use
// since Renovate doesn't currently understand useJUnitJupiter("<version>")
@ -173,6 +173,12 @@ testing {
}
}
tasks {
check {
dependsOn(testing.suites)
}
}
fun isJavaVersionAllowed(version: JavaVersion): Boolean {
if (otelJava.minJavaVersionSupported.get() > version) {
return false

View File

@ -5,7 +5,7 @@ There are two major components included here.
## Original proposal implementation
The original specification for consistent probability sampling is defined by
<https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/tracestate-probability-sampling-experimental.md>
<https://github.com/open-telemetry/opentelemetry-specification/blob/main/oteps/trace/4673-experimental-probability-sampling.md>
and <https://github.com/open-telemetry/opentelemetry-specification/pull/2047>.
It supports sampling probabilities that are power of 2 (1, 1/2, 1/4, ...), and uses 8-bit `r-value` and 8-bit `p-value` in tracestate.
@ -14,18 +14,18 @@ The implementation of this proposal is contained by the package `io/opentelemetr
* **ConsistentSampler**:
abstract base class of all consistent sampler implementations below
* **ConsistentAlwaysOffSampler**:
see <https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/tracestate-probability-sampling-experimental.md#always-off-sampler>
see <https://github.com/open-telemetry/opentelemetry-specification/blob/main/oteps/trace/4673-experimental-probability-sampling.md#always-off-sampler>
* **ConsistentAlwaysOnSampler**:
see <https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/tracestate-probability-sampling-experimental.md#always-on-consistent-probability-sampler>
see <https://github.com/open-telemetry/opentelemetry-specification/blob/main/oteps/trace/4673-experimental-probability-sampling.md#always-on-consistent-probability-sampler>
* **ConsistentComposedAndSampler**:
allows combining two consistent samplers and samples when both samplers would sample
* **ConsistentComposedOrSampler**:
allows combining two consistent sampler and samples when at least one of both samplers would sample,
see <https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/tracestate-probability-sampling-experimental.md#requirement-combine-multiple-consistent-probability-samplers-using-the-minimum-p-value>
see <https://github.com/open-telemetry/opentelemetry-specification/blob/main/oteps/trace/4673-experimental-probability-sampling.md#requirement-combine-multiple-consistent-probability-samplers-using-the-minimum-p-value>
* **ConsistentParentBasedSampler**:
see <https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/tracestate-probability-sampling-experimental.md#parentconsistentprobabilitybased-sampler>
see <https://github.com/open-telemetry/opentelemetry-specification/blob/main/oteps/trace/4673-experimental-probability-sampling.md#parentconsistentprobabilitybased-sampler>
* **ConsistentProbabilityBasedSampler**:
see <https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/tracestate-probability-sampling-experimental.md#consistentprobabilitybased-sampler>
see <https://github.com/open-telemetry/opentelemetry-specification/blob/main/oteps/trace/4673-experimental-probability-sampling.md#consistentprobabilitybased-sampler>
* **ConsistentRateLimitingSampler**:
a rate limiting sampler based on exponential smoothing that dynamically adjusts the sampling
probability based on the estimated rate of spans occurring to satisfy a given rate of sampled spans

View File

@ -17,7 +17,7 @@ dependencies {
api(platform("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:${otelInstrumentationVersion}"))
api(platform("com.fasterxml.jackson:jackson-bom:2.20.0"))
api(platform("com.google.protobuf:protobuf-bom:4.32.1"))
api(platform("com.squareup.okhttp3:okhttp-bom:5.1.0"))
api(platform("com.squareup.okhttp3:okhttp-bom:5.2.1"))
constraints {
api("io.opentelemetry.semconv:opentelemetry-semconv:${semconvVersion}")

View File

@ -50,7 +50,11 @@ testing {
targets {
all {
testTask.configure {
shouldRunAfter(tasks.test)
// Jakarta JMS requires Java 11+
val testJavaVersion: String? by project
if (testJavaVersion == "8") {
enabled = false
}
}
}
}

View File

@ -42,10 +42,12 @@ public final class InferredSpans {
*
* @param interval the new profiler interval
*/
public static void setProfilerInterval(Duration interval) {
@Nullable
public static Duration setProfilerInterval(Duration interval) {
InferredSpansProcessor p = instance;
if (p != null) {
p.setProfilerInterval(interval);
return p.setProfilerInterval(interval);
}
return null;
}
}

View File

@ -57,9 +57,10 @@ public class InferredSpansProcessor implements SpanProcessor {
}
}
public void setProfilerInterval(Duration interval) {
config.setProfilerInterval(interval);
public Duration setProfilerInterval(Duration interval) {
Duration oldInterval = config.setProfilerInterval(interval);
profiler.reschedule();
return oldInterval;
}
public static InferredSpansProcessorBuilder builder() {

View File

@ -84,8 +84,10 @@ public class InferredSpansConfiguration {
return profilerInterval;
}
public void setProfilerInterval(Duration profilerInterval) {
public Duration setProfilerInterval(Duration profilerInterval) {
Duration oldInterval = this.profilerInterval;
this.profilerInterval = profilerInterval;
return oldInterval;
}
public Duration getProfilingDuration() {

View File

@ -11,11 +11,16 @@ import io.opentelemetry.contrib.jmxmetrics.AbstractIntegrationTest;
import io.opentelemetry.proto.metrics.v1.Metric;
import java.time.Duration;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnJre;
import org.junit.jupiter.api.condition.JRE;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.Network;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.junit.jupiter.Container;
// possible workaround on Java 8:
// https://stackoverflow.com/questions/35466461/how-to-connect-with-jmx-from-host-to-docker-container-in-docker-machine
@DisabledOnJre(JRE.JAVA_8)
class SolrIntegrationTest extends AbstractIntegrationTest {
SolrIntegrationTest() {

View File

@ -23,12 +23,14 @@ import org.slf4j.LoggerFactory;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.Network;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.junit.jupiter.Testcontainers;
/**
* Tests all supported ways to connect to remote JMX interface. This indirectly tests
* JmxConnectionBuilder and relies on containers to minimize the JMX/RMI network complications which
* are not NAT-friendly.
*/
@Testcontainers(disabledWithoutDocker = true)
class JmxConnectionTest {
// OTLP endpoint is not used in test mode, but still has to be provided

View File

@ -14,10 +14,15 @@ import io.opentelemetry.contrib.jmxscraper.assertions.AttributeMatcher;
import io.opentelemetry.contrib.jmxscraper.assertions.AttributeMatcherGroup;
import java.nio.file.Path;
import java.time.Duration;
import org.junit.jupiter.api.condition.DisabledOnJre;
import org.junit.jupiter.api.condition.JRE;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.Network;
import org.testcontainers.containers.wait.strategy.Wait;
// possible workaround on Java 8:
// https://stackoverflow.com/questions/35466461/how-to-connect-with-jmx-from-host-to-docker-container-in-docker-machine
@DisabledOnJre(JRE.JAVA_8)
class SolrIntegrationTest extends TargetSystemIntegrationTest {
@Override

View File

@ -7,6 +7,7 @@ package io.opentelemetry.contrib.jmxscraper.target_systems;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
import static org.testcontainers.Testcontainers.exposeHostPorts;
import com.linecorp.armeria.server.ServerBuilder;
import com.linecorp.armeria.server.grpc.GrpcService;
@ -35,11 +36,12 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.Testcontainers;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.Network;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.junit.jupiter.Testcontainers;
@Testcontainers(disabledWithoutDocker = true)
public abstract class TargetSystemIntegrationTest {
private static final Logger logger = LoggerFactory.getLogger(TargetSystemIntegrationTest.class);
private static final Logger targetSystemLogger = LoggerFactory.getLogger("TargetSystemContainer");
@ -72,7 +74,7 @@ public abstract class TargetSystemIntegrationTest {
network = Network.newNetwork();
otlpServer = new OtlpGrpcServer();
otlpServer.start();
Testcontainers.exposeHostPorts(otlpServer.httpPort());
exposeHostPorts(otlpServer.httpPort());
otlpEndpoint = "http://" + OTLP_HOST + ":" + otlpServer.httpPort();
}

View File

@ -20,14 +20,14 @@ dependencies {
annotationProcessor("com.google.auto.value:auto-value")
compileOnly("com.google.auto.value:auto-value-annotations")
testImplementation("io.micrometer:micrometer-core:1.15.4")
testImplementation("io.micrometer:micrometer-core:1.15.5")
}
testing {
suites {
val integrationTest by registering(JvmTestSuite::class) {
dependencies {
implementation("io.micrometer:micrometer-registry-prometheus:1.15.4")
implementation("io.micrometer:micrometer-registry-prometheus:1.15.5")
}
}
}

View File

@ -22,16 +22,16 @@ OpampClient client =
.build(
new OpampClient.Callbacks() {
@Override
public void onConnect() {}
public void onConnect(OpampClient client) {}
@Override
public void onConnectFailed(@Nullable Throwable throwable) {}
public void onConnectFailed(OpampClient client, @Nullable Throwable throwable) {}
@Override
public void onErrorResponse(ServerErrorResponse errorResponse) {}
public void onErrorResponse(OpampClient client, ServerErrorResponse errorResponse) {}
@Override
public void onMessage(MessageData messageData) {
public void onMessage(OpampClient client, MessageData messageData) {
AgentRemoteConfig remoteConfig = messageData.getRemoteConfig();
if (remoteConfig != null) {
// A remote config was received

View File

@ -22,7 +22,7 @@ public interface OpampClient extends Closeable {
* Sets attributes of the Agent. The attributes will be included in the next outgoing status
* report. This is typically used by Agents which allow their AgentDescription to change
* dynamically while the OpAMPClient is started. May be also called from {@link
* Callbacks#onMessage(MessageData)}.
* Callbacks#onMessage(OpampClient, MessageData)}.
*
* @param agentDescription The new agent description.
*/
@ -40,16 +40,19 @@ public interface OpampClient extends Closeable {
* Called when the connection is successfully established to the Server. For WebSocket clients
* this is called after the handshake is completed without any error. For HTTP clients this is
* called for any request if the response status is OK.
*
* @param client The client that's connected.
*/
void onConnect();
void onConnect(OpampClient client);
/**
* Called when the connection to the Server cannot be established. May also be called if the
* connection is lost and reconnection attempt fails.
*
* @param client The client that failed to connect.
* @param throwable The exception.
*/
void onConnectFailed(@Nullable Throwable throwable);
void onConnectFailed(OpampClient client, @Nullable Throwable throwable);
/**
* Called when the Server reports an error in response to some previously sent request. Useful
@ -57,9 +60,10 @@ public interface OpampClient extends Closeable {
* retrying previous operations. The client handles the ErrorResponse_UNAVAILABLE case
* internally by performing retries as necessary.
*
* @param client The client that received an error response.
* @param errorResponse The error returned by the Server.
*/
void onErrorResponse(ServerErrorResponse errorResponse);
void onErrorResponse(OpampClient client, ServerErrorResponse errorResponse);
/**
* Called when the Agent receives a message that needs processing. See {@link MessageData}
@ -70,8 +74,9 @@ public interface OpampClient extends Closeable {
* onMessage returns. This is advisable if processing can take a long time. In that case
* returning quickly is preferable to avoid blocking the {@link OpampClient}.
*
* @param client The client that received a message.
* @param messageData The server response data that needs processing.
*/
void onMessage(MessageData messageData);
void onMessage(OpampClient client, MessageData messageData);
}
}

View File

@ -146,12 +146,12 @@ public final class OpampClientImpl
@Override
public void onConnectionSuccess() {
callbacks.onConnect();
callbacks.onConnect(this);
}
@Override
public void onConnectionFailed(Throwable throwable) {
callbacks.onConnectFailed(throwable);
callbacks.onConnectFailed(this, throwable);
}
@Override
@ -168,7 +168,7 @@ public final class OpampClientImpl
preserveFailedRequestRecipe();
if (throwable instanceof OpampServerResponseException) {
ServerErrorResponse errorResponse = ((OpampServerResponseException) throwable).errorResponse;
callbacks.onErrorResponse(errorResponse);
callbacks.onErrorResponse(this, errorResponse);
}
}
@ -195,7 +195,7 @@ public final class OpampClientImpl
}
if (notifyOnMessage) {
callbacks.onMessage(messageBuilder.build());
callbacks.onMessage(this, messageBuilder.build());
}
}

View File

@ -8,6 +8,7 @@ package io.opentelemetry.opamp.client.internal.impl;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
@ -199,7 +200,8 @@ class OpampClientImplTest {
// Await for onMessage call
await().atMost(Duration.ofSeconds(5)).until(() -> callbacks.onMessageCalls.get() == 1);
verify(callbacks).onMessage(MessageData.builder().setRemoteConfig(remoteConfig).build());
verify(callbacks)
.onMessage(client, MessageData.builder().setRemoteConfig(remoteConfig).build());
}
@Test
@ -214,7 +216,7 @@ class OpampClientImplTest {
// Giving some time for the callback to get called
await().during(Duration.ofSeconds(1));
verify(callbacks, never()).onMessage(any());
verify(callbacks, never()).onMessage(eq(client), any());
}
@Test
@ -257,8 +259,8 @@ class OpampClientImplTest {
await().atMost(Duration.ofSeconds(5)).until(() -> callbacks.onConnectCalls.get() == 1);
verify(callbacks).onConnect();
verify(callbacks, never()).onConnectFailed(any());
verify(callbacks).onConnect(client);
verify(callbacks, never()).onConnectFailed(eq(client), any());
}
@Test
@ -301,8 +303,8 @@ class OpampClientImplTest {
await().atMost(Duration.ofSeconds(5)).until(() -> callbacks.onErrorResponseCalls.get() == 1);
verify(callbacks).onErrorResponse(errorResponse);
verify(callbacks, never()).onMessage(any());
verify(callbacks).onErrorResponse(client, errorResponse);
verify(callbacks, never()).onMessage(eq(client), any());
}
@Test
@ -312,7 +314,7 @@ class OpampClientImplTest {
client.onConnectionFailed(throwable);
verify(callbacks).onConnectFailed(throwable);
verify(callbacks).onConnectFailed(client, throwable);
}
@Test
@ -450,22 +452,22 @@ class OpampClientImplTest {
private final AtomicInteger onMessageCalls = new AtomicInteger();
@Override
public void onConnect() {
public void onConnect(OpampClient client) {
onConnectCalls.incrementAndGet();
}
@Override
public void onConnectFailed(@Nullable Throwable throwable) {
public void onConnectFailed(OpampClient client, @Nullable Throwable throwable) {
onConnectFailedCalls.incrementAndGet();
}
@Override
public void onErrorResponse(ServerErrorResponse errorResponse) {
public void onErrorResponse(OpampClient client, ServerErrorResponse errorResponse) {
onErrorResponseCalls.incrementAndGet();
}
@Override
public void onMessage(MessageData messageData) {
public void onMessage(OpampClient client, MessageData messageData) {
onMessageCalls.incrementAndGet();
}
}

View File

@ -7,7 +7,7 @@ description = "To help in create an OpenTelemetry distro able to runtime attach
otelJava.moduleName.set("io.opentelemetry.contrib.attach.core")
dependencies {
implementation("net.bytebuddy:byte-buddy-agent:1.17.7")
implementation("net.bytebuddy:byte-buddy-agent:1.17.8")
// Used by byte-buddy but not brought in as a transitive dependency.
compileOnly("com.google.code.findbugs:annotations")

View File

@ -24,6 +24,48 @@ dependencies {
testImplementation("org.assertj:assertj-core")
}
testing {
suites {
val test by getting(JvmTestSuite::class) {
targets.all {
testTask.configure {
setForkEvery(1) // One JVM by test class to avoid a test class launching a runtime attachment influences the behavior of another test class
filter {
excludeTestsMatching("AgentDisabledByEnvironmentVariableTest")
excludeTestsMatching("AgentDisabledBySystemPropertyTest")
}
}
}
}
val testAgentDisabledByEnvironmentVariable by registering(JvmTestSuite::class) {
targets.all {
testTask.configure {
setForkEvery(1)
filter {
includeTestsMatching("AgentDisabledByEnvironmentVariableTest")
}
include("**/AgentDisabledByEnvironmentVariableTest.*")
environment("OTEL_JAVAAGENT_ENABLED", "false")
}
}
}
val testAgentDisabledBySystemProperty by registering(JvmTestSuite::class) {
targets.all {
testTask.configure {
setForkEvery(1)
filter {
includeTestsMatching("AgentDisabledBySystemPropertyTest")
}
include("**/AgentDisabledBySystemPropertyTest.*")
jvmArgs("-Dotel.javaagent.enabled=false")
}
}
}
}
}
tasks {
jar {
inputs.files(agent)
@ -32,36 +74,4 @@ tasks {
})
rename("^(.*)\\.jar\$", "otel-agent.jar")
}
withType<Test>().configureEach {
setForkEvery(1) // One JVM by test class to avoid a test class launching a runtime attachment influences the behavior of another test class
}
val testAgentDisabledByEnvironmentVariable by registering(Test::class) {
filter {
includeTestsMatching("AgentDisabledByEnvironmentVariableTest")
}
include("**/AgentDisabledByEnvironmentVariableTest.*")
environment("OTEL_JAVAAGENT_ENABLED", "false")
}
val testAgentDisabledBySystemProperty by registering(Test::class) {
filter {
includeTestsMatching("AgentDisabledBySystemPropertyTest")
}
include("**/AgentDisabledBySystemPropertyTest.*")
jvmArgs("-Dotel.javaagent.enabled=false")
}
test {
filter {
excludeTestsMatching("AgentDisabledByEnvironmentVariableTest")
excludeTestsMatching("AgentDisabledBySystemPropertyTest")
}
}
check {
dependsOn(testAgentDisabledByEnvironmentVariable)
dependsOn(testAgentDisabledBySystemProperty)
}
}

View File

@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
package internal;
package io.opentelemetry.contrib.sampler.internal;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@ -15,7 +15,6 @@ import io.opentelemetry.api.incubator.config.DeclarativeConfigProperties;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.context.Context;
import io.opentelemetry.contrib.sampler.RuleBasedRoutingSampler;
import io.opentelemetry.contrib.sampler.internal.RuleBasedRoutingSamplerComponentProvider;
import io.opentelemetry.sdk.OpenTelemetrySdk;
import io.opentelemetry.sdk.extension.incubator.fileconfig.DeclarativeConfiguration;
import io.opentelemetry.sdk.trace.IdGenerator;

View File

@ -2,7 +2,7 @@ pluginManagement {
plugins {
id("com.gradleup.shadow") version "9.2.2"
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
id("com.gradle.develocity") version "4.2.1"
id("com.gradle.develocity") version "4.2.2"
}
}