Skip to content

Commit 0495ef8

Browse files
authored
Merge pull request #29 from reactivegroup/feature/metrics
feat: log and telemetry api
2 parents 88c073c + 10ab0b9 commit 0495ef8

File tree

41 files changed

+2199
-235
lines changed

Some content is hidden

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

41 files changed

+2199
-235
lines changed

capa-spi-aws-config/pom.xml

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

2929
<artifactId>capa-spi-aws-config</artifactId>
@@ -51,7 +51,6 @@
5151
<artifactId>junit-jupiter-engine</artifactId>
5252
<scope>test</scope>
5353
</dependency>
54-
5554
<!-- power mock -->
5655
<dependency>
5756
<groupId>org.powermock</groupId>

capa-spi-aws-config/src/test/java/group/rxcloud/capa/spi/aws/config/AwsCapaConfigStoreTest.java

Lines changed: 214 additions & 214 deletions
Large diffs are not rendered by default.

capa-spi-aws-infrastructure/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-aws-parent</artifactId>
2525
<groupId>group.rxcloud</groupId>
26-
<version>1.0.4.RELEASE</version>
26+
<version>1.0.5.RELEASE</version>
2727
</parent>
2828

2929
<artifactId>capa-spi-aws-infrastructure</artifactId>

capa-spi-aws-mesh/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
<parent>
2424
<artifactId>capa-aws-parent</artifactId>
2525
<groupId>group.rxcloud</groupId>
26-
<version>1.0.4.RELEASE</version>
26+
<version>1.0.5.RELEASE</version>
2727
</parent>
2828

2929
<artifactId>capa-spi-aws-mesh</artifactId>
3030
<name>capa-skd-spi-aws-appmesh</name>
3131

3232
<properties>
33-
<capa-serializer.version>1.0.2.RELEASE</capa-serializer.version>
33+
<capa-serializer.version>1.0.3.RELEASE</capa-serializer.version>
3434
</properties>
3535

3636
<dependencies>

capa-spi-aws-mesh/src/main/java/group/rxcloud/capa/spi/aws/mesh/http/AwsCapaHttp.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
import java.util.concurrent.CompletableFuture;
4242

4343

