-
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
Showing
49 changed files
with
3,052 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?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-exceptiontrace-module</artifactId> | ||
<groupId>com.navercorp.pinpoint</groupId> | ||
<version>2.6.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>pinpoint-exceptiontrace-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-pinot-kafka</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.navercorp.pinpoint</groupId> | ||
<artifactId>pinpoint-exceptiontrace-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>${spring.kafka.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.navercorp.pinpoint</groupId> | ||
<artifactId>pinpoint-collector</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
37 changes: 37 additions & 0 deletions
37
...n/java/com/navercorp/pinpoint/exceptiontrace/collector/ExceptionTraceCollectorConfig.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,37 @@ | ||
/* | ||
* 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.exceptiontrace.collector; | ||
|
||
import com.navercorp.pinpoint.exceptiontrace.collector.config.ExceptionMetricKafkaConfiguration; | ||
import com.navercorp.pinpoint.pinot.config.PinotConfiguration; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.context.annotation.PropertySource; | ||
|
||
/** | ||
* @author intr3p1d | ||
*/ | ||
@Profile("exception") | ||
@Configuration | ||
@Import({PinotConfiguration.class, ExceptionMetricKafkaConfiguration.class}) | ||
@ComponentScan({"com.navercorp.pinpoint.exceptiontrace.collector.service", "com.navercorp.pinpoint.exceptiontrace.collector.dao"}) | ||
@PropertySource({ExceptionTraceCollectorConfig.KAFKA_TOPIC_PROPERTIES}) | ||
public class ExceptionTraceCollectorConfig { | ||
public static final String KAFKA_TOPIC_PROPERTIES = "classpath:profiles/${pinpoint.profiles.active}/kafka-topic-exception.properties"; | ||
} |
23 changes: 23 additions & 0 deletions
23
...m/navercorp/pinpoint/exceptiontrace/collector/ExceptionTraceCollectorPropertySources.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,23 @@ | ||
/* | ||
* 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.exceptiontrace.collector; | ||
|
||
/** | ||
* @author intr3p1d | ||
*/ | ||
public class ExceptionTraceCollectorPropertySources { | ||
} |
40 changes: 40 additions & 0 deletions
40
...navercorp/pinpoint/exceptiontrace/collector/config/ExceptionMetricKafkaConfiguration.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,40 @@ | ||
/* | ||
* 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.exceptiontrace.collector.config; | ||
|
||
import com.navercorp.pinpoint.exceptiontrace.collector.model.ExceptionMetaDataVo; | ||
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 intr3p1d | ||
*/ | ||
@Configuration | ||
@Import({KafkaConfiguration.class}) | ||
public class ExceptionMetricKafkaConfiguration { | ||
|
||
@Bean | ||
public KafkaTemplate<String, ExceptionMetaDataVo> kafkaExceptionMetaDataTemplate( | ||
@Qualifier("kafkaProducerFactory") ProducerFactory producerFactory | ||
) { | ||
return new KafkaTemplate<String, ExceptionMetaDataVo>(producerFactory); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
.../src/main/java/com/navercorp/pinpoint/exceptiontrace/collector/dao/ExceptionTraceDao.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,28 @@ | ||
/* | ||
* 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.exceptiontrace.collector.dao; | ||
|
||
import com.navercorp.pinpoint.exceptiontrace.common.model.ExceptionMetaData; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author intr3p1d | ||
*/ | ||
public interface ExceptionTraceDao { | ||
void insert(List<ExceptionMetaData> exceptionMetaData); | ||
} |
71 changes: 71 additions & 0 deletions
71
...main/java/com/navercorp/pinpoint/exceptiontrace/collector/dao/PinotExceptionTraceDao.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,71 @@ | ||
/* | ||
* 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.exceptiontrace.collector.dao; | ||
|
||
import com.navercorp.pinpoint.exceptiontrace.collector.model.ExceptionMetaDataVo; | ||
import com.navercorp.pinpoint.exceptiontrace.common.model.ExceptionMetaData; | ||
import com.navercorp.pinpoint.exceptiontrace.common.util.StringPrecondition; | ||
import com.navercorp.pinpoint.pinot.kafka.util.KafkaCallbacks; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.kafka.core.KafkaTemplate; | ||
import org.springframework.kafka.support.SendResult; | ||
import org.springframework.stereotype.Repository; | ||
import org.springframework.util.concurrent.ListenableFuture; | ||
import org.springframework.util.concurrent.ListenableFutureCallback; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
/** | ||
* @author intr3p1d | ||
*/ | ||
@Repository | ||
public class PinotExceptionTraceDao implements ExceptionTraceDao { | ||
private final Logger logger = LogManager.getLogger(this.getClass()); | ||
|
||
private final KafkaTemplate<String, ExceptionMetaDataVo> kafkaExceptionMetaDataTemplate; | ||
|
||
private final String topic; | ||
|
||
private final ListenableFutureCallback<SendResult<String, ExceptionMetaDataVo>> resultCallback | ||
= KafkaCallbacks.loggingCallback("Kafka(ExceptionMetaDataVo)", logger); | ||
|
||
|
||
public PinotExceptionTraceDao( | ||
@Qualifier("kafkaExceptionMetaDataTemplate") KafkaTemplate<String, ExceptionMetaDataVo> kafkaExceptionMetaDataTemplate, | ||
@Value("${kafka.exception.topic}") String topic | ||
) { | ||
this.kafkaExceptionMetaDataTemplate = Objects.requireNonNull(kafkaExceptionMetaDataTemplate, "kafkaExceptionMetaDataTemplate"); | ||
this.topic = StringPrecondition.requireHasLength(topic, "topic"); | ||
} | ||
|
||
@Override | ||
public void insert(List<ExceptionMetaData> exceptionMetaData) { | ||
Objects.requireNonNull(exceptionMetaData); | ||
logger.info("Pinot data insert: {}", exceptionMetaData); | ||
|
||
for (ExceptionMetaData e : exceptionMetaData) { | ||
ListenableFuture<SendResult<String, ExceptionMetaDataVo>> response = this.kafkaExceptionMetaDataTemplate.send( | ||
topic, ExceptionMetaDataVo.valueOf(e) | ||
); | ||
response.addCallback(resultCallback); | ||
} | ||
} | ||
} |
119 changes: 119 additions & 0 deletions
119
.../main/java/com/navercorp/pinpoint/exceptiontrace/collector/model/ExceptionMetaDataVo.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,119 @@ | ||
/* | ||
* 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.exceptiontrace.collector.model; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.navercorp.pinpoint.exceptiontrace.common.model.ExceptionMetaData; | ||
import com.navercorp.pinpoint.exceptiontrace.common.model.StackTraceElementWrapper; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
/** | ||
* @author intr3p1d | ||
*/ | ||
public class ExceptionMetaDataVo { | ||
|
||
private final ExceptionMetaData exceptionMetaData; | ||
private final StackTraceElementWrappersListVo wrappersListVo; | ||
|
||
|
||
public ExceptionMetaDataVo( | ||
ExceptionMetaData exceptionMetaData | ||
) { | ||
this.exceptionMetaData = exceptionMetaData; | ||
this.wrappersListVo = new StackTraceElementWrappersListVo(exceptionMetaData.getStackTrace().getStackTrace()); | ||
} | ||
|
||
public static ExceptionMetaDataVo valueOf(ExceptionMetaData exceptionMetaData) { | ||
return new ExceptionMetaDataVo( | ||
exceptionMetaData | ||
); | ||
} | ||
|
||
public long getTimestamp() { | ||
return this.exceptionMetaData.getTimestamp(); | ||
} | ||
|
||
public String getTransactionId() { | ||
return this.exceptionMetaData.getTransactionId(); | ||
} | ||
|
||
public long getSpanId() { | ||
return this.exceptionMetaData.getSpanId(); | ||
} | ||
|
||
public long getExceptionId() { | ||
return this.exceptionMetaData.getExceptionId(); | ||
} | ||
|
||
public String getApplicationServiceType() { | ||
return this.exceptionMetaData.getApplicationServiceType(); | ||
} | ||
|
||
public String getApplicationName() { | ||
return this.exceptionMetaData.getApplicationName(); | ||
} | ||
|
||
public String getAgentId() { | ||
return this.exceptionMetaData.getAgentId(); | ||
} | ||
|
||
public String getUriTemplate() { | ||
return this.exceptionMetaData.getUriTemplate(); | ||
} | ||
|
||
public String getErrorClassName() { | ||
return this.exceptionMetaData.getErrorClassName(); | ||
} | ||
|
||
public String getErrorMessage() { | ||
return this.exceptionMetaData.getErrorMessage(); | ||
} | ||
|
||
public int getExceptionDepth() { | ||
return this.exceptionMetaData.getExceptionDepth(); | ||
} | ||
|
||
public Iterable<String> getStackTraceClassName() { | ||
return wrappersListVo.getStackTraceClassName(); | ||
} | ||
|
||
public Iterable<String> getStackTraceFileName() { | ||
return wrappersListVo.getStackTraceFileName(); | ||
} | ||
|
||
public Iterable<Integer> getStackTraceLineNumber() { | ||
return wrappersListVo.getStackTraceLineNumber(); | ||
} | ||
|
||
public Iterable<String> getStackTraceMethodName() { | ||
return wrappersListVo.getStackTraceMethodName(); | ||
} | ||
|
||
public String getStackTraceHash() { | ||
return this.exceptionMetaData.getStackTraceHash(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ExceptionMetaDataVo{" + | ||
"exceptionMetaData=" + exceptionMetaData + | ||
'}'; | ||
} | ||
} |
Oops, something went wrong.