Skip to content

Commit f298d9c

Browse files
committed
refactor: code review and format code style
release: release 1.0.8.RELEASE version
1 parent c986253 commit f298d9c

File tree

29 files changed

+406
-144
lines changed

29 files changed

+406
-144
lines changed

examples/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<parent>
2424
<artifactId>capa-parent</artifactId>
2525
<groupId>group.rxcloud</groupId>
26-
<version>1.0.8-alpha-2</version>
26+
<version>1.0.8.RELEASE</version>
2727
</parent>
2828

2929
<artifactId>capa-examples</artifactId>

pom.xml

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<groupId>group.rxcloud</groupId>
2424
<artifactId>capa-parent</artifactId>
2525
<packaging>pom</packaging>
26-
<version>1.0.8-alpha-2</version>
26+
<version>1.0.8.RELEASE</version>
2727
<name>capa-sdk-parent</name>
2828
<description>SDK for Capa.</description>
2929
<url>https://github.com/reactivegroup</url>
@@ -81,14 +81,17 @@
8181
<java.version>8</java.version>
8282
<file.encoding>UTF-8</file.encoding>
8383
<maven.version>3.8.1</maven.version>
84-
<cloud-runtimes.version>1.0.9.RELEASE</cloud-runtimes.version>
84+
<cloud-runtimes.version>1.0.10.RELEASE</cloud-runtimes.version>
8585
<reactor-core.version>3.3.22.RELEASE</reactor-core.version>
8686
<slf4j.version>1.7.21</slf4j.version>
87+
<grpc.version>1.39.0</grpc.version>
88+
<jackson.version>2.12.4</jackson.version>
8789
<open.telemetry.version>1.9.0</open.telemetry.version>
8890
<open.telemetry.version.alpha>1.9.0-alpha</open.telemetry.version.alpha>
89-
9091
<junit.version>5.3.1</junit.version>
9192
<mockito-core.version>3.6.0</mockito-core.version>
93+
<powermock.version>2.0.2</powermock.version>
94+
9295
<checkstyle.version>3.1.2</checkstyle.version>
9396
<apache.rat.version>0.13</apache.rat.version>
9497
<cobertura.maven.version>2.7</cobertura.maven.version>
@@ -141,7 +144,6 @@
141144
<groupId>io.projectreactor</groupId>
142145
<artifactId>reactor-core</artifactId>
143146
<version>${reactor-core.version}</version>
144-
<optional>true</optional>
145147
</dependency>
146148

147149
<!-- slf4j -->
@@ -151,6 +153,20 @@
151153
<version>${slf4j.version}</version>
152154
</dependency>
153155

156+
<!-- serialize -->
157+
<dependency>
158+
<groupId>com.fasterxml.jackson.core</groupId>
159+
<artifactId>jackson-databind</artifactId>
160+
<version>${jackson.version}</version>
161+
</dependency>
162+
163+
<!-- grpc -->
164+
<dependency>
165+
<groupId>io.grpc</groupId>
166+
<artifactId>grpc-protobuf</artifactId>
167+
<version>${grpc.version}</version>
168+
</dependency>
169+
154170
<!-- open-telemetry-api -->
155171
<dependency>
156172
<groupId>io.opentelemetry</groupId>
@@ -176,6 +192,12 @@
176192
<version>${mockito-core.version}</version>
177193
<scope>test</scope>
178194
</dependency>
195+
<dependency>
196+
<groupId>org.powermock</groupId>
197+
<artifactId>powermock-reflect</artifactId>
198+
<version>${powermock.version}</version>
199+
<scope>test</scope>
200+
</dependency>
179201
</dependencies>
180202
</dependencyManagement>
181203

@@ -352,7 +374,7 @@
352374
<format>html</format>
353375
<format>xml</format>
354376
</formats>
355-
<check />
377+
<check/>
356378
</configuration>
357379
</plugin>
358380
<plugin>

sdk-component/pom.xml

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<parent>
2424
<groupId>group.rxcloud</groupId>
2525
<artifactId>capa-parent</artifactId>
26-
<version>1.0.8-alpha-2</version>
26+
<version>1.0.8.RELEASE</version>
2727
</parent>
2828

2929
<artifactId>capa-sdk-component</artifactId>
@@ -35,10 +35,7 @@
3535
<kotlin-stdlib.version>1.4.10</kotlin-stdlib.version>
3636
<log4j.version>2.14.1</log4j.version>
3737
<logback.version>1.1.7</logback.version>
38-
<guava-version>19.0</guava-version>
39-
<commons-lang3-version>3.11</commons-lang3-version>
40-
<commons-collections-version>3.2.2</commons-collections-version>
41-
</properties>
38+
</properties>
4239

