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

feat(server): add SSR React rendering summary metric #991

Merged
merged 8 commits into from
Jun 14, 2023

Conversation

PixnBits
Copy link
Contributor

@PixnBits PixnBits commented May 4, 2023

Description

Add a oneapp_ssr_react_rendering_seconds summary metric split by renderMethodName label.

Motivation and Context

Server-Side Rendering (SSR) can be resource intensive. It is useful to operators to know a bit more about the time taken to render the HTML via React.

How Has This Been Tested?

Run locally, comparing manual timers (process.hrtime.bigint) to the values visible in http://localhost:3005/metrics.

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?

DevOps has more telemetry to track server utilization to aid SSR efficiency in modules and possible server scaling.

@github-actions
Copy link
Contributor

github-actions bot commented May 4, 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

@github-actions
Copy link
Contributor

github-actions bot commented May 8, 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

@PixnBits PixnBits marked this pull request as ready for review May 8, 2023 20:44
@PixnBits PixnBits requested review from a team as code owners May 8, 2023 20:44
@PixnBits
Copy link
Contributor Author

PixnBits commented May 8, 2023

https://github.com/americanexpress/one-app/actions/runs/4919317274/jobs/8786780018?pr=991 appears to be unrelated to the changes made?

const ssrNamespace = createMetricNamespace('ssr');

createSummary({
name: ssrNamespace('react_rendering', 'seconds'),
Copy link
Member

Choose a reason for hiding this comment

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

are we tracking this in seconds or miliseconds?

Copy link
Contributor Author

@PixnBits PixnBits May 9, 2023

Choose a reason for hiding this comment

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

seconds is the base unit of time for metrics:
https://prometheus.io/docs/practices/naming/#base-units
from what I can tell they attempt to follow SI https://en.wikipedia.org/wiki/International_System_of_Units
side note: Grafana is used by a lot of different teams, at least one rocket company uses it for their launches (Astra, IIRC)

@PixnBits
Copy link
Contributor Author

PixnBits commented May 9, 2023

https://github.com/americanexpress/one-app/actions/runs/4919317274/jobs/8786780018?pr=991 appears to be unrelated to the changes made?

Yeah: #994


function createSummary(opts) {
const { name } = opts;
if (summaries[name]) {
Copy link
Member

Choose a reason for hiding this comment

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

this is great for safety but it's hidden, we should instead throw an error as in startSummaryTimer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤔 mirrors counters.js & gauges.js, maybe a subsequent PR?

Copy link
Member

Choose a reason for hiding this comment

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

ok not a big deal but would be cleaner


const ssrNamespace = createMetricNamespace('ssr');

createSummary({
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't the user call this function?

Copy link
Contributor Author

@PixnBits PixnBits Jun 8, 2023

Choose a reason for hiding this comment

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

user?
FWIW following the existing pattern, i.e. src/server/metrics/holocron.js and src/server/utils/pollModuleMap.js
there might be a better way of managing the metrics, but IMO would be best to do that refactor in a different PR rather than block this metric?

Copy link
Member

Choose a reason for hiding this comment

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

by user i mean the entity consuming it (in this case, the dev). If we are following a pattern then ok we could improve the code later

@JAdshead JAdshead merged commit 3e24352 into main Jun 14, 2023
@JAdshead JAdshead deleted the feature/ssr-metrics branch June 14, 2023 16:24
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.

4 participants