Skip to content

Commit

Permalink
Merge pull request #134 from epimorphics/spike/prometheus-metrics-update
Browse files Browse the repository at this point in the history
Primarily Prometheus Metrics
  • Loading branch information
jonrandahl authored Sep 4, 2024
2 parents b0d5b99 + db7e61e commit 4c17e20
Show file tree
Hide file tree
Showing 30 changed files with 405 additions and 138 deletions.
50 changes: 40 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,52 @@
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'

!/log/.keep
.byebug_history
.github-token
.npmrc
.tags
# Ignore vscode config
.vscode

## Ignore bundler configuration:
/.bundle
/vendor/bundle
/lib/bundler/man/

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep
C:\\nppdf32Log\\debuglog.txt

# Ignore Byebug command history file.
.byebug_history

# Ignore node_modules
node_modules/

# Ignore precompiled javascript packs
/public/packs
/public/packs-test
/tmp
C:\\nppdf32Log\\debuglog.txt
coverage
/public/assets

# Ignore uploaded files in development
/storage/*
!/storage/.keep
/public/uploads

### Rails specific ###
.byebug_history
/public/system
/coverage/
tmp

# Ignore files specific to the development environment
fc.json
fc_simple.json
index-names.txt
index.json
public/assets
tags
test/query_test.rb

# Ignore dot files used by environment or IDE tools
.tags
.tool-versions
.github-token
.npmrc
16 changes: 9 additions & 7 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,30 @@ Layout/LineLength:
- config/**/*
- test/**/*

Metrics/ClassLength:
Exclude:
- test/**/*
Lint/DuplicateBranch:
Enabled: false

Metrics/BlockLength:
Max: 30
Exclude:
- test/**/*
- lib/tasks/**/*

Metrics/ClassLength:
CountAsOne: ['array', 'hash', 'heredoc', 'method_call']
Exclude:
- test/**/*

Metrics/MethodLength:
CountAsOne: ['array', 'hash', 'heredoc', 'method_call']
Exclude:
- lib/tasks/location.rake

Style/FormatStringToken:
Enabled: false

Naming/MethodParameterName:
Exclude:
- test/**/*

Lint/DuplicateBranch:
Style/FormatStringToken:
Enabled: false

Style/OptionalBooleanParameter:
Expand Down
60 changes: 49 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,57 @@
# Standard Reports UI: change log

## 1.5.4 - 2024-09

