Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(FSADT1-992): adding monitoring and events #716

Merged
merged 13 commits into from
Jan 8, 2024
4 changes: 4 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ jobs:

- name: Frontend Unit Coverage
uses: romeovs/[email protected]
continue-on-error: true
with:
title: Frontend unit Test Coverage
delete-old-comments: true
Expand All @@ -152,6 +153,7 @@ jobs:

- name: Frontend Component Coverage
uses: romeovs/[email protected]
continue-on-error: true
with:
title: Frontend component Test Coverage
delete-old-comments: true
Expand All @@ -160,6 +162,7 @@ jobs:

- name: Frontend E2E Coverage
uses: romeovs/[email protected]
continue-on-error: true
with:
title: Frontend e2e Test Coverage
delete-old-comments: true
Expand All @@ -168,6 +171,7 @@ jobs:

- uses: actions/upload-artifact@v4
name: Upload Cypress Screenshots with error
continue-on-error: true
if: failure()
with:
name: cypress-screenshots
Expand Down
8 changes: 8 additions & 0 deletions backend/openshift.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ objects:
type: Rolling
template:
metadata:
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "8080"
prometheus.io/path: "/metrics"
labels:
app: ${NAME}-${ZONE}
deploymentconfig: ${NAME}-${ZONE}-${COMPONENT}
Expand Down Expand Up @@ -189,6 +193,10 @@ objects:
value: ${COGNITO_COOKIE_DOMAIN}
- name: TZ
value: America/Vancouver
- name: APP_ZONE
value: ${ZONE}
- name: APP_COMPONENT
value: ${COMPONENT}
ports:
- containerPort: 8080
protocol: TCP
Expand Down
25 changes: 25 additions & 0 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
Expand Down Expand Up @@ -168,7 +176,24 @@
</dependencyManagement>

<build>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
<includes>
<include>db/**</include>
<include>application*</include>
<include>static/**</include>
<include>templates/**</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package ca.bc.gov.app.configuration;

import io.micrometer.core.aop.TimedAspect;
import io.micrometer.core.instrument.Meter;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.config.MeterFilter;
import io.micrometer.core.instrument.distribution.DistributionStatisticConfig;
import io.micrometer.prometheus.PrometheusMeterRegistry;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ForestClientMetricConfiguration {

@Value("${info.app.version}")
private String appVersion;

@Value("${info.app.name}")
private String appName;

@Value("${info.app.zone}")
private String appZone;

@Bean
public TimedAspect timedAspect(MeterRegistry registry) {
return new TimedAspect(registry);
}

@Bean
public MeterRegistryCustomizer<MeterRegistry> metricsCommonTags() {
return registry -> registry.config()
.commonTags(
"version", appVersion,
"app", appName,
"zone",appZone
)
.meterFilter(ignoreTag())
.meterFilter(distribution());
}

@Bean
public MeterRegistryCustomizer<PrometheusMeterRegistry> prometheusConfiguration() {
return MeterRegistry::config;
}

public MeterFilter ignoreTag() {
return MeterFilter.ignoreTags("type");
}

public MeterFilter distribution() {
return new MeterFilter() {

@Override
public DistributionStatisticConfig configure(Meter.Id id,
DistributionStatisticConfig config) {
return DistributionStatisticConfig
.builder()
.percentiles(0.5, 0.95, 0.99)
.percentilesHistogram(true)
.build()
.merge(config);
}
};
}

}
2 changes: 0 additions & 2 deletions backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
info.app.build=@timestamp@
info.app.name=FSA Forest Client
[email protected]@
info.app.description=Forest Client Application version @project.version@

spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
Expand Down
10 changes: 9 additions & 1 deletion backend/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,26 @@ spring:
force: true

management:
enable-native-support: true
endpoint:
health:
show-details: always
endpoints:
web:
path-mapping:
prometheus: metrics
base-path: /
exposure:
include: "*"
include: health,info,prometheus,httptrace
httpexchanges:
recording:
include: principal,request-headers,response-headers,cookie-headers,time-taken,authorization-header,remote-address,session-id

info:
app:
name: nr-forest-client-${APP_COMPONENT:backend}
zone: ${APP_ZONE:local}

ca:
bc:
gov:
Expand Down
80 changes: 0 additions & 80 deletions ches/ChesControllerIntegrationTest.java

This file was deleted.

4 changes: 4 additions & 0 deletions legacy/openshift.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ objects:
type: Rolling
template:
metadata:
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9000"
prometheus.io/path: "/metrics"
labels:
app: ${NAME}-${ZONE}
deploymentconfig: ${NAME}-${ZONE}-${COMPONENT}
Expand Down
24 changes: 24 additions & 0 deletions legacy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@
<artifactId>spring-boot-starter-data-r2dbc</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>

<dependency>
<groupId>com.oracle.database.r2dbc</groupId>
<artifactId>oracle-r2dbc</artifactId>
Expand Down Expand Up @@ -184,7 +193,22 @@
</dependencyManagement>

<build>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
<includes>
<include>application*</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
</plugin>

<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package ca.bc.gov.app.configuration;

import io.micrometer.core.aop.TimedAspect;
import io.micrometer.core.instrument.Meter;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.config.MeterFilter;
import io.micrometer.core.instrument.distribution.DistributionStatisticConfig;
import io.micrometer.prometheus.PrometheusMeterRegistry;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ForestClientMetricConfiguration {

@Value("${info.app.version}")
private String appVersion;

@Value("${info.app.name}")
private String appName;

@Value("${info.app.zone}")
private String appZone;

@Bean
public TimedAspect timedAspect(MeterRegistry registry) {
return new TimedAspect(registry);
}

@Bean
public MeterRegistryCustomizer<MeterRegistry> metricsCommonTags() {
return registry -> registry.config()
.commonTags(
"version", appVersion,
"app", appName,
"zone",appZone
)
.meterFilter(ignoreTag())
.meterFilter(distribution());
}

@Bean
public MeterRegistryCustomizer<PrometheusMeterRegistry> prometheusConfiguration() {
return MeterRegistry::config;
}

public MeterFilter ignoreTag() {
return MeterFilter.ignoreTags("type");
}

public MeterFilter distribution() {
return new MeterFilter() {

@Override
public DistributionStatisticConfig configure(Meter.Id id,
DistributionStatisticConfig config) {
return DistributionStatisticConfig
.builder()
.percentiles(0.5, 0.95, 0.99)
.percentilesHistogram(true)
.build()
.merge(config);
}
};
}

}
Loading
Loading