4340
<dependencies>
4441
<!-- sdk module -->
@@ -47,15 +44,16 @@
4744
<artifactId>capa-sdk-infrastructure</artifactId>
4845
</dependency>
4946

47+
<!-- open-telemetry-api -->
5048
<dependency>
5149
<groupId>io.opentelemetry</groupId>
5250
<artifactId>opentelemetry-sdk</artifactId>
53-
<version>1.9.0</version>
51+
<version>${open.telemetry.version}</version>
5452
</dependency>
5553
<dependency>
5654
<groupId>io.opentelemetry</groupId>
5755
<artifactId>opentelemetry-sdk-metrics</artifactId>
58-
<version>1.9.0-alpha</version>
56+
<version>${open.telemetry.version.alpha}</version>
5957
</dependency>
6058

6159
<!-- okhttp -->
@@ -91,23 +89,24 @@
9189
<dependency>
9290
<groupId>org.apache.logging.log4j</groupId>
9391
<artifactId>log4j-core</artifactId>
94-
<optional>true</optional>
9592
<version>${log4j.version}</version>
93+
<optional>true</optional>
9694
</dependency>
9795
<!-- logback -->
9896
<dependency>
9997
<groupId>ch.qos.logback</groupId>
10098
<artifactId>logback-core</artifactId>
101-
<optional>true</optional>
10299
<version>${logback.version}</version>
100+
<optional>true</optional>
103101
</dependency>
104102
<dependency>
105103
<groupId>ch.qos.logback</groupId>
106104
<artifactId>logback-classic</artifactId>
105+
<version>${logback.version}</version>
107106
<!-- log4j-slf4j-impl and logback-classic cannot exist at the same time. -->
108107
<optional>true</optional>
109-
<version>${logback.version}</version>
110108
</dependency>
109+
111110
<dependency>
112111
<groupId>org.junit.jupiter</groupId>
113112
<artifactId>junit-jupiter-engine</artifactId>
@@ -118,21 +117,6 @@
118117
<artifactId>mockito-core</artifactId>
119118
<scope>test</scope>
120119
</dependency>
121-
<dependency>
122-
<groupId>com.google.guava</groupId>
123-
<artifactId>guava</artifactId>
124-
<version>${guava-version}</version>
125-
</dependency>
126-
<dependency>
127-
<groupId>org.apache.commons</groupId>
128-
<artifactId>commons-lang3</artifactId>
129-
<version>${commons-lang3-version}</version>
130-
</dependency>
131-
<dependency>
132-
<groupId>commons-collections</groupId>
133-
<artifactId>commons-collections</artifactId>
134-
<version>${commons-collections-version}</version>
135-
</dependency>
136120
</dependencies>
137121

