Skip to content

Commit 811d197

Browse files
committed
fix it & apply spotless
1 parent 1a914b0 commit 811d197

File tree

8 files changed

+39
-17
lines changed

8 files changed

+39
-17
lines changed

messaging-wrappers/README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ detailed example, please check out [KafkaClientTest](./kafka-clients/src/test/ja
4747
To use OpenTelemetry in your project, you need to add the necessary dependencies. Below are the configurations for both
4848
Gradle and Maven.
4949

50-
#### Gradle
50+
### [Given] Gradle
5151

5252
```kotlin
5353
dependencies {
5454
implementation("io.opentelemetry.contrib:opentelemetry-messaging-wrappers-kafka-clients:${latest_version}")
5555
}
5656
```
5757

58-
#### Maven
58+
### [Given] Maven
5959

6060
```xml
6161
<dependency>
@@ -125,15 +125,15 @@ custom message protocol. For detailed example, please check out [UserDefinedMess
125125

126126
### [Manual] Step 1 Add dependencies
127127

128-
#### Gradle
128+
#### [Manual] Gradle
129129

130130
```kotlin
131131
dependencies {
132132
implementation("io.opentelemetry.contrib:opentelemetry-messaging-wrappers-api:${latest_version}")
133133
}
134134
```
135135

136-
#### Maven
136+
#### [Manual] Maven
137137

138138
```xml
139139
<dependency>
@@ -209,4 +209,3 @@ public class Demo {
209209
- [Steve Rao](https://github.com/steverao), Alibaba
210210

211211
Learn more about component owners in [component_owners.yml](../.github/component_owners.yml).
212-

messaging-wrappers/aliyun-mns-sdk/build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,10 @@ tasks {
3131
jvmArgs("-Dotel.logs.exporter=logging")
3232
}
3333
}
34+
35+
configurations.testRuntimeClasspath {
36+
resolutionStrategy {
37+
force("ch.qos.logback:logback-classic:1.2.12")
38+
force("org.slf4j:slf4j-api:1.7.35")
39+
}
40+
}

messaging-wrappers/aliyun-mns-sdk/src/test/java/io/opentelemetry/contrib/messaging/wrappers/mns/AliyunMnsSdkTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
99
import static io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME;
1010
import static io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes.MESSAGING_MESSAGE_BODY_SIZE;
11+
import static io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes.MESSAGING_MESSAGE_ENVELOPE_SIZE;
1112
import static io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes.MESSAGING_OPERATION;
1213
import static io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes.MESSAGING_SYSTEM;
1314
import static org.assertj.core.api.Assertions.assertThat;
@@ -30,6 +31,7 @@
3031
import io.opentelemetry.contrib.messaging.wrappers.mns.semconv.MnsProcessRequest;
3132
import io.opentelemetry.contrib.messaging.wrappers.testing.AbstractBaseTest;
3233
import java.nio.charset.StandardCharsets;
34+
import org.apache.commons.codec.binary.Base64;
3335
import org.junit.jupiter.api.BeforeAll;
3436
import org.junit.jupiter.api.Test;
3537
import org.junit.jupiter.api.TestInstance;
@@ -140,11 +142,15 @@ public void assertTraces() {
140142
.hasKind(SpanKind.CONSUMER)
141143
.hasParent(trace.getSpan(0))
142144
.hasAttributesSatisfyingExactly(
143-
equalTo(MESSAGING_SYSTEM, "guava-eventbus"),
145+
equalTo(MESSAGING_SYSTEM, "smq"),
144146
equalTo(MESSAGING_DESTINATION_NAME, QUEUE),
145147
equalTo(
146148
MESSAGING_MESSAGE_BODY_SIZE,
147149
MESSAGE_BODY.getBytes(StandardCharsets.UTF_8).length),
150+
equalTo(
151+
MESSAGING_MESSAGE_ENVELOPE_SIZE,
152+
Base64.encodeBase64(MESSAGE_BODY.getBytes(StandardCharsets.UTF_8))
153+
.length),
148154
equalTo(MESSAGING_OPERATION, "process")),
149155
span ->
150156
span.hasName("process child")

messaging-wrappers/aliyun-mns-sdk/src/test/java/io/opentelemetry/contrib/messaging/wrappers/mns/broker/SmqMockedBroker.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,22 @@
4949
import org.springframework.web.bind.annotation.RequestParam;
5050

5151
@SpringBootApplication
52-
@SuppressWarnings({"JavaUtilDate", "LockNotBeforeTry", "SystemOut"})
52+
@SuppressWarnings({
53+
"JavaUtilDate",
54+
"LockNotBeforeTry",
55+
"SystemOut",
56+
"PrivateConstructorForUtilityClass"
57+
})
5358
public class SmqMockedBroker {
5459

5560
public static void main(String[] args) {
56-
System.out.println(System.getProperty("java.class.path"));
5761
SpringApplication.run(SmqMockedBroker.class, args);
5862
}
5963

6064
@Controller
6165
@Scope("singleton")
6266
public static class BrokerController {
63-
67+
6468
Lock queuesLock = new ReentrantLock();
6569

6670
Map<String, Deque<Message>> queues = new HashMap<>();
@@ -225,7 +229,4 @@ public ResponseEntity<Void> serveDeleteMessage(
225229
.build();
226230
}
227231
}
228-
229-
private SmqMockedBroker() {
230-
}
231232
}

messaging-wrappers/aliyun-mns-sdk/src/test/java/io/opentelemetry/contrib/messaging/wrappers/mns/broker/SmqUtils.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ public static String generateRandomMessageId() {
4141
}
4242

4343
public static String generateRandomRequestId() {
44-
return UUID.randomUUID().toString().replaceAll("-", "").substring(0, 24).toUpperCase(Locale.ROOT);
44+
return UUID.randomUUID()
45+
.toString()
46+
.replaceAll("-", "")
47+
.substring(0, 24)
48+
.toUpperCase(Locale.ROOT);
4549
}
4650

4751
public static ErrorMessage createErrorMessage(String requestId) {
@@ -68,6 +72,5 @@ private static String bytesToHex(byte[] bytes) {
6872
return sb.toString();
6973
}
7074

71-
private SmqUtils() {
72-
}
75+
private SmqUtils() {}
7376
}

messaging-wrappers/kafka-clients/build.gradle.kts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,9 @@ tasks {
3838
jvmArgs("-Dotel.logs.exporter=logging")
3939
}
4040
}
41+
42+
configurations.all {
43+
resolutionStrategy {
44+
force("org.apache.kafka:kafka-clients:0.11.0.0")
45+
}
46+
}

messaging-wrappers/kafka-clients/src/test/java/io/opentelemetry/contrib/messaging/wrappers/kafka/KafkaClientBaseTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public void awaitUntilConsumerIsReady() throws InterruptedException {
135135
return;
136136
}
137137
for (int i = 0; i < 60; i++) {
138-
consumer.poll(Duration.ZERO);
138+
consumer.poll(0L);
139139
if (consumerReady.await(3, TimeUnit.SECONDS)) {
140140
break;
141141
}

messaging-wrappers/kafka-clients/src/test/java/io/opentelemetry/contrib/messaging/wrappers/kafka/KafkaClientTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public void sendWithParent(Tracer tracer) {
104104
public void consumeWithChild(
105105
Tracer tracer, MessagingProcessWrapper<KafkaProcessRequest> wrapper) {
106106
// check that the message was received
107-
ConsumerRecords<?, ?> records = consumer.poll(Duration.ofSeconds(5));
107+
ConsumerRecords<?, ?> records = consumer.poll(Duration.ofSeconds(5).toMillis());
108108
assertThat(records.count()).isEqualTo(1);
109109
ConsumerRecord<?, ?> record = records.iterator().next();
110110
assertThat(record.value()).isEqualTo(greeting);

0 commit comments

Comments
 (0)