-
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
19 changed files
with
236 additions
and
60 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
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,58 @@ | ||
<?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"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>com.navercorp.pinpoint</groupId> | ||
<artifactId>pinpoint-agent-module</artifactId> | ||
<version>3.1.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>pinpoint-profiler-micrometer</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<properties> | ||
<jdk.version>1.8</jdk.version> | ||
<jdk.home>${env.JAVA_8_HOME}</jdk.home> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.navercorp.pinpoint</groupId> | ||
<artifactId>pinpoint-annotations</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.navercorp.pinpoint</groupId> | ||
<artifactId>pinpoint-commons</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.navercorp.pinpoint</groupId> | ||
<artifactId>pinpoint-commons-config</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.inject</groupId> | ||
<artifactId>guice</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.micrometer</groupId> | ||
<artifactId>micrometer-registry-otlp</artifactId> | ||
</dependency> | ||
|
||
<!-- Logging dependencies --> | ||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-api</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
|
||
</plugins> | ||
</build> | ||
</project> |
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
File renamed without changes.
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
File renamed without changes.
42 changes: 42 additions & 0 deletions
42
...micrometer/src/main/java/com/navercorp/pinpoint/profiler/micrometer/MicrometerModule.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,42 @@ | ||
package com.navercorp.pinpoint.profiler.micrometer; | ||
|
||
import com.google.inject.AbstractModule; | ||
import com.google.inject.Singleton; | ||
import com.navercorp.pinpoint.common.config.util.ValueAnnotationProcessor; | ||
import com.navercorp.pinpoint.profiler.micrometer.config.DefaultMicrometerConfig; | ||
import com.navercorp.pinpoint.profiler.micrometer.config.MicrometerConfig; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
import java.util.Objects; | ||
import java.util.function.Function; | ||
|
||
public class MicrometerModule extends AbstractModule { | ||
|
||
private final Logger logger = LogManager.getLogger(this.getClass()); | ||
|
||
private final Function<String, String> properties; | ||
|
||
public MicrometerModule(Function<String, String> properties) { | ||
this.properties = Objects.requireNonNull(properties, "properties"); | ||
} | ||
|
||
@Override | ||
protected void configure() { | ||
logger.info("load {}", this.getClass().getSimpleName()); | ||
|
||
final ValueAnnotationProcessor process = new ValueAnnotationProcessor(); | ||
|
||
MicrometerConfig micrometerConfig = new DefaultMicrometerConfig(); | ||
process.process(micrometerConfig, properties); | ||
|
||
logger.info("{}", micrometerConfig); | ||
|
||
if (micrometerConfig.isEnable()) { | ||
bind(MicrometerConfig.class).toInstance(micrometerConfig); | ||
bind(MicrometerMonitor.class).to(DefaultMicrometerMonitor.class).in(Singleton.class); | ||
} else { | ||
bind(MicrometerMonitor.class).to(DisableMicrometerMonitor.class).in(Singleton.class);; | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 24 additions & 0 deletions
24
...rometer/src/test/java/com/navercorp/pinpoint/profiler/micrometer/AgentOtlpConfigTest.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,24 @@ | ||
package com.navercorp.pinpoint.profiler.micrometer; | ||
|
||
import io.micrometer.registry.otlp.OtlpConfig; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
class AgentOtlpConfigTest { | ||
|
||
@Test | ||
void getOtlpConfig() { | ||
String url = "http://localhost:8080"; | ||
String step = "10s"; | ||
String batchSize = "100"; | ||
String serviceName = "serviceName"; | ||
String applicationName = "applicationName"; | ||
String agentId = "agentId"; | ||
|
||
OtlpConfig otlpConfig = AgentOtlpConfig.getOtlpConfig(url, step, batchSize, serviceName, applicationName, agentId); | ||
String attribute = otlpConfig.get("otlp.resourceAttributes"); | ||
assertEquals("service.namespace=serviceName,service.name=applicationName,pinpoint.agentId=agentId", attribute); | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
...rc/test/java/com/navercorp/pinpoint/profiler/micrometer/DefaultMicrometerMonitorTest.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,25 @@ | ||
package com.navercorp.pinpoint.profiler.micrometer; | ||
|
||
import com.navercorp.pinpoint.profiler.micrometer.config.DefaultMicrometerConfig; | ||
import com.navercorp.pinpoint.profiler.micrometer.config.MicrometerConfig; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.mockito.Mockito.spy; | ||
import static org.mockito.Mockito.when; | ||
|
||
class DefaultMicrometerMonitorTest { | ||
|
||
@Test | ||
void micrometerMonitor() { | ||
MicrometerConfig config = spy(DefaultMicrometerConfig.class); | ||
when(config.isEnable()).thenReturn(true); | ||
when(config.getUrl()).thenReturn("http://localhost:8080"); | ||
when(config.getStep()).thenReturn("10s"); | ||
when(config.getBatchSize()).thenReturn("100"); | ||
|
||
DefaultMicrometerMonitor monitor = new DefaultMicrometerMonitor("applicationName", "agentId", config); | ||
|
||
monitor.stop(); | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
agent-module/profiler-micrometer/src/test/resources/log4j2-test.xml
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Configuration status="INFO"> | ||
<Properties> | ||
<Property name="console_message_pattern">%d{MM-dd HH:mm:ss.sss} [%15.15t] %clr{%-5level} %clr{%-40.40logger{1.}}{cyan}:%3L -- %msg%n</Property> | ||
<Property name="file_message_pattern">%d{MM-dd HH:mm:ss.sss} [%15.15t] %-5level %-40.40logger{1.}:%3L -- %msg%n</Property> | ||
</Properties> | ||
|
||
<Appenders> | ||
<Console name="console" target="system_out"> | ||
<PatternLayout pattern="${file_message_pattern}"/> | ||
</Console> | ||
</Appenders> | ||
|
||
<Loggers> | ||
<Logger name="com.navercorp.pinpoint" level="DEBUG" additivity="false"> | ||
<AppenderRef ref="console"/> | ||
</Logger> | ||
|
||
<Root level="DEBUG"> | ||
<AppenderRef ref="console"/> | ||
</Root> | ||
</Loggers> | ||
</Configuration> |
29 changes: 29 additions & 0 deletions
29
agent-module/profiler-micrometer/src/test/resources/log4j2-test.yaml
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,29 @@ | ||
Configuration: | ||
status: INFO | ||
|
||
Properties: | ||
Property: | ||
- name: "console_message_pattern" | ||
value: "%d{MM-dd HH:mm:ss.sss} [%15.15t] %clr{%-5level} %clr{%-40.40logger{1.}}{cyan}:%3L -- %msg%n" | ||
- name: "file_message_pattern" | ||
value: "%d{MM-dd HH:mm:ss.sss} [%15.15t] %-5level %-40.40logger{1.}:%3L -- %msg%n" | ||
|
||
Appenders: | ||
Console: | ||
name: console | ||
target: system_out | ||
PatternLayout: | ||
pattern: ${file_message_pattern} | ||
|
||
Loggers: | ||
Logger: | ||
- name: com.navercorp.pinpoint | ||
level: DEBUG | ||
additivity: false | ||
AppenderRef: | ||
- ref: console | ||
|
||
Root: | ||
level: DEBUG | ||
AppenderRef: | ||
- ref: console |
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
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
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
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
Oops, something went wrong.