From 814a73f1602ffd08aa176ca0b4dacbf53c3b6fc7 Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Thu, 4 Jan 2024 11:04:51 -0800 Subject: [PATCH 01/11] ci: fixing ci --- .github/workflows/unit-tests.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index bc9b349997..2131ee5451 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -144,6 +144,7 @@ jobs: - name: Frontend Unit Coverage uses: romeovs/lcov-reporter-action@v0.3.1 + continue-on-error: true with: title: Frontend unit Test Coverage delete-old-comments: true @@ -152,6 +153,7 @@ jobs: - name: Frontend Component Coverage uses: romeovs/lcov-reporter-action@v0.3.1 + continue-on-error: true with: title: Frontend component Test Coverage delete-old-comments: true @@ -160,6 +162,7 @@ jobs: - name: Frontend E2E Coverage uses: romeovs/lcov-reporter-action@v0.3.1 + continue-on-error: true with: title: Frontend e2e Test Coverage delete-old-comments: true @@ -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 From 06912c0c911fd03b586292ff742654200f241f48 Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Thu, 4 Jan 2024 12:58:35 -0800 Subject: [PATCH 02/11] chore: removed unused file --- ches/ChesControllerIntegrationTest.java | 80 ------------------------- 1 file changed, 80 deletions(-) delete mode 100644 ches/ChesControllerIntegrationTest.java diff --git a/ches/ChesControllerIntegrationTest.java b/ches/ChesControllerIntegrationTest.java deleted file mode 100644 index 96934b2228..0000000000 --- a/ches/ChesControllerIntegrationTest.java +++ /dev/null @@ -1,80 +0,0 @@ -package ca.bc.gov.app.controller.ches; - -import static ca.bc.gov.app.TestConstants.EMAIL_REQUEST; -import static com.github.tomakehurst.wiremock.client.WireMock.ok; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; - -import ca.bc.gov.app.TestConstants; -import ca.bc.gov.app.dto.client.EmailRequestDto; -import ca.bc.gov.app.extensions.AbstractTestContainerIntegrationTest; -import ca.bc.gov.app.extensions.WiremockLogNotifier; -import com.github.tomakehurst.wiremock.junit5.WireMockExtension; -import java.time.Duration; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; -import org.springframework.test.web.reactive.server.WebTestClient; -import reactor.core.publisher.Mono; - -@DisplayName("Integrated Test | FSA Client Email Controller") -class ChesControllerIntegrationTest extends AbstractTestContainerIntegrationTest { - - @Autowired - protected WebTestClient client; - - @RegisterExtension - static WireMockExtension chesStub = WireMockExtension - .newInstance() - .options( - wireMockConfig() - .port(10010) - .notifier(new WiremockLogNotifier()) - .asynchronousResponseEnabled(true) - .stubRequestLoggingDisabled(false) - ) - .configureStaticDsl(true) - .build(); - - @BeforeEach - public void init() { - - chesStub - .stubFor( - post("/chess/uri") - .willReturn( - ok(TestConstants.CHES_SUCCESS_MESSAGE) - .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) - ) - ); - - chesStub - .stubFor( - post("/token/uri") - .willReturn( - ok(TestConstants.CHES_TOKEN_MESSAGE) - .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) - ) - ); - - client = client.mutate() - .responseTimeout(Duration.ofSeconds(10)) - .build(); - } - - @Test - @DisplayName("Submit email request") - void shouldSubmitRegisteredBusinessData() { - client - .post() - .uri("/api/ches/email") - .body(Mono.just(EMAIL_REQUEST), EmailRequestDto.class) - .exchange() - .expectStatus().isAccepted() - .expectBody().isEmpty(); - } - -} \ No newline at end of file From 403ab3a8b6967fa0aa724e296e1d7c7ab508b012 Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Thu, 4 Jan 2024 12:58:56 -0800 Subject: [PATCH 03/11] chore: enabling cluster monitoring --- common/openshift.init.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/common/openshift.init.yml b/common/openshift.init.yml index 14db16f63a..8896dabf85 100644 --- a/common/openshift.init.yml +++ b/common/openshift.init.yml @@ -159,15 +159,13 @@ objects: storage: ${IDX_PVC_SIZE} storageClassName: netapp-file-standard - kind: PersistentVolumeClaim + - kind: Namespace apiVersion: v1 metadata: - name: ${NAME}-${ZONE}-index-backup + name: ${NAME}-${ZONE} + annotations: + openshift.io/node-selector: "" labels: + openshift.io/cluster-monitoring: "true" app: ${NAME}-${ZONE} - spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: ${IDX_BKP_PVC_SIZE} - storageClassName: netapp-file-standard \ No newline at end of file + \ No newline at end of file From 03632b603668b2a5252103b4608853316e70bc5f Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Fri, 5 Jan 2024 11:07:07 -0800 Subject: [PATCH 04/11] feat(FSADT1-992): adding STRA monitoring system --- backend/openshift.deploy.yml | 8 +++ backend/pom.xml | 25 +++++++ .../ForestClientMetricConfiguration.java | 68 +++++++++++++++++++ .../src/main/resources/application.properties | 2 - backend/src/main/resources/application.yml | 9 ++- 5 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 backend/src/main/java/ca/bc/gov/app/configuration/ForestClientMetricConfiguration.java diff --git a/backend/openshift.deploy.yml b/backend/openshift.deploy.yml index df1c697c4a..3dca44bfcc 100644 --- a/backend/openshift.deploy.yml +++ b/backend/openshift.deploy.yml @@ -74,6 +74,10 @@ objects: labels: app: ${NAME}-${ZONE} name: ${NAME}-${ZONE}-${COMPONENT} + annotations: + prometheus.io/scrape: true + prometheus.io/port: 8080 + prometheus.io/path: /metrics spec: replicas: 1 triggers: @@ -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 diff --git a/backend/pom.xml b/backend/pom.xml index e4a57736e5..f6dab5a3b8 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -71,6 +71,14 @@ org.springframework.boot spring-boot-starter-freemarker + + org.springframework.boot + spring-boot-starter-aop + + + io.micrometer + micrometer-registry-prometheus + org.springframework spring-jdbc @@ -168,7 +176,24 @@ + + + true + src/main/resources + + db/** + application* + static/** + templates/** + + + + + org.apache.maven.plugins + maven-resources-plugin + 3.1.0 + org.graalvm.buildtools native-maven-plugin diff --git a/backend/src/main/java/ca/bc/gov/app/configuration/ForestClientMetricConfiguration.java b/backend/src/main/java/ca/bc/gov/app/configuration/ForestClientMetricConfiguration.java new file mode 100644 index 0000000000..4cac8f0c74 --- /dev/null +++ b/backend/src/main/java/ca/bc/gov/app/configuration/ForestClientMetricConfiguration.java @@ -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 metricsCommonTags() { + return registry -> registry.config() + .commonTags( + "version", appVersion, + "app", appName, + "zone",appZone + ) + .meterFilter(ignoreTag()) + .meterFilter(distribution()); + } + + @Bean + public MeterRegistryCustomizer 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); + } + }; + } + +} diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index 7ee1bc6c42..9f10172581 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -1,7 +1,5 @@ info.app.build=@timestamp@ -info.app.name=FSA Forest Client info.app.version=@project.version@ -info.app.description=Forest Client Application version @project.version@ spring.http.encoding.charset=UTF-8 spring.http.encoding.enabled=true diff --git a/backend/src/main/resources/application.yml b/backend/src/main/resources/application.yml index 7b6b640a58..cd029932be 100644 --- a/backend/src/main/resources/application.yml +++ b/backend/src/main/resources/application.yml @@ -37,13 +37,20 @@ management: 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: From 877d09b6617c3cff42d6b8ed6304545588f83a6c Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Fri, 5 Jan 2024 11:17:21 -0800 Subject: [PATCH 05/11] chore: fixing init --- common/openshift.init.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/common/openshift.init.yml b/common/openshift.init.yml index 8896dabf85..14db16f63a 100644 --- a/common/openshift.init.yml +++ b/common/openshift.init.yml @@ -159,13 +159,15 @@ objects: storage: ${IDX_PVC_SIZE} storageClassName: netapp-file-standard - kind: PersistentVolumeClaim - - kind: Namespace apiVersion: v1 metadata: - name: ${NAME}-${ZONE} - annotations: - openshift.io/node-selector: "" + name: ${NAME}-${ZONE}-index-backup labels: - openshift.io/cluster-monitoring: "true" app: ${NAME}-${ZONE} - \ No newline at end of file + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: ${IDX_BKP_PVC_SIZE} + storageClassName: netapp-file-standard \ No newline at end of file From ecde1769e49bbf53a87feda11bf6de8dd1a9832d Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Fri, 5 Jan 2024 12:47:41 -0800 Subject: [PATCH 06/11] chore: updating annotations --- backend/openshift.deploy.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/openshift.deploy.yml b/backend/openshift.deploy.yml index 3dca44bfcc..0a287ed612 100644 --- a/backend/openshift.deploy.yml +++ b/backend/openshift.deploy.yml @@ -96,6 +96,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} From 57ebdaaee77cb63e2d06fc6a8702233ccb47a032 Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Fri, 5 Jan 2024 13:01:07 -0800 Subject: [PATCH 07/11] chore: updating annotations --- backend/openshift.deploy.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/backend/openshift.deploy.yml b/backend/openshift.deploy.yml index 0a287ed612..ce538c19e9 100644 --- a/backend/openshift.deploy.yml +++ b/backend/openshift.deploy.yml @@ -74,10 +74,6 @@ objects: labels: app: ${NAME}-${ZONE} name: ${NAME}-${ZONE}-${COMPONENT} - annotations: - prometheus.io/scrape: true - prometheus.io/port: 8080 - prometheus.io/path: /metrics spec: replicas: 1 triggers: From e0fcefae116b1f71374ddd95932e37b8348209fc Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Fri, 5 Jan 2024 13:04:13 -0800 Subject: [PATCH 08/11] chore: updating annotations --- backend/openshift.deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/openshift.deploy.yml b/backend/openshift.deploy.yml index ce538c19e9..4afdbc3ae9 100644 --- a/backend/openshift.deploy.yml +++ b/backend/openshift.deploy.yml @@ -94,8 +94,8 @@ objects: metadata: annotations: prometheus.io/scrape: true - prometheus.io/port: 8080 - prometheus.io/path: /metrics + #prometheus.io/port: 8080 + #prometheus.io/path: /metrics labels: app: ${NAME}-${ZONE} deploymentconfig: ${NAME}-${ZONE}-${COMPONENT} From 7132f38a892f2a617e7524443b5b56d1ef19234f Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Fri, 5 Jan 2024 13:06:57 -0800 Subject: [PATCH 09/11] chore: updating annotations --- backend/openshift.deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/openshift.deploy.yml b/backend/openshift.deploy.yml index 4afdbc3ae9..0ab9043a77 100644 --- a/backend/openshift.deploy.yml +++ b/backend/openshift.deploy.yml @@ -93,7 +93,7 @@ objects: template: metadata: annotations: - prometheus.io/scrape: true + prometheus.io/scrape: "true" #prometheus.io/port: 8080 #prometheus.io/path: /metrics labels: From 2577698c2e81520dd870c424a03016ff090962bb Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Fri, 5 Jan 2024 13:08:43 -0800 Subject: [PATCH 10/11] chore: updating annotations --- backend/openshift.deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/openshift.deploy.yml b/backend/openshift.deploy.yml index 0ab9043a77..abe7ffae51 100644 --- a/backend/openshift.deploy.yml +++ b/backend/openshift.deploy.yml @@ -94,8 +94,8 @@ objects: metadata: annotations: prometheus.io/scrape: "true" - #prometheus.io/port: 8080 - #prometheus.io/path: /metrics + prometheus.io/port: "8080" + prometheus.io/path: "/metrics" labels: app: ${NAME}-${ZONE} deploymentconfig: ${NAME}-${ZONE}-${COMPONENT} From 971417c8a32f7a9a3e06dd2a43575291a70cc646 Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Fri, 5 Jan 2024 13:54:58 -0800 Subject: [PATCH 11/11] feat(FSADT1-992): adding prom annotation to all backend apps --- backend/src/main/resources/application.yml | 1 + legacy/openshift.deploy.yml | 4 ++ legacy/pom.xml | 24 +++++++ .../ForestClientMetricConfiguration.java | 68 +++++++++++++++++++ .../src/main/resources/application.properties | 6 +- legacy/src/main/resources/application.yml | 12 +++- processor/openshift.deploy.yml | 4 ++ processor/pom.xml | 22 ++++++ .../ForestClientMetricConfiguration.java | 68 +++++++++++++++++++ .../src/main/resources/application.properties | 6 +- processor/src/main/resources/application.yml | 12 +++- 11 files changed, 221 insertions(+), 6 deletions(-) create mode 100644 legacy/src/main/java/ca/bc/gov/app/configuration/ForestClientMetricConfiguration.java create mode 100644 processor/src/main/java/ca/bc/gov/app/configuration/ForestClientMetricConfiguration.java diff --git a/backend/src/main/resources/application.yml b/backend/src/main/resources/application.yml index cd029932be..02ebf26583 100644 --- a/backend/src/main/resources/application.yml +++ b/backend/src/main/resources/application.yml @@ -32,6 +32,7 @@ spring: force: true management: + enable-native-support: true endpoint: health: show-details: always diff --git a/legacy/openshift.deploy.yml b/legacy/openshift.deploy.yml index ff7680f261..6d2bb50686 100644 --- a/legacy/openshift.deploy.yml +++ b/legacy/openshift.deploy.yml @@ -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} diff --git a/legacy/pom.xml b/legacy/pom.xml index 0723f9bfb5..60dc81999a 100644 --- a/legacy/pom.xml +++ b/legacy/pom.xml @@ -75,6 +75,15 @@ spring-boot-starter-data-r2dbc + + org.springframework.boot + spring-boot-starter-aop + + + io.micrometer + micrometer-registry-prometheus + + com.oracle.database.r2dbc oracle-r2dbc @@ -184,7 +193,22 @@ + + + true + src/main/resources + + application* + + + + + org.apache.maven.plugins + maven-resources-plugin + 3.1.0 + + org.graalvm.buildtools native-maven-plugin diff --git a/legacy/src/main/java/ca/bc/gov/app/configuration/ForestClientMetricConfiguration.java b/legacy/src/main/java/ca/bc/gov/app/configuration/ForestClientMetricConfiguration.java new file mode 100644 index 0000000000..4cac8f0c74 --- /dev/null +++ b/legacy/src/main/java/ca/bc/gov/app/configuration/ForestClientMetricConfiguration.java @@ -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 metricsCommonTags() { + return registry -> registry.config() + .commonTags( + "version", appVersion, + "app", appName, + "zone",appZone + ) + .meterFilter(ignoreTag()) + .meterFilter(distribution()); + } + + @Bean + public MeterRegistryCustomizer 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); + } + }; + } + +} diff --git a/legacy/src/main/resources/application.properties b/legacy/src/main/resources/application.properties index 2b52047560..9f10172581 100644 --- a/legacy/src/main/resources/application.properties +++ b/legacy/src/main/resources/application.properties @@ -1,4 +1,6 @@ info.app.build=@timestamp@ -info.app.name=FSA Legacy Forest Client info.app.version=@project.version@ -info.app.description=Legacy Forest Client Application version @project.version@ + +spring.http.encoding.charset=UTF-8 +spring.http.encoding.enabled=true +spring.http.encoding.force=true \ No newline at end of file diff --git a/legacy/src/main/resources/application.yml b/legacy/src/main/resources/application.yml index 1380a4eb83..d02389f0e8 100644 --- a/legacy/src/main/resources/application.yml +++ b/legacy/src/main/resources/application.yml @@ -29,11 +29,21 @@ management: show-details: always endpoints: web: + path-mapping: + prometheus: metrics base-path: / exposure: - include: health,metrics + 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:legacy} + zone: ${APP_ZONE:local} + ca: bc: gov: diff --git a/processor/openshift.deploy.yml b/processor/openshift.deploy.yml index d18cdcbbfe..25df43b5ac 100644 --- a/processor/openshift.deploy.yml +++ b/processor/openshift.deploy.yml @@ -79,6 +79,10 @@ objects: type: Rolling template: metadata: + annotations: + prometheus.io/scrape: "true" + prometheus.io/port: "3100" + prometheus.io/path: "/metrics" labels: app: ${NAME}-${ZONE} deploymentconfig: ${NAME}-${ZONE}-${COMPONENT} diff --git a/processor/pom.xml b/processor/pom.xml index 4dc52307c7..b70a841a0d 100644 --- a/processor/pom.xml +++ b/processor/pom.xml @@ -69,6 +69,14 @@ org.springframework.boot spring-boot-starter-validation + + org.springframework.boot + spring-boot-starter-aop + + + io.micrometer + micrometer-registry-prometheus + org.postgresql postgresql @@ -167,7 +175,21 @@ + + + true + src/main/resources + + application* + + + + + org.apache.maven.plugins + maven-resources-plugin + 3.1.0 + org.graalvm.buildtools native-maven-plugin diff --git a/processor/src/main/java/ca/bc/gov/app/configuration/ForestClientMetricConfiguration.java b/processor/src/main/java/ca/bc/gov/app/configuration/ForestClientMetricConfiguration.java new file mode 100644 index 0000000000..4cac8f0c74 --- /dev/null +++ b/processor/src/main/java/ca/bc/gov/app/configuration/ForestClientMetricConfiguration.java @@ -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 metricsCommonTags() { + return registry -> registry.config() + .commonTags( + "version", appVersion, + "app", appName, + "zone",appZone + ) + .meterFilter(ignoreTag()) + .meterFilter(distribution()); + } + + @Bean + public MeterRegistryCustomizer 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); + } + }; + } + +} diff --git a/processor/src/main/resources/application.properties b/processor/src/main/resources/application.properties index 401c5c8695..9f10172581 100644 --- a/processor/src/main/resources/application.properties +++ b/processor/src/main/resources/application.properties @@ -1,4 +1,6 @@ info.app.build=@timestamp@ -info.app.name=FSA Forest Client Processor info.app.version=@project.version@ -info.app.description=Forest Client Processor version @project.version@ + +spring.http.encoding.charset=UTF-8 +spring.http.encoding.enabled=true +spring.http.encoding.force=true \ No newline at end of file diff --git a/processor/src/main/resources/application.yml b/processor/src/main/resources/application.yml index 098e9be4d3..285e5b8a5e 100644 --- a/processor/src/main/resources/application.yml +++ b/processor/src/main/resources/application.yml @@ -29,9 +29,19 @@ management: show-details: always endpoints: web: + path-mapping: + prometheus: metrics base-path: / exposure: - include: health,metrics + 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:processor} + zone: ${APP_ZONE:local} ca: bc: