Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/agents/knowledge/general-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ Reason about visibility from "what does the advice method directly reference?".
## [Style] `@SuppressWarnings` Usage

- Place `@SuppressWarnings` on the single member that needs it, or on the class when two
or more members in the class need the same suppression.
or more members in the class need the same suppression. Do not move an existing
suppression from a member to the class unless multiple members need it.
- **Do not add `@SuppressWarnings("deprecation")` unless the build fails without it.**
The project disables javac's `-Xlint:deprecation` globally and uses a custom Error Prone
check (`OtelDeprecatedApiUsage`) instead. Only add the annotation when it is actually
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.nio.file.Paths;
import java.util.Optional;
import java.util.logging.Logger;
import javax.annotation.Nullable;

class SystemHelper {
private static final Logger logger = Logger.getLogger(SystemHelper.class.getName());
Expand All @@ -31,10 +32,12 @@ class SystemHelper {
}
}

@Nullable
String getenv(String name) {
return System.getenv(name);
}

@Nullable
String getProperty(String key) {
return System.getProperty(key);
}
Expand All @@ -44,6 +47,7 @@ String getProperty(String key) {
* bootJar layouts the application classes live under {@code BOOT-INF/classes/}, so the prefix is
* applied when that layout is detected.
*/
@Nullable
InputStream openClasspathResource(String filename) {
String path = addBootInfPrefix ? "BOOT-INF/classes/" + filename : filename;
return classLoader.getResourceAsStream(path);
Expand All @@ -54,6 +58,7 @@ InputStream openClasspathResource(String filename) {
* This is used for things like {@code META-INF/build-info.properties}, which Spring Boot places
* at the jar root rather than under {@code BOOT-INF/classes/}.
*/
@Nullable
InputStream openJarRootResource(String path) {
return classLoader.getResourceAsStream(path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
import org.apache.pekko.http.scaladsl.Http;
import org.assertj.core.api.AbstractStringAssert;
import org.elasticmq.rest.sqs.SQSRestServer;
Expand Down Expand Up @@ -71,7 +69,7 @@ static void cleanUp() {
}

@Test
void sqsListener() throws InterruptedException, ExecutionException, TimeoutException {
void sqsListener() throws Exception {
String messageContent = "hello";
CompletableFuture<String> messageFuture = new CompletableFuture<>();
AwsSqsTestApplication.messageHandler =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies {
latestDepTestLibrary("org.springframework.boot:spring-boot-starter-test:3.+") // see spring-cloud-gateway-4.3* module
}

tasks.withType<Test>().configureEach {
tasks.test {
jvmArgs("-Dotel.instrumentation.spring-cloud-gateway.experimental-span-attributes=true")

// required on jdk17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class SimpleAsyncTaskExecutorInstrumentationTest {
private static Method findMethod(String name, Class<?>... parameterTypes) {
try {
return SimpleAsyncTaskExecutor.class.getMethod(name, parameterTypes);
} catch (NoSuchMethodException e) {
} catch (NoSuchMethodException ignored) {
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.springframework.dao.IncorrectResultSizeDataAccessException;
import org.springframework.data.jpa.repository.JpaRepository;

@SuppressWarnings("deprecation") // TODO DB_CONNECTION_STRING deprecation
public abstract class AbstractSpringJpaTest<
ENTITY, REPOSITORY extends JpaRepository<ENTITY, Long>> {

Expand Down Expand Up @@ -74,7 +75,6 @@ void testObjectMethod() {
span -> span.hasName("toString test").hasTotalAttributeCount(0)));
}

@SuppressWarnings("deprecation") // TODO DB_CONNECTION_STRING deprecation
static void assertHibernate4Trace(TraceAssert trace, String repoClassName) {
trace.hasSpansSatisfyingExactly(
span ->
Expand Down Expand Up @@ -103,7 +103,6 @@ DB_CONNECTION_STRING, emitStableDatabaseSemconv() ? null : "hsqldb:mem:"),
emitStableDatabaseSemconv() ? null : "JpaCustomer")));
}

@SuppressWarnings("deprecation") // TODO DB_CONNECTION_STRING deprecation
static void assertHibernateTrace(TraceAssert trace, String repoClassName) {
trace.hasSpansSatisfyingExactly(
span ->
Expand Down Expand Up @@ -163,7 +162,6 @@ DB_CONNECTION_STRING, emitStableDatabaseSemconv() ? null : "hsqldb:mem:"),
emitStableDatabaseSemconv() ? null : "JpaCustomer")));
}

@SuppressWarnings("deprecation") // TODO DB_CONNECTION_STRING deprecation
@Test
void testCrud() {
boolean isHibernate4 = Version.getVersionString().startsWith("4.");
Expand Down Expand Up @@ -374,7 +372,6 @@ void testCrud() {
emitStableDatabaseSemconv() ? null : "JpaCustomer"))));
}

@SuppressWarnings("deprecation") // TODO DB_CONNECTION_STRING deprecation
@Test
void testCustomRepositoryMethod() {
REPOSITORY repo = repository();
Expand Down Expand Up @@ -417,7 +414,6 @@ void testCustomRepositoryMethod() {
emitStableDatabaseSemconv() ? null : "JpaCustomer"))));
}