44+
/**
45+
* The Aws capa http.
46+
*/
4447
public class AwsCapaHttp extends CapaSerializeHttpSpi {
4548

4649
private static final Logger logger = LoggerFactory.getLogger(AwsCapaHttp.class);
@@ -71,7 +74,8 @@ protected <T> CompletableFuture<HttpResponse<T>> invokeSpiApi(String appId,
7174
method,
7275
requestData,
7376
httpMethod,
74-
headers, urlParameters,
77+
headers,
78+
urlParameters,
7579
type,
7680
(AwsRpcServiceOptions) rpcServiceOptions);
7781
}
@@ -85,7 +89,9 @@ private interface AwsHttpInvoker {
8589
* @param appId the app id
8690
* @param method the method
8791
* @param requestData the request data
92+
* @param httpMethod the http method
8893
* @param headers the headers
94+
* @param urlParameters the url parameters
8995
* @param type the response type
9096
* @param rpcServiceOptions the rpc service options
9197
* @return the async completable future
@@ -154,6 +160,10 @@ private <T> CompletableFuture<HttpResponse<T>> doAsyncInvoke(String method,
154160
String serviceId,
155161
String namespace,
156162
int servicePort) {
163+
serviceId = serviceId.toLowerCase();
164+
namespace = namespace.toLowerCase();
165+
method = method.toLowerCase();
166+
157167
// generate app mesh http url
158168
final String appMeshHttpUrl = AwsCapaRpcProperties.AppMeshProperties.Settings.getRpcAwsAppMeshTemplate()
159169
.replace("{serviceId}", serviceId)

capa-spi-aws-mesh/src/main/java/group/rxcloud/capa/spi/aws/mesh/http/serializer/BaijiSSJsonObjectSerializer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@ public <T> T deserialize(byte[] data, TypeRef<T> type) throws IOException {
6969
*/
7070
@Override
7171
public String getContentType() {
72-
return "application/bjjson";
72+
return SERIALIZER.contentType();
7373
}
7474
}

capa-spi-aws-mesh/src/test/java/group/rxcloud/capa/spi/aws/mesh/http/serializer/AwsCapaSerializerProviderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ public class AwsCapaSerializerProviderTest {
2525
@Test
2626
public void testGetSerializerOrDefault_Success() {
2727
CapaObjectSerializer serializerOrDefault = AwsCapaSerializerProvider.getSerializerOrDefault(null);
28-
Assertions.assertEquals("application/bjjson", serializerOrDefault.getContentType());
28+
Assertions.assertEquals("application/json", serializerOrDefault.getContentType());
2929
}
3030
}

capa-spi-aws-mesh/src/test/java/group/rxcloud/capa/spi/aws/mesh/http/serializer/BaijiSSJsonObjectSerializerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ public void testSerializeAndDeserialize_Success() throws IOException {
4444
@Test
4545
public void testGetContentType_Success() {
4646
String contentType = baijiSSJsonObjectSerializer.getContentType();
47-
Assertions.assertEquals("application/bjjson", contentType);
47+
Assertions.assertEquals("application/json", contentType);
4848
}
4949
}

capa-spi-aws-telemetry/pom.xml

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one or more
4+
contributor license agreements. See the NOTICE file distributed with
5+
this work for additional information regarding copyright ownership.
6+
The ASF licenses this file to You under the Apache License, Version 2.0
7+
(the "License"); you may not use this file except in compliance with
8+
the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
-->
18+
<project xmlns="http://maven.apache.org/POM/4.0.0"
19+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
21+
<modelVersion>4.0.0</modelVersion>
22+
23+
<parent>
24+
<artifactId>capa-aws-parent</artifactId>
25+
<groupId>group.rxcloud</groupId>
26+
<version>1.0.5.RELEASE</version>
27+
</parent>
28+
29+
<artifactId>capa-spi-aws-telemetry</artifactId>
30+
<name>capa-skd-spi-aws-cloudwatch</name>
31+
32+
<properties>
33+
<slf4j.version>1.7.21</slf4j.version>
34+
<log4j.version>2.8.2</log4j.version>
35+
<logback.version>1.1.7</logback.version>
36+
<gson.version>2.8.0</gson.version>
37+
<capa.addons.version>1.0.3.RELEASE</capa.addons.version>
38+
</properties>
39+
40+
<dependencies>
41+
<dependency>
42+
<groupId>group.rxcloud</groupId>
43+
<artifactId>capa-spi-aws-infrastructure</artifactId>
44+
</dependency>
45+
46+
<dependency>
47+
<groupId>group.rxcloud</groupId>
48+
<artifactId>capa-foundation</artifactId>
49+
<version>${capa.addons.version}</version>
50+
</dependency>
51+
<dependency>
52+
<groupId>group.rxcloud</groupId>
53+
<artifactId>capa-id-generator</artifactId>
54+
<version>${capa.addons.version}</version>
55+
</dependency>
56+
57+
<!-- cloud watch logs -->
58+
<dependency>
59+
<groupId>software.amazon.awssdk</groupId>
60+
<artifactId>cloudwatchlogs</artifactId>
61+
</dependency>
62+
<dependency>
63+
<groupId>software.amazon.awssdk</groupId>
64+
<artifactId>cloudwatch</artifactId>
65+
</dependency>
66+
67+
<!-- logback -->
68+
<dependency>
69+
<groupId>ch.qos.logback</groupId>
70+
<artifactId>logback-classic</artifactId>
71+
<version>${logback.version}</version>
72+
<!-- log4j-slf4j-impl and logback-classic cannot exist at the same time. -->
73+
<optional>true</optional>
74+
</dependency>
75+
<dependency>
76+
<groupId>ch.qos.logback</groupId>
77+
<artifactId>logback-core</artifactId>
78+
<version>${logback.version}</version>
79+
<optional>true</optional>
80+
</dependency>
81+
<!--log4j-->
82+
<dependency>
83+
<groupId>org.apache.logging.log4j</groupId>
84+
<artifactId>log4j-core</artifactId>
85+
<version>${log4j.version}</version>
86+
<optional>true</optional>
87+
</dependency>
88+
89+
<dependency>
90+
<groupId>com.google.code.gson</groupId>
91+
<artifactId>gson</artifactId>
92+
<version>${gson.version}</version>
93+
</dependency>
94+
95+
<!-- unit test -->
96+
<dependency>
97+
<groupId>org.junit.jupiter</groupId>
98+
<artifactId>junit-jupiter-engine</artifactId>
99+
<scope>test</scope>
100+
</dependency>
101+
<dependency>
102+
<groupId>org.mockito</groupId>
103+
<artifactId>mockito-core</artifactId>
104+
<scope>test</scope>
105+
</dependency>
106+
</dependencies>
107+
108+
<build>
109+
<plugins>
110+
<!-- With JUnit 5 explicitely needed to let our tests run with Maven & as there seems to be a transitively
111+
added older surefire-plugin, that doesnt support JUnit 5 as described in https://stackoverflow.com/a/49019437/4964553 -->
112+
<plugin>
113+
<groupId>org.apache.maven.plugins</groupId>
114+
<artifactId>maven-surefire-plugin</artifactId>
115+
<version>${maven.surefire.version}</version>
116+
</plugin>
117+
<plugin>
118+
<groupId>org.jacoco</groupId>
119+
<artifactId>jacoco-maven-plugin</artifactId>
120+
<version>${maven.jacoco.version}</version>
121+
<executions>
122+
<!-- Prepares the property pointing to the JaCoCo
123+
runtime agent which is passed as VM argument when Maven the Surefire plugin
124+
is executed. -->
125+
<execution>
126+
<id>pre-unit-test</id>
127+
<goals>
128+
<goal>prepare-agent</goal>
129+
</goals>
130+
</execution>
131+
<!-- Ensures that the code coverage report for
132+
unit tests is created after unit tests have been run. -->
133+
<execution>
134+
<id>post-unit-test</id>
135+
<phase>test</phase>
136+
<goals>
137+
<goal>report</goal>
138+
</goals>
139+
</execution>
140+
</executions>
141+
</plugin>
142+
</plugins>
143+
</build>
144+
145+
</project>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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.spi.aws.telemetry;
18+
19+
20+
import group.rxcloud.capa.infrastructure.CapaProperties;
21+
22+
import java.util.Properties;
23+
24+
public interface AwsCapaTelemetryProperties {
25+
26+
abstract class Settings {
27+
28+
private static String awsTraceId = "";
29+
30+
private static final String TELEMETRY_AWS_TRACE_ID_KEY = "TELEMETRY_AWS_TRACE_ID_KEY";
31+
32+
static {
33+
Properties awsProperties = CapaProperties.COMPONENT_PROPERTIES_SUPPLIER.apply("telemetry-aws");
34+
35+
awsTraceId = awsProperties.getProperty(TELEMETRY_AWS_TRACE_ID_KEY, awsTraceId);
36+
}
37+
38+
public static String getTelemetryAwsTraceIdKey() {
39+
return awsTraceId;
40+
}
41+
42+
private Settings() {
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)