Skip to content

Commit 059461f

Browse files
committed
Merge branch 'main' of github.com:open-telemetry/opentelemetry-java-instrumentation into indy-migration-2
2 parents 873e072 + 239a6a9 commit 059461f

File tree

46 files changed

+1626
-798
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1626
-798
lines changed

conventions/src/main/kotlin/otel.java-conventions.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ dependencies {
161161
compileOnly("com.google.errorprone:error_prone_annotations")
162162

163163
codenarc("org.codenarc:CodeNarc:3.6.0")
164-
codenarc(platform("org.codehaus.groovy:groovy-bom:3.0.24"))
164+
codenarc(platform("org.codehaus.groovy:groovy-bom:3.0.25"))
165165

166166
modules {
167167
// checkstyle uses the very old google-collections which causes Java 9 module conflict with

dependencyManagement/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ val otelContribVersion = "1.46.0-alpha"
1010
val otelSdkAlphaVersion = otelSdkVersion.replaceFirst("(-SNAPSHOT)?$".toRegex(), "-alpha$1")
1111

1212
// Need both BOM and groovy jars
13-
val groovyVersion = "4.0.26"
13+
val groovyVersion = "4.0.27"
1414

1515
// We don't force libraries we instrument to new versions since we compile and test against specific
1616
// old baseline versions but we do try to force those libraries' transitive dependencies to new

instrumentation/camel-2.20/javaagent-unit-tests/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/CamelPropagationUtilTest.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,16 @@
2626
import org.junit.jupiter.api.BeforeAll;
2727
import org.junit.jupiter.api.Test;
2828

29-
public class CamelPropagationUtilTest {
29+
class CamelPropagationUtilTest {
3030

3131
@BeforeAll
32-
public static void setUp() {
32+
static void setUp() {
3333
GlobalOpenTelemetry.set(
3434
OpenTelemetry.propagating(ContextPropagators.create(JaegerPropagator.getInstance())));
3535
}
3636

3737
@Test
38-
public void shouldExtractHttpParentForHttpEndpoint() throws Exception {
39-
38+
void shouldExtractHttpParentForHttpEndpoint() throws Exception {
4039
// given
4140
Endpoint endpoint = new HttpEndpoint("", new HttpComponent(), URI.create(""));
4241
Map<String, Object> exchangeHeaders =
@@ -54,8 +53,7 @@ public void shouldExtractHttpParentForHttpEndpoint() throws Exception {
5453
}
5554

5655
@Test
57-
public void shouldNotFailExtractingNullHttpParentForHttpEndpoint() throws Exception {
58-
56+
void shouldNotFailExtractingNullHttpParentForHttpEndpoint() throws Exception {
5957
// given
6058
Endpoint endpoint = new HttpEndpoint("", new HttpComponent(), URI.create(""));
6159
Map<String, Object> exchangeHeaders = Collections.singletonMap("uber-trace-id", null);
@@ -70,8 +68,7 @@ public void shouldNotFailExtractingNullHttpParentForHttpEndpoint() throws Except
7068
}
7169

7270
@Test
73-
public void shouldNotFailExtractingNullAwsParentForSqsEndpoint() {
74-
71+
void shouldNotFailExtractingNullAwsParentForSqsEndpoint() {
7572
// given
7673
Endpoint endpoint = new SqsEndpoint("", new SqsComponent(), new SqsConfiguration());
7774
Map<String, Object> exchangeHeaders = Collections.singletonMap("AWSTraceHeader", null);
@@ -86,8 +83,7 @@ public void shouldNotFailExtractingNullAwsParentForSqsEndpoint() {
8683
}
8784

8885
@Test
89-
public void shouldExtractAwsParentForSqsEndpoint() {
90-
86+
void shouldExtractAwsParentForSqsEndpoint() {
9187
// given
9288
Endpoint endpoint = new SqsEndpoint("", new SqsComponent(), new SqsConfiguration());
9389
Map<String, Object> exchangeHeaders =

instrumentation/camel-2.20/javaagent-unit-tests/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/SanitizationTest.java

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
package io.opentelemetry.javaagent.instrumentation.apachecamel.decorators;
77

8-
import static org.junit.jupiter.api.Assertions.assertEquals;
8+
import static org.assertj.core.api.Assertions.assertThat;
99
import static org.mockito.Mockito.mock;
1010
import static org.mockito.Mockito.when;
1111

@@ -20,6 +20,18 @@
2020

2121
class SanitizationTest {
2222

23+
static class CqlArgs implements ArgumentsProvider {
24+
@Override
25+
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
26+
return Stream.of(
27+
Arguments.of("FROM TABLE WHERE FIELD>=-1234", "FROM TABLE WHERE FIELD>=?"),
28+
Arguments.of(
29+
"SELECT Name, Phone.Number FROM Contact WHERE Address.State = 'NY'",
30+
"SELECT Name, Phone.Number FROM Contact WHERE Address.State = ?"),
31+
Arguments.of("FROM col WHERE @Tag='Something'", "FROM col WHERE @Tag=?"));
32+
}
33+
}
34+
2335
@ParameterizedTest
2436
@ArgumentsSource(CqlArgs.class)
2537
void sanitizeCql(String original, String expected) {
@@ -31,7 +43,22 @@ void sanitizeCql(String original, String expected) {
3143
when(exchange.getIn()).thenReturn(message);
3244

3345
String actualSanitized = decorator.getStatement(exchange, null);
34-
assertEquals(expected, actualSanitized);
46+
assertThat(actualSanitized).isEqualTo(expected);
47+
}
48+
49+
static class JdbcArgs implements ArgumentsProvider {
50+
@Override
51+
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
52+
return Stream.of(
53+
Arguments.of("SELECT 3", "SELECT ?"),
54+
Arguments.of(
55+
"SELECT * FROM TABLE WHERE FIELD = 1234", "SELECT * FROM TABLE WHERE FIELD = ?"),
56+
Arguments.of(
57+
"SELECT * FROM TABLE WHERE FIELD<-1234", "SELECT * FROM TABLE WHERE FIELD<?"),
58+
Arguments.of(
59+
"SELECT col1 AS col2 FROM users WHERE field=1234",
60+
"SELECT col1 AS col2 FROM users WHERE field=?"));
61+
}
3562
}
3663

3764
@ParameterizedTest
@@ -45,22 +72,7 @@ void sanitizeJdbc(String original, String expected) {
4572
when(exchange.getIn()).thenReturn(message);
4673

4774
String actualSanitized = decorator.getStatement(exchange, null);
48-
assertEquals(expected, actualSanitized);
49-
}
50-
51-
@ParameterizedTest
52-
@ArgumentsSource(SqlArgs.class)
53-
void sanitizeSql(String original, String expected) {
54-
55-
DbSpanDecorator decorator = new DbSpanDecorator("sql", "");
56-
57-
Exchange exchange = mock(Exchange.class);
58-
Message message = mock(Message.class);
59-
when(message.getHeader("CamelSqlQuery")).thenReturn(original);
60-
when(exchange.getIn()).thenReturn(message);
61-
62-
String actualSanitized = decorator.getStatement(exchange, null);
63-
assertEquals(expected, actualSanitized);
75+
assertThat(actualSanitized).isEqualTo(expected);
6476
}
6577

6678
static class SqlArgs implements ArgumentsProvider {
@@ -75,30 +87,18 @@ public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
7587
}
7688
}
7789

78-
static class CqlArgs implements ArgumentsProvider {
79-
@Override
80-
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
81-
return Stream.of(
82-
Arguments.of("FROM TABLE WHERE FIELD>=-1234", "FROM TABLE WHERE FIELD>=?"),
83-
Arguments.of(
84-
"SELECT Name, Phone.Number FROM Contact WHERE Address.State = 'NY'",
85-
"SELECT Name, Phone.Number FROM Contact WHERE Address.State = ?"),
86-
Arguments.of("FROM col WHERE @Tag='Something'", "FROM col WHERE @Tag=?"));
87-
}
88-
}
90+
@ParameterizedTest
91+
@ArgumentsSource(SqlArgs.class)
92+
void sanitizeSql(String original, String expected) {
8993

90-
static class JdbcArgs implements ArgumentsProvider {
91-
@Override
92-
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
93-
return Stream.of(
94-
Arguments.of("SELECT 3", "SELECT ?"),
95-
Arguments.of(
96-
"SELECT * FROM TABLE WHERE FIELD = 1234", "SELECT * FROM TABLE WHERE FIELD = ?"),
97-
Arguments.of(
98-
"SELECT * FROM TABLE WHERE FIELD<-1234", "SELECT * FROM TABLE WHERE FIELD<?"),
99-
Arguments.of(
100-
"SELECT col1 AS col2 FROM users WHERE field=1234",
101-
"SELECT col1 AS col2 FROM users WHERE field=?"));
102-
}
94+
DbSpanDecorator decorator = new DbSpanDecorator("sql", "");
95+
96+
Exchange exchange = mock(Exchange.class);
97+
Message message = mock(Message.class);
98+
when(message.getHeader("CamelSqlQuery")).thenReturn(original);
99+
when(exchange.getIn()).thenReturn(message);
100+
101+
String actualSanitized = decorator.getStatement(exchange, null);
102+
assertThat(actualSanitized).isEqualTo(expected);
103103
}
104104
}

instrumentation/camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/DecoratorRegistry.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,14 @@ private static Map<String, SpanDecorator> loadDecorators() {
3232
result.put("direct-vm", new InternalSpanDecorator());
3333
result.put("disruptor", new InternalSpanDecorator());
3434
result.put("disruptor-vm", new InternalSpanDecorator());
35-
result.put("elasticsearch", new DbSpanDecorator("elasticsearch", "elasticsearch"));
36-
result.put("opensearch", new DbSpanDecorator("opensearch", "opensearch"));
35+
result.put(
36+
"elasticsearch",
37+
new DbSpanDecorator(
38+
"elasticsearch", DbIncubatingAttributes.DbSystemIncubatingValues.ELASTICSEARCH));
39+
result.put(
40+
"opensearch",
41+
new DbSpanDecorator(
42+
"opensearch", DbIncubatingAttributes.DbSystemIncubatingValues.OPENSEARCH));
3743
result.put("http4", new Http4SpanDecorator());
3844
result.put("https4", new Https4SpanDecorator());
3945
result.put("http", new HttpSpanDecorator());

instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/DirectCamelTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
class DirectCamelTest extends AbstractHttpServerUsingTest<ConfigurableApplicationContext> {
2525

2626
@RegisterExtension
27-
public static final InstrumentationExtension testing =
28-
HttpServerInstrumentationExtension.forAgent();
27+
static final InstrumentationExtension testing = HttpServerInstrumentationExtension.forAgent();
2928

3029
private ConfigurableApplicationContext appContext;
3130

instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/MulticastDirectCamelTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
class MulticastDirectCamelTest extends AbstractHttpServerUsingTest<ConfigurableApplicationContext> {
2525

2626
@RegisterExtension
27-
public static final InstrumentationExtension testing =
28-
HttpServerInstrumentationExtension.forAgent();
27+
static final InstrumentationExtension testing = HttpServerInstrumentationExtension.forAgent();
2928

3029
private ConfigurableApplicationContext appContext;
3130

instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/RestCamelTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@
3939
class RestCamelTest extends AbstractHttpServerUsingTest<ConfigurableApplicationContext> {
4040

4141
@RegisterExtension
42-
public static final InstrumentationExtension testing =
43-
HttpServerInstrumentationExtension.forAgent();
42+
static final InstrumentationExtension testing = HttpServerInstrumentationExtension.forAgent();
4443

4544
private ConfigurableApplicationContext appContext;
4645

instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/SingleServiceCamelTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
class SingleServiceCamelTest extends AbstractHttpServerUsingTest<ConfigurableApplicationContext> {
2727

2828
@RegisterExtension
29-
public static final InstrumentationExtension testing =
30-
HttpServerInstrumentationExtension.forAgent();
29+
static final InstrumentationExtension testing = HttpServerInstrumentationExtension.forAgent();
3130

3231
@Override
3332
protected ConfigurableApplicationContext setupServer() {

instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/TwoServicesWithDirectClientCamelTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@
4242
class TwoServicesWithDirectClientCamelTest
4343
extends AbstractHttpServerUsingTest<ConfigurableApplicationContext> {
4444
@RegisterExtension
45-
public static final InstrumentationExtension testing =
46-
HttpServerInstrumentationExtension.forAgent();
45+
static final InstrumentationExtension testing = HttpServerInstrumentationExtension.forAgent();
4746

4847
private static CamelContext clientContext;
4948

0 commit comments

Comments
 (0)