@SuppressWarnings("deprecation") // TODO DB_CONNECTION_STRING deprecation
@Test
void testFailedRepositoryMethod() {
// given
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies {
}

tasks {
withType<Test>().configureEach {
test {
systemProperty("testLatestDeps", otelProps.testLatestDeps)
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,6 @@ public SpringIntegrationTelemetryBuilder setProducerSpanEnabled(boolean producer
return this;
}

private static String consumerSpanName(MessageWithChannel messageWithChannel) {
return messageWithChannel.getChannelName() + " process";
}

private static String producerSpanName(MessageWithChannel messageWithChannel) {
return messageWithChannel.getChannelName() + " publish";
}

/**
* Returns a new {@link SpringIntegrationTelemetry} with the settings of this {@link
* SpringIntegrationTelemetryBuilder}.
Expand Down Expand Up @@ -112,6 +104,14 @@ public SpringIntegrationTelemetry build() {
producerSpanEnabled);
}

private static String consumerSpanName(MessageWithChannel messageWithChannel) {
return messageWithChannel.getChannelName() + " process";
}

private static String producerSpanName(MessageWithChannel messageWithChannel) {
return messageWithChannel.getChannelName() + " publish";
}

private static AttributesExtractor<MessageWithChannel, Void> buildMessagingAttributesExtractor(
MessagingAttributesGetter<MessageWithChannel, Void> getter,
MessageOperation operation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import static java.util.stream.Collectors.toMap;

import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.testing.internal.AutoCleanupExtension;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -17,9 +18,9 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
Expand All @@ -35,6 +36,8 @@

abstract class AbstractComplexPropagationTest {

@RegisterExtension static final AutoCleanupExtension cleanup = AutoCleanupExtension.create();

private final Class<?> additionalContextClass;
private final InstrumentationExtension testing;

Expand All @@ -58,13 +61,7 @@ void setUp() {
springApplication.setDefaultProperties(
singletonMap("spring.main.web-application-type", "none"));
applicationContext = springApplication.run();
}

@AfterEach
void tearDown() {
if (applicationContext != null) {
applicationContext.close();
}
cleanup.deferCleanup(applicationContext);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
import static org.assertj.core.api.Assertions.assertThat;

import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.testing.internal.AutoCleanupExtension;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.sdk.trace.data.SpanData;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.springframework.boot.SpringApplication;
Expand All @@ -37,6 +38,8 @@

abstract class AbstractSpringIntegrationTracingTest {

@RegisterExtension static final AutoCleanupExtension cleanup = AutoCleanupExtension.create();

private final InstrumentationExtension testing;

private final Class<?> additionalContextClass;
Expand All @@ -61,13 +64,7 @@ void setUp() {
springApplication.setDefaultProperties(
singletonMap("spring.main.web-application-type", "none"));
applicationContext = springApplication.run();
}

@AfterEach
void tearDown() {
if (applicationContext != null) {
applicationContext.close();
}
cleanup.deferCleanup(applicationContext);
}

@ParameterizedTest
Expand Down
Loading