-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f00f184
commit 67c83ac
Showing
75 changed files
with
4,082 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
commons/src/main/java/com/navercorp/pinpoint/common/util/ObjectUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright 2023 NAVER Corp. | ||
* | ||
* Licensed 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 com.navercorp.pinpoint.common.util; | ||
|
||
/** | ||
* @author minwoo.jung | ||
*/ | ||
public class ObjectUtils { | ||
|
||
public static <T> T defaultIfNull(T object, T defaultValue) { | ||
return object != null ? object : defaultValue; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?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-inspector-module</artifactId> | ||
<groupId>com.navercorp.pinpoint</groupId> | ||
<version>2.6.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>pinpoint-inspector-collector</artifactId> | ||
<name>pinpoint-inspector-collector</name> | ||
|
||
<properties> | ||
<jdk.version>11</jdk.version> | ||
<jdk.home>${env.JAVA_11_HOME}</jdk.home> | ||
</properties> | ||
|
||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.navercorp.pinpoint</groupId> | ||
<artifactId>pinpoint-collector</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<!-- todo : (minwoo) It is necessary to think about removing the dependency on the metric side. --> | ||
<dependency> | ||
<groupId>com.navercorp.pinpoint</groupId> | ||
<artifactId>pinpoint-metric</artifactId> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>*</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.navercorp.pinpoint</groupId> | ||
<artifactId>pinpoint-pinot-kafka</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
39 changes: 39 additions & 0 deletions
39
...ector/src/main/java/com/navercorp/pinpoint/inspector/collector/InspectorCollectorApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2023 NAVER Corp. | ||
* | ||
* Licensed 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 com.navercorp.pinpoint.inspector.collector; | ||
|
||
import com.navercorp.pinpoint.inspector.collector.config.InspectorKafkaConfiguration; | ||
import com.navercorp.pinpoint.inspector.collector.config.InspectorPropertySources; | ||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration; | ||
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; | ||
import org.springframework.context.annotation.PropertySource; | ||
|
||
/** | ||
* @author minwoo.jung | ||
*/ | ||
@ComponentScan({"com.navercorp.pinpoint.inspector.collector"}) | ||
@EnableAutoConfiguration(exclude = {KafkaAutoConfiguration.class}) | ||
@Import({ | ||
InspectorPropertySources.class, | ||
InspectorKafkaConfiguration.class}) | ||
public class InspectorCollectorApp { | ||
} |
39 changes: 39 additions & 0 deletions
39
...n/java/com/navercorp/pinpoint/inspector/collector/config/InspectorKafkaConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2023 NAVER Corp. | ||
* | ||
* Licensed 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 com.navercorp.pinpoint.inspector.collector.config; | ||
|
||
import com.navercorp.pinpoint.inspector.collector.model.kafka.AgentStat; | ||
import com.navercorp.pinpoint.pinot.kafka.KafkaConfiguration; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.kafka.core.KafkaTemplate; | ||
import org.springframework.kafka.core.ProducerFactory; | ||
|
||
/** | ||
* @author minwoo.jung | ||
*/ | ||
@Configuration | ||
@Import({KafkaConfiguration.class}) | ||
public class InspectorKafkaConfiguration { | ||
|
||
@Bean | ||
public KafkaTemplate<String, AgentStat> kafkaAgentStatTemplate(@Qualifier("kafkaProducerFactory") ProducerFactory producerFactory) { | ||
return new KafkaTemplate<>(producerFactory); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...main/java/com/navercorp/pinpoint/inspector/collector/config/InspectorPropertySources.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright 2023 NAVER Corp. | ||
* | ||
* Licensed 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 com.navercorp.pinpoint.inspector.collector.config; | ||
|
||
import org.springframework.context.annotation.PropertySource; | ||
import org.springframework.context.annotation.PropertySources; | ||
|
||
/** | ||
* @author minwoo.jung | ||
*/ | ||
|
||
@PropertySources({ | ||
@PropertySource(name = "InspectorPropertySources-KAFKA", value = { InspectorPropertySources.KAFKA_TOPIC}), | ||
}) | ||
public class InspectorPropertySources { | ||
public static final String KAFKA_TOPIC = "classpath:inspector/collector/kafka-topic.properties"; | ||
} |
33 changes: 33 additions & 0 deletions
33
...-collector/src/main/java/com/navercorp/pinpoint/inspector/collector/dao/AgentStatDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2023 NAVER Corp. | ||
* | ||
* Licensed 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 com.navercorp.pinpoint.inspector.collector.dao; | ||
|
||
import com.navercorp.pinpoint.common.server.bo.stat.AgentStatBo; | ||
import com.navercorp.pinpoint.common.server.bo.stat.AgentStatDataPoint; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author minwoo.jung | ||
*/ | ||
@Repository | ||
public interface AgentStatDao<T extends AgentStatDataPoint> { | ||
void insert(String agentId, List<T> agentStatDataPoints); | ||
|
||
void dispatch(AgentStatBo agentStatBo); | ||
} |
80 changes: 80 additions & 0 deletions
80
...c/main/java/com/navercorp/pinpoint/inspector/collector/dao/pinot/DefaultAgentStatDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright 2023 NAVER Corp. | ||
* | ||
* Licensed 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 com.navercorp.pinpoint.inspector.collector.dao.pinot; | ||
|
||
import com.navercorp.pinpoint.common.server.bo.stat.AgentStatBo; | ||
import com.navercorp.pinpoint.common.server.bo.stat.AgentStatDataPoint; | ||
import com.navercorp.pinpoint.inspector.collector.dao.AgentStatDao; | ||
import com.navercorp.pinpoint.inspector.collector.model.kafka.AgentStat; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.springframework.kafka.core.KafkaTemplate; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.function.Function; | ||
|
||
/** | ||
* @author minwoo.jung | ||
*/ | ||
public class DefaultAgentStatDao <T extends AgentStatDataPoint> implements AgentStatDao<T> { | ||
|
||
private final Logger logger = LogManager.getLogger(DefaultAgentStatDao.class.getName()); | ||
|
||
private final Function<AgentStatBo, List<T>> dataPointFunction; | ||
private final Function<List<T>, List<AgentStat>> convertToKafkaModelFunction; | ||
private final KafkaTemplate kafkaAgentStatTemplate; | ||
private final String topic; | ||
|
||
public DefaultAgentStatDao(Function<AgentStatBo, List<T>> dataPointFunction, KafkaTemplate kafkaAgentStatTemplate, Function<List<T>, List<AgentStat>> convertToKafkaModelFunction, String topic) { | ||
this.dataPointFunction = Objects.requireNonNull(dataPointFunction, "dataPointFunction"); | ||
this.kafkaAgentStatTemplate = Objects.requireNonNull(kafkaAgentStatTemplate, "kafkaAgentStatTemplate"); | ||
this.convertToKafkaModelFunction = convertToKafkaModelFunction; | ||
this.topic = topic; | ||
} | ||
|
||
@Override | ||
public void insert(String agentId, List<T> agentStatData) { | ||
List<AgentStat> agentStatList = convertDataToKafkaModel(agentStatData); | ||
for (AgentStat agentStat : agentStatList) { | ||
String kafkaKey = generateKafkaKey(agentStat); | ||
kafkaAgentStatTemplate.send(topic, kafkaKey, agentStat); | ||
} | ||
} | ||
|
||
private List<AgentStat> convertDataToKafkaModel(List<T> AgentStatDataPointList) { | ||
List<AgentStat> agentStatList = convertToKafkaModelFunction.apply(AgentStatDataPointList); | ||
return agentStatList; | ||
} | ||
|
||
@Override | ||
public void dispatch(AgentStatBo agentStatBo) { | ||
Objects.requireNonNull(agentStatBo, "agentStatBo"); | ||
List<T> dataPointList = this.dataPointFunction.apply(agentStatBo); | ||
insert(agentStatBo.getAgentId(), dataPointList); | ||
} | ||
|
||
private String generateKafkaKey(AgentStat agentStat) { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append(agentStat.getApplicationName()); | ||
sb.append("_"); | ||
sb.append(agentStat.getAgentId()); | ||
sb.append("_"); | ||
sb.append(agentStat.getMetricName()); | ||
return sb.toString(); | ||
} | ||
} |
Oops, something went wrong.