-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Jonas Bulcke <[email protected]>
- Loading branch information
Showing
10 changed files
with
199 additions
and
2 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
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,40 @@ | ||
<?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>ldi-orchestrator</artifactId> | ||
<groupId>be.vlaanderen.informatievlaanderen.ldes.ldi</groupId> | ||
<version>2.9.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>ldio-application-instrumentation</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.pyroscope</groupId> | ||
<artifactId>agent</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-context</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>jakarta.annotation</groupId> | ||
<artifactId>jakarta.annotation-api</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<finalName>${project.artifactId}</finalName> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
22 changes: 22 additions & 0 deletions
22
...va/be/vlaanderen/informatievlaanderen/ldes/ldio/instrumentation/PyroscopeInitialiser.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,22 @@ | ||
package be.vlaanderen.informatievlaanderen.ldes.ldio.instrumentation; | ||
|
||
import io.pyroscope.javaagent.PyroscopeAgent; | ||
import io.pyroscope.javaagent.config.Config; | ||
import jakarta.annotation.PostConstruct; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class PyroscopeInitialiser { | ||
|
||
@Value("${pyroscope.agent.enabled:false}") | ||
private boolean usePyroscope; | ||
@PostConstruct | ||
public void init() { | ||
if(usePyroscope) { | ||
PyroscopeAgent.start( | ||
Config.build() | ||
); | ||
} | ||
} | ||
} |
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,55 @@ | ||
<?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>ldi-orchestrator</artifactId> | ||
<groupId>be.vlaanderen.informatievlaanderen.ldes.ldi</groupId> | ||
<version>2.11.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>ldio-instrumentation</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.pyroscope</groupId> | ||
<artifactId>agent</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-context</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-autoconfigure</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-test</artifactId> | ||
<version>${spring-boot.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>jakarta.annotation</groupId> | ||
<artifactId>jakarta.annotation-api</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<finalName>${project.artifactId}</finalName> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
18 changes: 18 additions & 0 deletions
18
...va/be/vlaanderen/informatievlaanderen/ldes/ldio/instrumentation/PyroscopeInitialiser.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,18 @@ | ||
package be.vlaanderen.informatievlaanderen.ldes.ldio.instrumentation; | ||
|
||
import io.pyroscope.javaagent.PyroscopeAgent; | ||
import io.pyroscope.javaagent.config.Config; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.context.event.ApplicationReadyEvent; | ||
import org.springframework.context.event.EventListener; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@ConditionalOnProperty(value = "pyroscope.agent.enabled", havingValue = "true") | ||
public class PyroscopeInitialiser { | ||
|
||
@EventListener(ApplicationReadyEvent.class) | ||
public void init() { | ||
PyroscopeAgent.start(Config.build()); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...e/vlaanderen/informatievlaanderen/ldes/ldio/instrumentation/PyroscopeInitialiserTest.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,36 @@ | ||
package be.vlaanderen.informatievlaanderen.ldes.ldio.instrumentation; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.test.context.runner.ApplicationContextRunner; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class PyroscopeInitialiserTest { | ||
private ApplicationContextRunner runner; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
runner = new ApplicationContextRunner() | ||
.withUserConfiguration(PyroscopeInitialiser.class); | ||
} | ||
|
||
@Test | ||
void given_EnabledIsTrue_when_RunContext_then_BeanIsPresent() { | ||
runner | ||
.withPropertyValues("pyroscope.agent.enabled=true") | ||
.run(context -> assertThat(context).hasSingleBean(PyroscopeInitialiser.class)); | ||
} | ||
|
||
@Test | ||
void given_EnabledIsFalse_when_RunContext_then_BeanIsAbsent() { | ||
runner | ||
.withPropertyValues("pyroscope.agent.enabled=false") | ||
.run(context -> assertThat(context).doesNotHaveBean(PyroscopeInitialiser.class)); | ||
} | ||
|
||
@Test | ||
void given_MissingEnabledProperty_when_RunContext_then_BeanIsAbsent() { | ||
runner.run(context -> assertThat(context).doesNotHaveBean(PyroscopeInitialiser.class)); | ||
} | ||
} |
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