Skip to content

Commit

Permalink
Merge pull request #58 from reactivegroup/feature/metrics
Browse files Browse the repository at this point in the history
feat: Telemetry API

+ refactor: optimize code
  • Loading branch information
kevinten10 authored Dec 2, 2021
2 parents 8a25788 + f298d9c commit f5f3481
Show file tree
Hide file tree
Showing 86 changed files with 2,201 additions and 362 deletions.
6 changes: 3 additions & 3 deletions examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
<parent>
<artifactId>capa-parent</artifactId>
<groupId>group.rxcloud</groupId>
<version>1.0.7.RELEASE</version>
<version>1.0.8.RELEASE</version>
</parent>

<artifactId>capa-examples</artifactId>
<packaging>jar</packaging>
<name>capa-sdk-examples</name>

<properties>
<log4j.version>2.8.2</log4j.version>
<log4j.version>2.14.1</log4j.version>
<logback.version>1.1.7</logback.version>
<slf4j-api.version>1.7.32</slf4j-api.version>
</properties>
Expand Down Expand Up @@ -67,7 +67,7 @@
<version>${log4j.version}</version>
</dependency>
<!-- logback -->
<!-- <dependency>
<!--<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
public class DemoLog {

public static void main(String[] args) {
log.info("test");
try {
log.info("test");
}catch (Exception e){
System.out.println();
}

}
}
12 changes: 1 addition & 11 deletions examples/src/main/resources/xml/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,9 @@
-->
<configuration>
<!--Log-->
<appender name="Log" class="group.rxcloud.capa.component.log.agent.CapaLogbackAppenderAgent">
<appender name="Log" class="group.rxcloud.capa.component.log.CapaLogbackAppenderAgent">
</appender>

<logger name="com.ctrip.ibu.market.e2c" level="INFO" additivity="false">
<!-- <appender-ref ref="STDOUT"/>-->
<appender-ref ref="Log"/>
</logger>

<logger name="com.ctrip.ibu.telescope.mock.support" level="INFO" additivity="false">
<!-- <appender-ref ref="STDOUT"/>-->
<appender-ref ref="Log"/>
</logger>

<root level="INFO">
<appender-ref ref="Log"/>
</root>
Expand Down
37 changes: 31 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<groupId>group.rxcloud</groupId>
<artifactId>capa-parent</artifactId>
<packaging>pom</packaging>
<version>1.0.7.RELEASE</version>
<version>1.0.8.RELEASE</version>
<name>capa-sdk-parent</name>
<description>SDK for Capa.</description>
<url>https://github.com/reactivegroup</url>
Expand All @@ -44,6 +44,10 @@
<name>reckless11</name>
<email>reckless0511@gmail.com</email>
</developer>
<developer>
<name>dgzpg</name>
<email>1711145024@qq.com</email>
</developer>
</developers>

<scm>
Expand Down Expand Up @@ -77,14 +81,17 @@
<java.version>8</java.version>
<file.encoding>UTF-8</file.encoding>
<maven.version>3.8.1</maven.version>
<cloud-runtimes.version>1.0.9.RELEASE</cloud-runtimes.version>
<cloud-runtimes.version>1.0.10.RELEASE</cloud-runtimes.version>
<reactor-core.version>3.3.22.RELEASE</reactor-core.version>
<slf4j.version>1.7.21</slf4j.version>
<grpc.version>1.39.0</grpc.version>
<jackson.version>2.12.4</jackson.version>
<open.telemetry.version>1.9.0</open.telemetry.version>
<open.telemetry.version.alpha>1.9.0-alpha</open.telemetry.version.alpha>

<junit.version>5.3.1</junit.version>
<mockito-core.version>3.6.0</mockito-core.version>
<powermock.version>2.0.2</powermock.version>

<checkstyle.version>3.1.2</checkstyle.version>
<apache.rat.version>0.13</apache.rat.version>
<cobertura.maven.version>2.7</cobertura.maven.version>
Expand Down Expand Up @@ -137,7 +144,6 @@
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>${reactor-core.version}</version>
<optional>true</optional>
</dependency>

<!-- slf4j -->
Expand All @@ -147,6 +153,20 @@
<version>${slf4j.version}</version>
</dependency>

