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

Improve and enhance the web service #5

Merged
merged 5 commits into from
Aug 6, 2024
Merged

Conversation

jonathanio
Copy link
Contributor

Add a number of enhancements to the web services to make it easier to work with and develop, including:

  • Skipping logs for all internal health endpoints: /alive, /healthz, and /metrics, as there is no need to report on these for backend analysis.
  • Add support for count and duration metrics for Prometheus, and add the /metrics endpoints to report those.
  • Refactor the cobra and viper configurations into the init() function for each cmd so that configuration files, environments, and command-line arguments are combined into single blocks, and changes in one are not lost from another.

Checklist

Before raising or requesting a review of the pull request, please check and confirm the following items have been performed, where possible:

  • I have performed a self-review of my code and run any tests locally to check
  • I have added tests that prove that any changes are effective and work correctly
  • I have made corresponding changes, as needed, to the repository documentation
  • Each commit in, and this pull request, have meaningful subjects and bodies for context
  • I have added release/..., type/..., and changes/... labels, as needed, to this pull request

@jonathanio jonathanio added release/update An update to an existing feature is made with this pull request type/enhancement Adding or requesting a new feature update/github-workflows Update with changes to GitHub Workflows update/go Update with changes to Go files or applications labels Aug 6, 2024
@jonathanio jonathanio self-assigned this Aug 6, 2024
Fix all references for hostname to address in the configuration to merge
on the standard of address for binding the server.
Add filters for slog-gin which ignores /alive and /healthz endpoints for
standard access logging. Additionally, don't log 404 and 401 messages as
these don't provide significant value.
Add an initial middleware function, and map the default handler, for
Prometheus into the web service, allowing monitoring of the requests
made against the service and the latency.
Refactor the configuration processing to conbine the cobra and viper
code, setting the command-line flags alongside the configuration file
and environment settings. This should make it easier to build and manage
the two components for configuration the application together.
Split the testing and the code analysis tasks into separate groups and
allow the build take to take priority over the code analysis, allowing
for faster local development.
@jonathanio jonathanio force-pushed the improve-web-service branch from 42e1ba0 to 48a1b49 Compare August 6, 2024 20:53
Copy link

codecov bot commented Aug 6, 2024

Codecov Report

Attention: Patch coverage is 0% with 63 lines in your changes missing coverage. Please review.

Project coverage is 15.10%. Comparing base (c06ff4c) to head (48a1b49).

Files Patch % Lines
internal/serve/main.go 0.00% 27 Missing ⚠️
internal/cmd/serve.go 0.00% 25 Missing ⚠️
internal/cmd/root.go 0.00% 6 Missing ⚠️
internal/cmd/send.go 0.00% 3 Missing ⚠️
internal/serve/metrics/main.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main       #5      +/-   ##
==========================================
- Coverage   16.44%   15.10%   -1.35%     
==========================================
  Files          14       13       -1     
  Lines         304      331      +27     
==========================================
  Hits           50       50              
- Misses        254      281      +27     
Flag Coverage Δ
unit-tests 15.10% <0.00%> (-1.35%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
internal/serve/metrics/main.go 0.00% <0.00%> (ø)
internal/cmd/send.go 0.00% <0.00%> (ø)
internal/cmd/root.go 0.00% <0.00%> (ø)
internal/cmd/serve.go 0.00% <0.00%> (ø)
internal/serve/main.go 0.00% <0.00%> (ø)

@jonathanio jonathanio merged commit d70f651 into main Aug 6, 2024
8 of 10 checks passed
@jonathanio jonathanio deleted the improve-web-service branch August 6, 2024 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release/update An update to an existing feature is made with this pull request type/enhancement Adding or requesting a new feature update/github-workflows Update with changes to GitHub Workflows update/go Update with changes to Go files or applications
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant