Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

feat(metrics): switch to fastify-metrics #1034

Merged
merged 2 commits into from
Jun 26, 2023
Merged

Conversation

JAdshead
Copy link
Contributor

Description

Reverts the custom request route metric and replaces with fastify-metrics

This includes metrics for the following, grouped by registered route and status code:

metric labels description
http_request_duration_seconds_count method, route, status_code Requests total count
http_request_duration_seconds_bucket method, route, status_code Requests durations by bucket
http_request_summary_seconds method, route, status_code Requests duration percentiles
http_request_summary_seconds_count method, route, status_code Requests total count

Example:

# TYPE http_request_duration_seconds histogram
http_request_duration_seconds_bucket{le="0.005",method="GET",route="/*",status_code="200"} 0
http_request_duration_seconds_bucket{le="0.01",method="GET",route="/*",status_code="200"} 1
http_request_duration_seconds_bucket{le="0.025",method="GET",route="/*",status_code="200"} 3
http_request_duration_seconds_bucket{le="0.05",method="GET",route="/*",status_code="200"} 3
http_request_duration_seconds_bucket{le="0.1",method="GET",route="/*",status_code="200"} 4
http_request_duration_seconds_bucket{le="0.25",method="GET",route="/*",status_code="200"} 4
http_request_duration_seconds_bucket{le="0.5",method="GET",route="/*",status_code="200"} 4
http_request_duration_seconds_bucket{le="1",method="GET",route="/*",status_code="200"} 4
http_request_duration_seconds_bucket{le="2.5",method="GET",route="/*",status_code="200"} 4
http_request_duration_seconds_bucket{le="5",method="GET",route="/*",status_code="200"} 4
http_request_duration_seconds_bucket{le="10",method="GET",route="/*",status_code="200"} 4
http_request_duration_seconds_bucket{le="+Inf",method="GET",route="/*",status_code="200"} 4
http_request_duration_seconds_sum{method="GET",route="/*",status_code="200"} 0.092516233
http_request_duration_seconds_count{method="GET",route="/*",status_code="200"} 4
http_request_duration_seconds_bucket{le="0.005",method="GET",route="/_/static/*",status_code="200"} 2
http_request_duration_seconds_bucket{le="0.01",method="GET",route="/_/static/*",status_code="200"} 7
http_request_duration_seconds_bucket{le="0.025",method="GET",route="/_/static/*",status_code="200"} 12
http_request_duration_seconds_bucket{le="0.05",method="GET",route="/_/static/*",status_code="200"} 20
http_request_duration_seconds_bucket{le="0.1",method="GET",route="/_/static/*",status_code="200"} 20
http_request_duration_seconds_bucket{le="0.25",method="GET",route="/_/static/*",status_code="200"} 20
http_request_duration_seconds_bucket{le="0.5",method="GET",route="/_/static/*",status_code="200"} 20
http_request_duration_seconds_bucket{le="1",method="GET",route="/_/static/*",status_code="200"} 20
http_request_duration_seconds_bucket{le="2.5",method="GET",route="/_/static/*",status_code="200"} 20
http_request_duration_seconds_bucket{le="5",method="GET",route="/_/static/*",status_code="200"} 20
http_request_duration_seconds_bucket{le="10",method="GET",route="/_/static/*",status_code="200"} 20
http_request_duration_seconds_bucket{le="+Inf",method="GET",route="/_/static/*",status_code="200"} 20
http_request_duration_seconds_sum{method="GET",route="/_/static/*",status_code="200"} 0.417883017
http_request_duration_seconds_count{method="GET",route="/_/static/*",status_code="200"} 20

Motivation and Context

Improved http request metrics.

How Has This Been Tested?

Test suite and locally.

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (adding or updating documentation)
  • Dependency update
  • Security update

Checklist:

  • My change requires a change to the documentation and I have updated the documentation accordingly.
  • These changes should be applied to a maintenance branch.
  • This change requires cross browser checks.
  • Performance tests should be ran against the server prior to merging.
  • This change impacts caching for client browsers.
  • This change impacts HTTP headers.
  • This change adds additional environment variable requirements for One App users.
  • I have added the Apache 2.0 license header to any new files created.

What is the Impact to Developers Using One App?

@github-actions
Copy link
Contributor

github-actions bot commented Jun 23, 2023

Size Change: 0 B

Total Size: 687 kB

ℹ️ View Unchanged
Filename Size
./build/app/app.js 164 kB
./build/app/app~vendors.js 389 kB
./build/app/runtime.js 7.07 kB
./build/app/service-worker-client.js 7.26 kB
./build/app/vendors.js 120 kB

compressed-size-action

@JAdshead JAdshead requested a review from a team June 23, 2023 22:17
@@ -68,6 +68,11 @@ export async function createApp(opts = {}) {
fastify.register(ensureCorrelationId);
fastify.register(fastifyCookie);
fastify.register(logging);
fastify.register(fastifyMetrics, {
defaultMetrics: { enabled: false },
endpoint: null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we set endpoint to null? how exactly does this change how some one will retrieve the metrics itself? im assuming none but still wondering

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is already a separate metrics server running. this disables the plugin from adding metrics routes to the main one app server

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotcha makes sense

@JAdshead JAdshead requested a review from a team June 26, 2023 15:54
@JAdshead JAdshead requested a review from a team June 26, 2023 18:05
@JAdshead JAdshead mentioned this pull request Jun 26, 2023
14 tasks
@JAdshead JAdshead merged commit b531606 into main Jun 26, 2023
@JAdshead JAdshead deleted the feat/fastify-metrics branch June 26, 2023 18:16
@JAdshead JAdshead mentioned this pull request Jun 29, 2023
14 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants