Skip to content

Commit

Permalink
feat: monitoring (#411)
Browse files Browse the repository at this point in the history
* chore: versions make command

## In `code`

* Split versions for api and web-ui
* Add make get-*-version
* Add make get-versions
* Refacto methods et make help exposition

* feat: expose actuator

* feat: expose metrics and threaddump with authentication

* chore: ignore custom properties

* chore: removed timed

* chore: update api version to 8.0.2

* chore: update web-ui version to 8.0.2

* chore: remove unused import

* chore: custom sample properties

* feat: add influxdb support
  • Loading branch information
Thomas GRUSON authored Mar 9, 2021
1 parent c10f426 commit 494ed24
Show file tree
Hide file tree
Showing 43 changed files with 104 additions and 208 deletions.
2 changes: 1 addition & 1 deletion charts/candidate/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: ara
version: 8.0.0-rc.0
version: 8.0.2-rc.0
home: https://github.com/Decathlon/ara
description: |
ARA helps you to fight against regressions by letting it preanalyze your non-regression tests runs,
Expand Down
2 changes: 1 addition & 1 deletion charts/candidate/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ spec:
- backend:
serviceName: {{ printf "%s-%s" .Chart.Name "api" }}
servicePort: http-port
path: /actuator/info
path: /actuator
- backend:
serviceName: {{ printf "%s-%s" .Chart.Name "api" }}
servicePort: http-port
Expand Down
4 changes: 2 additions & 2 deletions charts/candidate/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ api:
image:
registry: docker.io
repository: decathlon/ara-api
# tag:
tag: 8.0.2
imagePullPolicy: IfNotPresent
replicas: 1
annotations: {}
Expand Down Expand Up @@ -44,7 +44,7 @@ ui:
image:
registry: docker.io
repository: decathlon/ara-web-ui
# tag:
tag: 8.0.2
imagePullPolicy: IfNotPresent
replicas: 1
annotations: {}
Expand Down
83 changes: 45 additions & 38 deletions code/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,34 @@
DOCKER_REGISTRY?=docker.io
# Forks may use name/ara for their tests
IMAGE_NAME?=decathlon/ara
VERSION?=latest
API_VERSION?=latest
WEB_UI_VERSION?=latest

API_IMAGE=${DOCKER_REGISTRY}/${IMAGE_NAME}-api:${VERSION}
WEB_UI_IMAGE=${DOCKER_REGISTRY}/${IMAGE_NAME}-web-ui:${VERSION}

DIFF_LABEL = "to-be-changed"
DATE_WITH_TIME := $(shell /bin/date "+%Y%m%d%H%M%S")
BASE?=h2
API_IMAGE=${DOCKER_REGISTRY}/${IMAGE_NAME}-api:${API_VERSION}
WEB_UI_IMAGE=${DOCKER_REGISTRY}/${IMAGE_NAME}-web-ui:${WEB_UI_VERSION}

#####################################
## QUICK START ##
#####################################

start: ## Start ARA
@echo '-- Start ARA --'
@export VERSION=$(VERSION); docker-compose up -d
@export API_VERSION=$(API_VERSION); export WEB_UI_VERSION=$(WEB_UI_VERSION); docker-compose up -d

stop: ## Stop ARA
@echo '-- Stop ARA --'
@export VERSION=$(VERSION); docker-compose down
@export API_VERSION=$(API_VERSION); export WEB_UI_VERSION=$(WEB_UI_VERSION); docker-compose down


# RUN BY MODULE

run-db: ## Run database
@echo '-- Run database --'
@export VERSION=$(VERSION); docker-compose up ara-db
run-%: ## Run module
@echo '-- Run $* --'
@export API_VERSION=$(API_VERSION); export WEB_UI_VERSION=$(WEB_UI_VERSION); docker-compose up $(OPT) ara-$*

run-api: ## Run api
@echo '-- Run ara-api --'
@export VERSION=$(VERSION); docker-compose up ara-api

run-web-ui: ## Run web-ui
@echo '-- Run ara-web-ui --'
@export VERSION=$(VERSION); docker-compose up ara-web-ui

start-db: ## Start database in background
@echo '-- Start database in background --'
@export VERSION=$(VERSION); docker-compose up -d ara-db
stop-%: ## Stop module
@echo '-- Stop $* --'
@docker-compose up $(OPT) ara-$*

#####################################
## BUILD APP ##
Expand All @@ -52,7 +41,7 @@ start-db: ## Start database in background
build: ## Build ARA in parallel
@$(MAKE) build-full -j2 -k

build-full: build-api build-web-ui ## Build ARA
build-full: build-api build-web-ui

about-web-ui:
@mkdir -p web-ui/static/version
Expand Down Expand Up @@ -84,7 +73,7 @@ about-api:
-f about.jq > \
api/server/src/main/resources/static/api/version/about.json

build-api: ## Build ara-api
build-api: about-api ## Build ara-api
@echo '-- Build ${API_IMAGE} --'
@docker build -t ${API_IMAGE} api

Expand All @@ -93,6 +82,9 @@ build-api: ## Build ara-api
#####################################

# CREATE LIQUIBASE DIFF
DIFF_LABEL = "to-be-changed"
DATE_WITH_TIME := $(shell /bin/date "+%Y%m%d%H%M%S")
BASE?=h2

liquibase-diff: build-api up-migration ## Create a liquibase diff file -- DIFF_LABEL required, BASE to specify database
ifeq ($(BASE),h2)
Expand Down Expand Up @@ -122,38 +114,53 @@ stop-migration-stack:

# UPDATE ARA VERSION

update-chart-version:
get-versions: ## Give ARA version
@echo -n 'chart stable: '
@$(MAKE) get-chart-version TARGET_CHART=stable
@echo -n 'chart candidate: '
@$(MAKE) get-chart-version TARGET_CHART=candidate
@echo -n 'api: '
@$(MAKE) get-api-version
@echo -n 'web-ui: '
@$(MAKE) get-web-ui-version

TARGET_CHART?=stable
get-chart-version:
@echo $$(cat ../charts/$(TARGET_CHART)/Chart.yaml | grep version | sed -e 's/version: //')

update-chart-version: ## Update chart version
@echo '-- Update Helm Chart version --'
@sed -i'.old' 's/^version:.*$\/version: $(VERSION)/' ../charts/stable/Chart.yaml
@sed -i'.old' 's/^version:.*$\/version: $(VERSION)/' ../charts/$(TARGET_CHART)/Chart.yaml

get-api-version:
@$(MAKE) -C api get-version

update-maven-version:
update-api-version: ## Update api version
@echo '-- Update Maven version --'
@mvn --batch-mode -f api/pom.xml -s api/settings.xml release:update-versions -DautoVersionSubmodules=true -DdevelopmentVersion=$(VERSION)-SNAPSHOT
@mvn --batch-mode -f api/pom.xml -s api/settings.xml versions:set -DremoveSnapshot -DprocessAllModules

update-front-version:
get-web-ui-version:
@$(MAKE) -C web-ui get-version

update-web-ui-version: ## Update web-ui version
@echo '-- Update Web-UI version --'
@npm --prefix web-ui version $(VERSION)

commit-version:
@echo '-- Commit new version --'
@git add -A && git commit -m "⬆️ Upgrade to $(VERSION)" && git push


#####################################
## HELM PART ##
#####################################

helm-tempate: ## Helm template
helm-tempate:
@helm template ../charts/stable --debug

helm-install: ## Helm install ara-local
helm-install:
@helm install --create-namespace --namespace ara ara-local ../charts/stable

helm-upgrade: ## Helm upgrade ara-local
helm-upgrade:
@helm upgrade --namespace ara ara-local ../charts/stable

helm-uninstall: ## Helm uninstall ara-local
helm-uninstall:
@helm uninstall --namespace ara ara-local

.PHONY: help
Expand Down
4 changes: 3 additions & 1 deletion code/api/database/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<groupId>com.decathlon.ara</groupId>
<artifactId>ara-database</artifactId>
<version>8.0.1</version>
<version>8.0.2</version>

<name>ARA Database</name>
<description>
Expand All @@ -39,6 +39,8 @@
<properties>
<java.version>14</java.version>
<querydsl.version>4.3.1</querydsl.version>
<diffChangeLogFile>src/main/resources/db/changelog/changes/XX/to-be-changed.yaml</diffChangeLogFile>
<liquibasePropertyFile>src/main/resources/liquibase-XX.properties</liquibasePropertyFile>
</properties>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion code/api/generated-cucumber-report/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<groupId>com.decathlon.ara</groupId>
<artifactId>ara-generated-cucumber-report</artifactId>
<version>8.0.1</version>
<version>8.0.2</version>

<name>ARA Cucumber</name>
<description>
Expand Down
2 changes: 1 addition & 1 deletion code/api/jacoco-aggregation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>ara-parent</artifactId>
<groupId>com.decathlon.ara</groupId>
<version>8.0.1</version>
<version>8.0.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion code/api/lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<groupId>com.decathlon.ara</groupId>
<artifactId>ara-lib</artifactId>
<version>8.0.1</version>
<version>8.0.2</version>

<properties>
<java.version>14</java.version>
Expand Down
2 changes: 1 addition & 1 deletion code/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<groupId>com.decathlon.ara</groupId>
<artifactId>ara-parent</artifactId>
<packaging>pom</packaging>
<version>8.0.1</version>
<version>8.0.2</version>

<name>ARA API</name>
<description>
Expand Down
1 change: 1 addition & 0 deletions code/api/server/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ src/test/resources/dbunit/freshly-created-dataset-to-rename.xml
# application.properties
## authentication
/src/main/resources/application-auth.properties
/src/main/resources/application-custom.properties
32 changes: 5 additions & 27 deletions code/api/server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<groupId>com.decathlon.ara</groupId>
<artifactId>ara-server</artifactId>
<version>8.0.1</version>
<version>8.0.2</version>

<name>ARA Server</name>
<description>
Expand Down Expand Up @@ -59,6 +59,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-influx</artifactId>
</dependency>

<!-- Tests and development -->
<dependency>
Expand Down Expand Up @@ -112,32 +116,6 @@
<artifactId>commons-lang3</artifactId>
</dependency>

<!-- From JHipster -->
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-annotation</artifactId>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-json</artifactId>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-jcache</artifactId>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-jvm</artifactId>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-servlet</artifactId>
</dependency>

<!-- Entity<->DTO Mappapplicater classes generation -->
<dependency>
<groupId>org.mapstruct</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected void configure(HttpSecurity http) throws Exception {
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeRequests()//NOSONAR
.antMatchers("/actuator/**").permitAll()
.antMatchers("/actuator/info", "/actuator/health").permitAll()
.antMatchers("/auth/**").permitAll()
.antMatchers(swaggerResources).permitAll()
.anyRequest().authenticated()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package com.decathlon.ara.scenario.cucumber.resource;

import com.codahale.metrics.annotation.Timed;

import com.decathlon.ara.scenario.cucumber.upload.CucumberScenarioUploader;
import com.decathlon.ara.service.ProjectService;
import com.decathlon.ara.service.exception.BadRequestException;
Expand Down Expand Up @@ -56,7 +56,6 @@ public class CucumberResource {
* @return OK on success, INTERNAL_SERVER_ERROR on processing error
*/
@PostMapping("scenarios/upload/{sourceCode}")
@Timed
public ResponseEntity<Void> uploadScenarios(@PathVariable String projectCode, @PathVariable String sourceCode, @Valid @RequestBody String json) {
try {
cucumberScenarioUploader.uploadCucumber(projectService.toId(projectCode), sourceCode, json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package com.decathlon.ara.scenario.cypress.resource;

import com.codahale.metrics.annotation.Timed;

import com.decathlon.ara.scenario.cucumber.bean.Feature;
import com.decathlon.ara.scenario.cypress.upload.CypressScenarioUploader;
import com.decathlon.ara.service.ProjectService;
Expand Down Expand Up @@ -49,7 +49,6 @@ public class CypressResource {
private final CypressScenarioUploader cypressScenarioUploader;

@PostMapping("scenarios/upload/{sourceCode}")
@Timed
public ResponseEntity<Void> uploadCucumberScenarios(@PathVariable String projectCode, @PathVariable String sourceCode, @RequestBody List<Feature> features) {
try {
cypressScenarioUploader.uploadScenarios(projectService.toId(projectCode), sourceCode, features);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package com.decathlon.ara.scenario.postman.resource;

import com.codahale.metrics.annotation.Timed;

import com.decathlon.ara.Entities;
import com.decathlon.ara.scenario.postman.upload.PostmanScenarioUploader;
import com.decathlon.ara.service.ProjectService;
Expand Down Expand Up @@ -54,7 +54,6 @@ public class PostmanResource {
private final PostmanScenarioUploader postmanScenarioUploader;

@PostMapping("scenarios/upload/{sourceCode}")
@Timed
public ResponseEntity<Void> uploadScenarios(@PathVariable String projectCode,
@PathVariable String sourceCode,
@RequestParam("file") MultipartFile file) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package com.decathlon.ara.web.rest;

import com.codahale.metrics.annotation.Timed;

import com.decathlon.ara.Entities;
import com.decathlon.ara.service.ProjectService;
import com.decathlon.ara.service.exception.NotFoundException;
Expand Down Expand Up @@ -61,7 +61,6 @@ public class CommunicationResource {
* @return the ResponseEntity with status 200 (OK) and the list of entities in body
*/
@GetMapping("")
@Timed
public ResponseEntity<List<CommunicationDTO>> getAll(@PathVariable String projectCode) {
try {
return ResponseEntity.ok().body(service.findAll(projectService.toId(projectCode)));
Expand All @@ -71,7 +70,6 @@ public ResponseEntity<List<CommunicationDTO>> getAll(@PathVariable String projec
}

@GetMapping("/{code}")
@Timed
public ResponseEntity<CommunicationDTO> getOneByCode(@PathVariable String projectCode, @PathVariable String code) {
try {
return ResponseEntity.ok().body(service.findOneByCode(projectService.toId(projectCode), code));
Expand All @@ -81,7 +79,6 @@ public ResponseEntity<CommunicationDTO> getOneByCode(@PathVariable String projec
}

@PutMapping("/{code}")
@Timed
public ResponseEntity<CommunicationDTO> update(@PathVariable String projectCode,
@PathVariable String code,
@Valid @RequestBody CommunicationDTO dtoToUpdate) {
Expand Down
Loading

0 comments on commit 494ed24

Please sign in to comment.