- (Jon) Implemented improved boilerplate metrics integration to offer analysis
of current application usage stats
- (Jon) Added `process_threads` gauge to prometheus metrics alongside isolating
thread counts to specific status' as per the Rails thread documentation
[GH-148](https://github.com/epimorphics/hmlr-linked-data/issues/148)
- (Jon) Updated the approach to resolve
[GH-142](https://github.com/epimorphics/hmlr-linked-data/issues/142)
- (Jon) Excluded prometheus metrics from the testing environment to reduce noise
in the logs
- (Jon) Added `puma-metrics` gem to provide base metrics for the Puma web server
- (Jon) Added the `internal_error_event` metric to the improved error controls
- (Jon) Tweaked the application controller to improve error control and display
provided message in themed pages to match the rest of the application
- (Jon) Added `puma.stats` to footer template in development environment only,
again as per the approach in the [`LR_Common_Styles`
gem](https://github.com/epimorphics/lr_common_styles/releases/tag/1.9.6)
- (Jon) Reorganised makefile targets alphabetically as well as mirrored other
improvements from the other applications in the suite
- (Jon) Updated .rubocop.yml primarily reorganising the rules alphabetically as
well as adding `CountAsOne` to both `Metrics/ClassLength` and
`Metrics/MethodLength`; includes files with removed earlier disabling of said
rules!
- (Jon) Updated `.gitignore` to include ignoring `byebug` history as well as
sets the tmp directory ignore to be anywhere, not just at the project root

## 1.5.3 - 2024-09

- (Dan) Fixes bug XXS vulnerability [133](https://github.com/epimorphics/standard-reports-ui/issues/133)
- (Dan) Update the error messages for the postcode selectors step 3/7 so each error message is unique to the postcode selector [120](https://github.com/epimorphics/standard-reports-ui/issues/120)
- (Dan) Updates alt text for screenshots of example reports [115](https://github.com/epimorphics/standard-reports-ui/issues/115)
- (Dan) Updates report page styles so links are underlined and gives download report page a seperate page title
- (Dan) Updates gemfile to use v1.9.5 lr_common_styles
- (Dan) Updates the page titles throughout the app [116](https://github.com/epimorphics/standard-reports-ui/issues/116)
- (Dan) Updates the button text on reports page to be dynamic and adds aria labels to help screen readers [119](https://github.com/epimorphics/standard-reports-ui/issues/119)
- (Dan) Update the error message for the postcode selectors step 3/7 [120](https://github.com/epimorphics/standard-reports-ui/issues/120)
- (Dan) Update the error message for the postcode selectors step 3/7 [120](https://github.com/epimorphics/standard-reports-ui/issues/120)
- (Dan) Updates step 3/7 to return user input rather than false when user inputs invalid value [118](https://github.com/epimorphics/standard-reports-ui/issues/118)
- (Dan) Adds underline text to laning page of standard reports and to help link[114](https://github.com/epimorphics/standard-reports-ui/issues/114)
- (Dan) Styled the help button to match PPD [117](https://github.com/epimorphics/standard-reports-ui/issues/117)
- (Dan) Adds more descriptive text to action buttons on the report page [115](https://github.com/epimorphics/standard-reports-ui/issues/115)
- (Dan) Updates the page titles throughout the app
[116](https://github.com/epimorphics/standard-reports-ui/issues/116)
- (Dan) Updates the button text on reports page to be dynamic and adds aria
labels to help screen readers
[119](https://github.com/epimorphics/standard-reports-ui/issues/119)
- (Dan) Update the error message for the postcode selectors step 3/7
[120](https://github.com/epimorphics/standard-reports-ui/issues/120)
- (Dan) Update the error message for the postcode selectors step 3/7
[120](https://github.com/epimorphics/standard-reports-ui/issues/120)
- (Dan) Updates step 3/7 to return user input rather than false when user inputs
invalid value
[118](https://github.com/epimorphics/standard-reports-ui/issues/118)
- (Dan) Adds underline text to laning page of standard reports and to help
link[114](https://github.com/epimorphics/standard-reports-ui/issues/114)
- (Dan) Styled the help button to match PPD
[117](https://github.com/epimorphics/standard-reports-ui/issues/117)
- (Dan) Adds more descriptive text to action buttons on the report page
[115](https://github.com/epimorphics/standard-reports-ui/issues/115)

## 1.5.2 - 2023-11-27

Expand All @@ -30,7 +67,8 @@

- (Jon) Updated the `app/controllers/application_controller.rb` to include the
`before_action` for the `change_default_caching_policy` method to ensure the
default `Cache-Control` header for all requests is set to 5 minutes (300 seconds).
default `Cache-Control` header for all requests is set to 5 minutes (300
seconds).

## 1.5.0 - 2023-07-05

Expand All @@ -44,8 +82,8 @@
- (Jon) Keeping with the logging improvements this change rewrites the messages
passed to the logging gem to ensure the included details are simple and
straight to the point. This should also improve the issues reported in
[GH-117](https://github.com/epimorphics/hmlr-linked-data/issues/117) ,
at least from the front-end point of view!
[GH-117](https://github.com/epimorphics/hmlr-linked-data/issues/117) , at
least from the front-end point of view!
- (Jon) Updated the [README](README.md) to include the `API_SERVICE_URL`
variable to ensure the local `standard_reports_manager` instance is used in
the test environment.
Expand Down
5 changes: 3 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ gem 'js-routes', '< 2.0'
gem 'leaflet-rails'
gem 'prometheus-client', '~> 4.0'
gem 'puma'
gem 'puma-metrics'
gem 'responders', '~> 2.0'
gem 'sentry-ruby', '~> 5.2'
gem 'yajl-ruby', require: 'yajl'
Expand Down Expand Up @@ -74,11 +75,11 @@ end
# TODO: While running the rails app locally for testing you can set gems to your local path
# ! These "local" paths do not work with a docker image - use the repo instead
# gem 'json_rails_logger', '~> 1.0.0', path: '~/Epimorphics/shared/json-rails-logger/'
# gem 'lr_common_styles', '~> 1.9.3', path: '~/Epimorphics/clients/land-registry/projects/lr_common_styles/'
# gem 'lr_common_styles', '~> 1.9', '>= 1.9.6', path: '~/Epimorphics/clients/land-registry/projects/lr_common_styles/'
# rubocop:enable Layout/LineLength

# TODO: In production you want to set this to the gem from the epimorphics package repo
source 'https://rubygems.pkg.github.com/epimorphics' do
gem 'json_rails_logger', '~> 1.0.0'
gem 'lr_common_styles', '~> 1.9', '>= 1.9.5'
gem 'lr_common_styles', '~> 1.9', '>= 1.9.6'
end
10 changes: 7 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,11 @@ GEM
psych (4.0.3)
stringio
public_suffix (5.0.0)
puma (5.6.4)
puma (5.6.7)
nio4r (~> 2.0)
puma-metrics (1.2.5)
prometheus-client (>= 0.10)
puma (>= 5.0)
racc (1.7.1)
rack (2.2.7)
rack-test (2.1.0)
Expand Down Expand Up @@ -364,7 +367,7 @@ GEM
json
lograge
railties
lr_common_styles (1.9.5)
lr_common_styles (1.9.6)
bootstrap-sass (~> 3.4.0)
font-awesome-rails (~> 4.7.0.1)
govuk_elements_rails (~> 2.0.0)
Expand Down Expand Up @@ -402,7 +405,7 @@ DEPENDENCIES
json_rails_logger (~> 1.0.0)!
leaflet-rails
libv8-node (>= 16.10.0.0)
lr_common_styles (~> 1.9, >= 1.9.5)!
lr_common_styles (~> 1.9, >= 1.9.6)!
minitest-rails-capybara
minitest-reporters
minitest-spec-rails
Expand All @@ -412,6 +415,7 @@ DEPENDENCIES
modulejs-rails
prometheus-client (~> 4.0)
puma
puma-metrics
rails (< 6.0.0)
responders (~> 2.0)
rubocop
Expand Down
21 changes: 16 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: assets clean image lint publish realclean run tag test vars
.PHONY: assets auth check clean image lint local publish realclean run tag test vars

ACCOUNT?=$(shell aws sts get-caller-identity | jq -r .Account)
ALPINE_VERSION?=3.13
Expand Down Expand Up @@ -28,23 +28,27 @@ REPO?=${ECR}/${IMAGE}
GITHUB_TOKEN=.github-token
BUNDLE_CFG=.bundle/config

all: image

${BUNDLE_CFG}: ${GITHUB_TOKEN}
@./bin/bundle config set --local rubygems.pkg.github.com ${GPR_OWNER}:`cat ${GITHUB_TOKEN}`

${GITHUB_TOKEN}:
@echo ${PAT} > ${GITHUB_TOKEN}

assets:
@./bin/bundle config set --local without 'development'
all: image

assets: auth
@./bin/bundle config set --local without 'development test'
@./bin/bundle install
@./bin/rails assets:clean assets:precompile

auth: ${GITHUB_TOKEN} ${BUNDLE_CFG}

check: lint test
@echo "All checks passed."

clean:
@[ -d public/assets ] && ./bin/rails assets:clobber || :
@@ rm -rf bundle coverage log node_modules

image: auth
@echo Building ${REPO}:${TAG} ...
Expand All @@ -64,6 +68,12 @@ image: auth
lint: assets
@./bin/bundle exec rubocop

local:
@echo "Installing all packages ..."
@./bin/bundle install
@echo "Starting local server ..."
@./bin/rails server -p ${PORT}

publish: image
@echo Publishing image: ${REPO}:${TAG} ...
@docker push ${REPO}:${TAG} 2>&1
Expand All @@ -88,6 +98,7 @@ tag:
@echo ${TAG}

test: assets
@echo "Running tests ..."
@./bin/rails test

vars:
Expand Down
Loading

0 comments on commit 4c17e20

Please sign in to comment.