<!-- serialize -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>

<!-- grpc -->
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>${grpc.version}</version>
</dependency>

<!-- open-telemetry-api -->
<dependency>
<groupId>io.opentelemetry</groupId>
Expand All @@ -172,6 +192,12 @@
<version>${mockito-core.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-reflect</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -348,7 +374,7 @@
<format>html</format>
<format>xml</format>
</formats>
<check />
<check/>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -414,5 +440,4 @@
</plugin>
</plugins>
</build>

</project>
20 changes: 14 additions & 6 deletions sdk-component/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>group.rxcloud</groupId>
<artifactId>capa-parent</artifactId>
<version>1.0.7.RELEASE</version>
<version>1.0.8.RELEASE</version>
</parent>

<artifactId>capa-sdk-component</artifactId>
Expand All @@ -33,9 +33,9 @@
<properties>
<okhttp.version>4.9.1</okhttp.version>
<kotlin-stdlib.version>1.4.10</kotlin-stdlib.version>
<log4j.version>2.8.2</log4j.version>
<log4j.version>2.14.1</log4j.version>
<logback.version>1.1.7</logback.version>
</properties>
</properties>

<dependencies>
<!-- sdk module -->
Expand All @@ -44,15 +44,16 @@
<artifactId>capa-sdk-infrastructure</artifactId>
</dependency>

<!-- open-telemetry-api -->
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk</artifactId>
<version>1.9.0</version>
<version>${open.telemetry.version}</version>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk-metrics</artifactId>
<version>1.9.0-alpha</version>
<version>${open.telemetry.version.alpha}</version>
</dependency>

<!-- okhttp -->
Expand Down Expand Up @@ -88,15 +89,22 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<optional>true</optional>
<version>${log4j.version}</version>
<optional>true</optional>
</dependency>
<!-- logback -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
<!-- log4j-slf4j-impl and logback-classic cannot exist at the same time. -->
<optional>true</optional>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package group.rxcloud.capa.component;

import group.rxcloud.capa.infrastructure.CapaProperties;

import java.util.Properties;

/**
* Capa log component common properties.
*/
public interface CapaLogProperties {

abstract class Settings {

private static String centerConfigAppId = "";

private static final String LOG_COMPONENT_CENTER_CONFIG_APPID = "LOG_COMPONENT_CENTER_CONFIG_APPID";

static {
Properties properties = CapaProperties.COMPONENT_PROPERTIES_SUPPLIER.apply("log-common");

centerConfigAppId = properties.getProperty(LOG_COMPONENT_CENTER_CONFIG_APPID, centerConfigAppId);
}

public static String getCenterConfigAppId() {
return centerConfigAppId;
}

private Settings() {
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package group.rxcloud.capa.component;

import group.rxcloud.capa.infrastructure.CapaProperties;

import java.util.Properties;

/**
* Capa telemetry component common properties.
*/
public interface CapaTelemetryProperties {

abstract class Settings {

private static String centerConfigAppId = "";

private static final String TELEMETRY_COMPONENT_CENTER_CONFIG_APPID = "TELEMETRY_COMPONENT_CENTER_CONFIG_APPID";

static {
Properties properties = CapaProperties.COMPONENT_PROPERTIES_SUPPLIER.apply("telemetry-common");

centerConfigAppId = properties.getProperty(TELEMETRY_COMPONENT_CENTER_CONFIG_APPID, centerConfigAppId);
}

public static String getCenterConfigAppId() {
return centerConfigAppId;
}

private Settings() {
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package group.rxcloud.capa.component.configstore;

/**
* Common headers for config store.
*/
public class ConfigHeaders {

public static final String CAPA_CONFIG_EXTENSION = "capa-config-extension";

/**
* Config extension mode.
*/
public enum Extension {

/**
* Multi appId will be merge random.
*/
MERGE("0"),
/**
* The first appId is child config file,
* and will override the other appId.
*/
EXTEND("1"),
;

private final String mode;

Extension(String mode) {
this.mode = mode;
}

public String getMode() {
return mode;
}
}
}
Loading

0 comments on commit f5f3481

Please sign in to comment.