Skip to content

Commit

Permalink
[pinpoint-apm#9603] Add uri stat modules
Browse files Browse the repository at this point in the history
  • Loading branch information
ga-ram committed Jan 5, 2023
1 parent 6f2d1cb commit 076ed62
Show file tree
Hide file tree
Showing 44 changed files with 395 additions and 78 deletions.
4 changes: 4 additions & 0 deletions metric-module/collector-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
<groupId>com.navercorp.pinpoint</groupId>
<artifactId>pinpoint-metric</artifactId>
</dependency>
<dependency>
<groupId>com.navercorp.pinpoint</groupId>
<artifactId>pinpoint-uristat-collector</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConfiguration;
import org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportResource;

@SpringBootConfiguration
@EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class, TransactionAutoConfiguration.class, SqlInitializationAutoConfiguration.class})
@ImportResource({"classpath:applicationContext-collector.xml", "classpath:servlet-context-collector.xml"})
@Import({CollectorAppPropertySources.class, FlinkContextConfiguration.class})
@ComponentScan({"com.navercorp.pinpoint.uristat.collector.service", })
public class BasicCollectorApp {
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.navercorp.pinpoint.metric.collector.CollectorTypeParser;
import com.navercorp.pinpoint.metric.collector.MetricCollectorApp;
import com.navercorp.pinpoint.metric.collector.TypeSet;
import com.navercorp.pinpoint.uristat.collector.UriStatCollectorConfig;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.WebApplicationType;
Expand Down Expand Up @@ -43,20 +44,20 @@ public static void main(String[] args) {

if (types.hasType(CollectorType.BASIC)) {
logger.info(String.format("Start %s collector", CollectorType.BASIC));
SpringApplicationBuilder collectorAppBuilder = createAppBuilder(builder, BasicCollectorApp.class, 15400);
SpringApplicationBuilder collectorAppBuilder = createAppBuilder(builder, 15400, BasicCollectorApp.class, UriStatCollectorConfig.class);
collectorAppBuilder.build().run(args);
}

if (types.hasType(CollectorType.METRIC)) {
logger.info(String.format("Start %s collector", CollectorType.METRIC));
SpringApplicationBuilder metricAppBuilder = createAppBuilder(builder, MetricCollectorApp.class, 15200);
SpringApplicationBuilder metricAppBuilder = createAppBuilder(builder, 15200, MetricCollectorApp.class);
metricAppBuilder.listeners(new AdditionalProfileListener("metric"));
metricAppBuilder.build().run(args);
}
}


private static SpringApplicationBuilder createAppBuilder(SpringApplicationBuilder builder, Class<?> appClass, int port) {
private static SpringApplicationBuilder createAppBuilder(SpringApplicationBuilder builder, int port, Class<?>... appClass) {
SpringApplicationBuilder appBuilder = builder.child(appClass)
.web(WebApplicationType.SERVLET)
.bannerMode(Banner.Mode.OFF)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@ public long estimateLimit() {
return (range.getRange() / timePrecision.getInterval() + 1) * TAG_SET_COUNT;
}

public Range getRange() {
return this.range;
}

public TimePrecision getTimePrecision() {
return this.timePrecision;
}

public long getLimit() {
return this.limit;
}

abstract public QueryParameter build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,4 @@
<constructor-arg index="0" ref="kafkaProducerFactory"/>
</bean>

<bean id="kafkaUriStatTemplate" class="org.springframework.kafka.core.KafkaTemplate">
<constructor-arg index="0" ref="kafkaProducerFactory"/>
</bean>

</beans>
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
kafka.double.topic=system-metric-double
kafka.metadata.tag.topic=system-metric-tag
kafka.metadata.data.type.topic=system-metric-data-type
kafka.uri.topic=url-stat
kafka.metadata.data.type.topic=system-metric-data-type
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@
<typeAlias type="com.navercorp.pinpoint.metric.common.model.MetricDataName" alias="MetricDataName"/>
<typeAlias type="com.navercorp.pinpoint.metric.common.model.MetricDataType" alias="MetricDataType"/>
<typeAlias type="com.navercorp.pinpoint.metric.common.model.mybatis.MetricDataTypeHandler" alias="MetricDataTypeHandler"/>

<typeAlias type="com.navercorp.pinpoint.metric.common.model.UriStat" alias="UriStat" />
<typeAlias type="com.navercorp.pinpoint.metric.web.model.UriStatSummary" alias="UriStatSummary" />
<typeAlias type="com.navercorp.pinpoint.metric.web.util.UriStatQueryParameter" alias="UriStatQueryParameter" />

</typeAliases>

<typeHandlers>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
config.show.systemMetric=true
config.show.urlStat=true
config.show.systemMetric=true
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
config.show.systemMetric=true
config.show.urlStat=true
config.show.systemMetric=true
4 changes: 4 additions & 0 deletions metric-module/web-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.navercorp.pinpoint</groupId>
<artifactId>pinpoint-uristat-web</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.navercorp.pinpoint.common.server.util.ServerBootLogger;
import com.navercorp.pinpoint.metric.web.MetricWebApp;
import com.navercorp.pinpoint.uristat.web.UriStatWebConfig;
import com.navercorp.pinpoint.web.PinpointBasicLoginConfig;
import com.navercorp.pinpoint.web.WebApp;
import com.navercorp.pinpoint.web.WebAppPropertySources;
Expand Down Expand Up @@ -46,7 +47,7 @@ public class MetricAndWebApp {

public static void main(String[] args) {
try {
WebStarter starter = new WebStarter(MetricAndWebApp.class, PinpointBasicLoginConfig.class, AuthorizationConfig.class, MetricWebApp.class);
WebStarter starter = new WebStarter(MetricAndWebApp.class, PinpointBasicLoginConfig.class, AuthorizationConfig.class, MetricWebApp.class, UriStatWebConfig.class);
starter.start(args);
} catch (Exception exception) {
logger.error("[WebApp] could not launch app.", exception);
Expand Down
18 changes: 18 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@

<module>hbase2-module</module>
<module>metric-module</module>
<module>uristat-common</module>
<module>uristat-web</module>
<module>uristat-collector</module>

<!-- <module>agent-testweb</module> -->
<!-- <module>plugins-it</module> -->
Expand Down Expand Up @@ -411,6 +414,21 @@
<artifactId>pinpoint-web</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.navercorp.pinpoint</groupId>
<artifactId>pinpoint-uristat-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.navercorp.pinpoint</groupId>
<artifactId>pinpoint-uristat-web</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.navercorp.pinpoint</groupId>
<artifactId>pinpoint-uristat-collector</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.navercorp.pinpoint</groupId>
<artifactId>pinpoint-metric</artifactId>
Expand Down
42 changes: 42 additions & 0 deletions uristat-collector/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>pinpoint</artifactId>
<groupId>com.navercorp.pinpoint</groupId>
<version>2.5.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>pinpoint-uristat-collector</artifactId>

<properties>
<jdk.version>11</jdk.version>
<jdk.home>${env.JAVA_11_HOME}</jdk.home>
</properties>

<dependencies>
<dependency>
<groupId>com.navercorp.pinpoint</groupId>
<artifactId>pinpoint-uristat-common</artifactId>
</dependency>
<dependency>
<groupId>com.navercorp.pinpoint</groupId>
<artifactId>pinpoint-metric</artifactId>
</dependency>
<dependency>
<groupId>com.navercorp.pinpoint</groupId>
<artifactId>pinpoint-commons-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
<version>2.9.4</version>
</dependency>
<dependency>
<groupId>com.navercorp.pinpoint</groupId>
<artifactId>pinpoint-collector</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.navercorp.pinpoint.uristat.collector;


import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.PropertySource;

@Profile("metric")
@ComponentScan({"com.navercorp.pinpoint.uristat.collector.service", "com.navercorp.pinpoint.uristat.collector.dao"})
@PropertySource({"classpath:kafka-topic.properties", "classpath:kafka-producer-factory.properties"})
@ImportResource({"classpath*:**/applicationContext-collector-metric-namespace.xml", "classpath:applicationContext-collector-pinot-kafka.xml"})
public class UriStatCollectorConfig {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.navercorp.pinpoint.uristat.collector;

public class UriStatCollectorPropertySources {
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.navercorp.pinpoint.metric.collector.dao.pinot;
package com.navercorp.pinpoint.uristat.collector.dao;

import com.navercorp.pinpoint.metric.collector.dao.UriStatDao;
import com.navercorp.pinpoint.metric.common.model.StringPrecondition;
import com.navercorp.pinpoint.metric.common.model.UriStat;
import com.navercorp.pinpoint.uristat.common.util.StringPrecondition;
import com.navercorp.pinpoint.uristat.common.model.UriStat;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Repository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.navercorp.pinpoint.metric.collector.dao;
package com.navercorp.pinpoint.uristat.collector.dao;

import com.navercorp.pinpoint.metric.common.model.UriStat;
import com.navercorp.pinpoint.uristat.common.model.UriStat;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@
* limitations under the License.
*/

package com.navercorp.pinpoint.collector.service;
package com.navercorp.pinpoint.uristat.collector.service;

import com.navercorp.pinpoint.collector.service.AgentUriStatService;
import com.navercorp.pinpoint.common.server.bo.stat.AgentUriStatBo;
import com.navercorp.pinpoint.common.server.bo.stat.EachUriStatBo;
import com.navercorp.pinpoint.common.server.bo.stat.UriStatHistogram;
import com.navercorp.pinpoint.common.server.tenant.TenantProvider;
import com.navercorp.pinpoint.metric.collector.MetricAppPropertySources;
import com.navercorp.pinpoint.metric.collector.dao.UriStatDao;
import com.navercorp.pinpoint.metric.common.model.UriStat;
//import com.navercorp.pinpoint.metric.collector.MetricAppPropertySources;
import com.navercorp.pinpoint.uristat.collector.dao.UriStatDao;
import com.navercorp.pinpoint.uristat.common.model.UriStat;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportResource;
Expand All @@ -32,15 +34,12 @@
import java.util.Objects;

@Service
@ComponentScan("com.navercorp.pinpoint.metric.collector.dao.pinot")
@ImportResource({"classpath:pinot-collector/applicationContext-collector-pinot.xml", "classpath:pinot-collector/servlet-context-collector-pinot.xml"})
@Import({MetricAppPropertySources.class})
//@Import({MetricAppPropertySources.class})
public class PinotAgentUriStatService implements AgentUriStatService {

private final int BUCKET_SIZE = 8;
private final int[] EMPTY_BUCKETS = new int[BUCKET_SIZE];
private final UriStatDao uriStatDao;

private final TenantProvider tenantProvider;

public PinotAgentUriStatService(UriStatDao uriStatDao, TenantProvider tenantProvider) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd">

<util:map id="kafkaProducerFactoryProperties" key-type="java.lang.String" value-type="java.lang.String">
<entry key="bootstrap.servers" value="${pinpoint.metric.kafka.bootstrap.servers}"/>
<entry key="key.serializer" value="${pinpoint.metric.kafka.key.serializer}"/>
<entry key="value.serializer" value="${pinpoint.metric.kafka.value.serializer}"/>
<entry key="partitioner.class" value="org.apache.kafka.clients.producer.internals.DefaultPartitioner"/>
<entry key="acks" value="${pinpoint.metric.kafka.acks}"/>
<entry key="compression.type" value="zstd"/>
</util:map>

<bean id="kafkaProducerFactory" class="org.springframework.kafka.core.DefaultKafkaProducerFactory">
<constructor-arg index="0" ref="kafkaProducerFactoryProperties" />
</bean>

<bean id="kafkaUriStatTemplate" class="org.springframework.kafka.core.KafkaTemplate">
<constructor-arg index="0" ref="kafkaProducerFactory"/>
</bean>

</beans>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pinpoint.metric.kafka.bootstrap.servers=
pinpoint.metric.kafka.key.serializer=org.apache.kafka.common.serialization.StringSerializer
pinpoint.metric.kafka.value.serializer=org.springframework.kafka.support.serializer.JsonSerializer
pinpoint.metric.kafka.acks=1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kafka.uri.topic=url-stat
37 changes: 37 additions & 0 deletions uristat-common/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>pinpoint</artifactId>
<groupId>com.navercorp.pinpoint</groupId>
<version>2.5.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>pinpoint-uristat-common</artifactId>

<properties>
<jdk.version>11</jdk.version>
<jdk.home>${env.JAVA_11_HOME}</jdk.home>
</properties>

<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

</project>
Loading

0 comments on commit 076ed62

Please sign in to comment.