138122
<build>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package group.rxcloud.capa.component;
18+
19+
import group.rxcloud.capa.infrastructure.CapaProperties;
20+
21+
import java.util.Properties;
22+
23+
/**
24+
* Capa log component common properties.
25+
*/
26+
public interface CapaLogProperties {
27+
28+
abstract class Settings {
29+
30+
private static String centerConfigAppId = "";
31+
32+
private static final String LOG_COMPONENT_CENTER_CONFIG_APPID = "LOG_COMPONENT_CENTER_CONFIG_APPID";
33+
34+
static {
35+
Properties properties = CapaProperties.COMPONENT_PROPERTIES_SUPPLIER.apply("log-common");
36+
37+
centerConfigAppId = properties.getProperty(LOG_COMPONENT_CENTER_CONFIG_APPID, centerConfigAppId);
38+
}
39+
40+
public static String getCenterConfigAppId() {
41+
return centerConfigAppId;
42+
}
43+
44+
private Settings() {
45+
}
46+
}
47+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package group.rxcloud.capa.component;
18+
19+
import group.rxcloud.capa.infrastructure.CapaProperties;
20+
21+
import java.util.Properties;
22+
23+
/**
24+
* Capa telemetry component common properties.
25+
*/
26+
public interface CapaTelemetryProperties {
27+
28+
abstract class Settings {
29+
30+
private static String centerConfigAppId = "";
31+
32+
private static final String TELEMETRY_COMPONENT_CENTER_CONFIG_APPID = "TELEMETRY_COMPONENT_CENTER_CONFIG_APPID";
33+
34+
static {
35+
Properties properties = CapaProperties.COMPONENT_PROPERTIES_SUPPLIER.apply("telemetry-common");
36+
37+
centerConfigAppId = properties.getProperty(TELEMETRY_COMPONENT_CENTER_CONFIG_APPID, centerConfigAppId);
38+
}
39+
40+
public static String getCenterConfigAppId() {
41+
return centerConfigAppId;
42+
}
43+
44+
private Settings() {
45+
}
46+
}
47+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package group.rxcloud.capa.component.configstore;
18+
19+
/**
20+
* Common headers for config store.
21+
*/
22+
public class ConfigHeaders {
23+
24+
public static final String CAPA_CONFIG_EXTENSION = "capa-config-extension";
25+
26+
/**
27+
* Config extension mode.
28+
*/
29+
public enum Extension {
30+
31+
/**
32+
* Multi appId will be merge random.
33+
*/
34+
MERGE("0"),
35+
/**
36+
* The first appId is child config file,
37+
* and will override the other appId.
38+
*/
39+
EXTEND("1"),
40+
;
41+
42+
private final String mode;
43+
44+
Extension(String mode) {
45+
this.mode = mode;
46+
}
47+
48+
public String getMode() {
49+
return mode;
50+
}
51+
}
52+
}

sdk-component/src/main/java/group/rxcloud/capa/component/telemetry/SamplerConfig.java

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
*/
1717
package group.rxcloud.capa.component.telemetry;
1818

19+
import group.rxcloud.capa.component.CapaTelemetryProperties;
1920
import group.rxcloud.capa.component.telemetry.metrics.CapaMeterProviderBuilder;
20-
import group.rxcloud.capa.infrastructure.CapaProperties;
2121
import group.rxcloud.capa.infrastructure.hook.MergedPropertiesConfig;
2222
import group.rxcloud.capa.infrastructure.hook.Mixer;
2323
import org.slf4j.Logger;
@@ -45,46 +45,40 @@ public class SamplerConfig implements Serializable {
4545

4646
private static final transient Logger log = LoggerFactory.getLogger(CapaMeterProviderBuilder.class);
4747

48-
public static transient Supplier<SamplerConfig> DEFAULT_SUPPLIER = () -> {
49-
return CONFIG;
50-
};
48+
public static transient Supplier<SamplerConfig> DEFAULT_SUPPLIER = () -> CONFIG;
5149

5250
static {
5351
Mixer.configurationHooksNullable().ifPresent(hooks -> {
54-
5552
String fileName = "capa-component-telemetry-sample.properties";
56-
57-
String suffix = "telemetry-common";
58-
5953
try {
60-
MergedPropertiesConfig config = new MergedPropertiesConfig(fileName, hooks
61-
.defaultConfigurationAppId(),
62-
CapaProperties.COMPONENT_PROPERTIES_SUPPLIER.apply(suffix).getProperty("appId"));
54+
// TODO: 2021/12/3 Move this to SPI module.
55+
// TODO: 2021/12/3 And use Configuration extension api to get merged file.
56+
MergedPropertiesConfig config = new MergedPropertiesConfig(
57+
fileName,
58+
hooks.defaultConfigurationAppId(),
59+
CapaTelemetryProperties.Settings.getCenterConfigAppId());
6360
String metricKey = "metricsEnable";
6461
String traceKey = "traceEnable";
6562
SamplerConfig dynamicConfig = new SamplerConfig() {
6663
@Override
6764
public Boolean isMetricsEnable() {
6865
return !config.containsKey(metricKey) || Boolean.TRUE.toString()
69-
.equalsIgnoreCase(config.get(metricKey));
66+
.equalsIgnoreCase(config.get(metricKey));
7067
}
7168

7269
@Override
7370
public Boolean isTraceEnable() {
7471
return !config.containsKey(traceKey) || Boolean.TRUE.toString()
75-
.equalsIgnoreCase(config.get(traceKey));
72+
.equalsIgnoreCase(config.get(traceKey));
7673
}
7774
};
7875

79-
DEFAULT_SUPPLIER = () -> {
80-
return dynamicConfig;
81-
};
76+
DEFAULT_SUPPLIER = () -> dynamicConfig;
8277
} catch (Throwable throwable) {
8378
log.warn("Fail to load global telemetry config. Dynamic global config is disabled for capa telemetry.",
8479
throwable);
8580
}
8681
});
87-
8882
}
8983

9084
private Boolean metricsEnable;

0 commit comments

Comments
 (0)