Skip to content

Commit c73a7ec

Browse files
committed
fix build and format test
1 parent e588d1e commit c73a7ec

File tree

33 files changed

+449
-358
lines changed

33 files changed

+449
-358
lines changed

messaging-wrappers/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,4 @@ public class Demo {
115115
- [Steve Rao](https://github.com/steverao), Alibaba
116116

117117
Learn more about component owners in [component_owners.yml](../.github/component_owners.yml).
118+
Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
16
package io.opentelemetry.contrib.messaging.wrappers.mns;
27

38
import com.aliyun.mns.model.BaseMessage;
49
import com.aliyun.mns.model.MessagePropertyValue;
510
import com.aliyun.mns.model.MessageSystemPropertyName;
611
import com.aliyun.mns.model.MessageSystemPropertyValue;
7-
import io.opentelemetry.contrib.messaging.wrappers.mns.semconv.MNSProcessRequest;
12+
import io.opentelemetry.contrib.messaging.wrappers.mns.semconv.MnsProcessRequest;
13+
14+
import javax.annotation.Nullable;
815

9-
public final class MNSHelper {
16+
public final class MnsHelper {
1017

11-
public static <REQUEST extends MNSProcessRequest> MNSProcessWrapperBuilder<REQUEST> processWrapperBuilder() {
12-
return new MNSProcessWrapperBuilder<>();
18+
public static <REQUEST extends MnsProcessRequest>
19+
MnsProcessWrapperBuilder<REQUEST> processWrapperBuilder() {
20+
return new MnsProcessWrapperBuilder<>();
1321
}
1422

23+
@Nullable
1524
public static String getMessageHeader(BaseMessage message, String name) {
1625
MessageSystemPropertyName key = convert2SystemPropertyName(name);
1726
if (key != null) {
@@ -27,9 +36,8 @@ public static String getMessageHeader(BaseMessage message, String name) {
2736
return null;
2837
}
2938

30-
/**
31-
* see {@link MessageSystemPropertyName}
32-
* */
39+
/** see {@link MessageSystemPropertyName} */
40+
@Nullable
3341
public static MessageSystemPropertyName convert2SystemPropertyName(String name) {
3442
if (name == null) {
3543
return null;
@@ -43,6 +51,5 @@ public static MessageSystemPropertyName convert2SystemPropertyName(String name)
4351
return null;
4452
}
4553

46-
private MNSHelper() {
47-
}
54+
private MnsHelper() {}
4855
}
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
16
package io.opentelemetry.contrib.messaging.wrappers.mns;
27

38
import io.opentelemetry.contrib.messaging.wrappers.DefaultMessagingProcessWrapperBuilder;
4-
import io.opentelemetry.contrib.messaging.wrappers.mns.semconv.MNSProcessRequest;
9+
import io.opentelemetry.contrib.messaging.wrappers.mns.semconv.MnsProcessRequest;
510

6-
public class MNSProcessWrapperBuilder<REQUEST extends MNSProcessRequest>
11+
public class MnsProcessWrapperBuilder<REQUEST extends MnsProcessRequest>
712
extends DefaultMessagingProcessWrapperBuilder<REQUEST> {
813

9-
MNSProcessWrapperBuilder() {
14+
MnsProcessWrapperBuilder() {
1015
super();
11-
super.textMapGetter = MNSTextMapGetter.create();
16+
super.textMapGetter = MnsTextMapGetter.create();
1217
}
1318
}
Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
16
package io.opentelemetry.contrib.messaging.wrappers.mns;
27

38
import static java.util.Collections.emptyList;
49

5-
import com.aliyun.mns.model.*;
10+
import com.aliyun.mns.model.Message;
11+
import com.aliyun.mns.model.MessagePropertyValue;
12+
import com.aliyun.mns.model.MessageSystemPropertyName;
13+
import com.aliyun.mns.model.MessageSystemPropertyValue;
614
import io.opentelemetry.context.propagation.TextMapGetter;
7-
import io.opentelemetry.contrib.messaging.wrappers.mns.semconv.MNSProcessRequest;
8-
9-
import javax.annotation.Nullable;
15+
import io.opentelemetry.contrib.messaging.wrappers.mns.semconv.MnsProcessRequest;
1016
import java.util.ArrayList;
1117
import java.util.Collections;
1218
import java.util.List;
1319
import java.util.Map;
20+
import javax.annotation.Nullable;
1421

15-
public class MNSTextMapGetter<REQUEST extends MNSProcessRequest> implements TextMapGetter<REQUEST> {
22+
public class MnsTextMapGetter<REQUEST extends MnsProcessRequest> implements TextMapGetter<REQUEST> {
1623

17-
public static <REQUEST extends MNSProcessRequest> TextMapGetter<REQUEST> create() {
18-
return new MNSTextMapGetter<>();
24+
public static <REQUEST extends MnsProcessRequest> TextMapGetter<REQUEST> create() {
25+
return new MnsTextMapGetter<>();
1926
}
2027

2128
@Override
@@ -39,6 +46,7 @@ public Iterable<String> keys(@Nullable REQUEST carrier) {
3946
return keys;
4047
}
4148

49+
@Nullable
4250
@Override
4351
public String get(@Nullable REQUEST carrier, String key) {
4452
if (carrier == null || carrier.getMessage() == null) {
@@ -47,7 +55,7 @@ public String get(@Nullable REQUEST carrier, String key) {
4755
Message message = carrier.getMessage();
4856

4957
// the system property should always take precedence over the user property
50-
MessageSystemPropertyName systemPropertyName = MNSHelper.convert2SystemPropertyName(key);
58+
MessageSystemPropertyName systemPropertyName = MnsHelper.convert2SystemPropertyName(key);
5159
if (systemPropertyName != null) {
5260
MessageSystemPropertyValue value = message.getSystemProperty(systemPropertyName);
5361
if (value != null) {
@@ -66,6 +74,5 @@ public String get(@Nullable REQUEST carrier, String key) {
6674
return null;
6775
}
6876

69-
private MNSTextMapGetter() {
70-
}
77+
private MnsTextMapGetter() {}
7178
}

messaging-wrappers/aliyun-mns-sdk/src/main/java/io/opentelemetry/contrib/messaging/wrappers/mns/example/MNSConsumer.java

Lines changed: 0 additions & 72 deletions
This file was deleted.
Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
16
package io.opentelemetry.contrib.messaging.wrappers.mns.semconv;
27

38
import com.aliyun.mns.model.Message;
4-
import io.opentelemetry.contrib.messaging.wrappers.mns.MNSHelper;
9+
import io.opentelemetry.contrib.messaging.wrappers.mns.MnsHelper;
510
import io.opentelemetry.contrib.messaging.wrappers.semconv.MessagingProcessRequest;
6-
7-
import javax.annotation.Nullable;
811
import java.util.Collections;
912
import java.util.List;
13+
import javax.annotation.Nullable;
1014

11-
public class MNSProcessRequest implements MessagingProcessRequest {
15+
public class MnsProcessRequest implements MessagingProcessRequest {
1216

1317
private final Message message;
1418

15-
@Nullable
16-
private final String destination;
19+
@Nullable private final String destination;
1720

18-
public static MNSProcessRequest of(Message message) {
21+
public static MnsProcessRequest of(Message message) {
1922
return of(message, null);
2023
}
2124

22-
public static MNSProcessRequest of(Message message, @Nullable String destination) {
23-
return new MNSProcessRequest(message, destination);
25+
public static MnsProcessRequest of(Message message, @Nullable String destination) {
26+
return new MnsProcessRequest(message, destination);
2427
}
2528

2629
@Override
@@ -76,7 +79,7 @@ public String getMessageId() {
7679

7780
@Override
7881
public List<String> getMessageHeader(String name) {
79-
String header = MNSHelper.getMessageHeader(message, name);
82+
String header = MnsHelper.getMessageHeader(message, name);
8083
if (header == null) {
8184
return Collections.emptyList();
8285
}
@@ -87,7 +90,7 @@ public Message getMessage() {
8790
return message;
8891
}
8992

90-
private MNSProcessRequest(Message message, @Nullable String destination) {
93+
private MnsProcessRequest(Message message, @Nullable String destination) {
9194
this.message = message;
9295
this.destination = destination;
9396
}

messaging-wrappers/api/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ tasks {
2626
jvmArgs("-Dotel.metrics.exporter=logging")
2727
jvmArgs("-Dotel.logs.exporter=logging")
2828
}
29-
}
29+
}

messaging-wrappers/api/src/main/java/io/opentelemetry/contrib/messaging/wrappers/DefaultMessagingProcessWrapperBuilder.java

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
16
package io.opentelemetry.contrib.messaging.wrappers;
27

38
import com.google.errorprone.annotations.CanIgnoreReturnValue;
@@ -9,19 +14,16 @@
914
import io.opentelemetry.instrumentation.api.incubator.semconv.messaging.MessageOperation;
1015
import io.opentelemetry.instrumentation.api.incubator.semconv.messaging.MessagingAttributesExtractor;
1116
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
12-
13-
import javax.annotation.Nullable;
1417
import java.util.ArrayList;
1518
import java.util.Collection;
1619
import java.util.List;
20+
import javax.annotation.Nullable;
1721

1822
public class DefaultMessagingProcessWrapperBuilder<REQUEST extends MessagingProcessRequest> {
1923

20-
@Nullable
21-
private OpenTelemetry openTelemetry;
24+
@Nullable private OpenTelemetry openTelemetry;
2225

23-
@Nullable
24-
protected TextMapGetter<REQUEST> textMapGetter;
26+
@Nullable protected TextMapGetter<REQUEST> textMapGetter;
2527

2628
@CanIgnoreReturnValue
2729
public DefaultMessagingProcessWrapperBuilder<REQUEST> openTelemetry(OpenTelemetry openTelemetry) {
@@ -32,15 +34,18 @@ public DefaultMessagingProcessWrapperBuilder<REQUEST> openTelemetry(OpenTelemetr
3234
protected List<AttributesExtractor<REQUEST, Void>> attributesExtractors;
3335

3436
@CanIgnoreReturnValue
35-
public DefaultMessagingProcessWrapperBuilder<REQUEST> textMapGetter(TextMapGetter<REQUEST> textMapGetter) {
37+
public DefaultMessagingProcessWrapperBuilder<REQUEST> textMapGetter(
38+
TextMapGetter<REQUEST> textMapGetter) {
3639
this.textMapGetter = textMapGetter;
3740
return this;
3841
}
3942

4043
/**
4144
* This method overrides the original items.
42-
* <p>See {@link DefaultMessagingProcessWrapperBuilder#addAttributesExtractor} if you just want to append one.</p>
43-
* */
45+
*
46+
* <p>See {@link DefaultMessagingProcessWrapperBuilder#addAttributesExtractor} if you just want to
47+
* append one.
48+
*/
4449
@CanIgnoreReturnValue
4550
public DefaultMessagingProcessWrapperBuilder<REQUEST> attributesExtractors(
4651
Collection<AttributesExtractor<REQUEST, Void>> attributesExtractors) {
@@ -73,7 +78,8 @@ public MessagingProcessWrapper<REQUEST> build() {
7378
protected DefaultMessagingProcessWrapperBuilder() {
7479
// init attributes extractors by default
7580
this.attributesExtractors = new ArrayList<>();
76-
this.attributesExtractors.add(MessagingAttributesExtractor.create(
81+
this.attributesExtractors.add(
82+
MessagingAttributesExtractor.create(
7783
DefaultMessagingAttributesGetter.create(), MessageOperation.PROCESS));
7884
}
7985
}

0 commit comments

Comments
 (0)