question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support to monitoring performances

See original GitHub issue

Feature request

Is your feature request related to a problem?

I’m migrating an application to Next.js and one requirement that we have is to be able to monitor the application (using Prometheus for example). Here are 2 examples of metrics that could make sense:

  • rendering time: how long does the app takes to render (once data is ready). Useful to track the evolution of the complexity of the tree.
  • data-fetching time: how long do we wait for the data. Useful to track how our dependencies behave. This would basically measure the time spent in the _app.js getInitialProps().

Describe the solution you’d like

I think this would require the developer to use the custom server approach: we could provide a few new options on the const app = next({ dev }) call.

Options proposal:

  • onRenderStart or beforeRender
  • onRenderEnd or afterRender
  • onGetInitialPropsStart or beforeGetInitialProps
  • onGetInitialPropsEnd or afterGetInitialProps

All the options above would be callbacks called at the right time. They could also be grouped inside a single timings option maybe.

One thing to consider as well is that a timer started in a start/before callback needs to be stopped in the end/after one. This means we need to have a context shared between those…

One other way that could enable this context could be to return the end function:


next({
  onRender: () => {
    const endTimer = timer.start()
    return () => endTimer()
  }
})

Describe alternatives you’ve considered

I don’t have other ideas in my mind so far as I’m still beginning with using Next.js, I’m probably lacking a wider vision.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
timneutkenscommented, Aug 10, 2019

The specific PR is client-only but there’s more coming.

1reaction
Janpotcommented, Jun 5, 2019

Yes, one could definitely imagine more powerful hooks. I’m just putting it on the table as a low config alternative, that uses already available standards.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add support to monitoring performances · Issue #7499 - GitHub
I'm migrating an application to Next.js and one requirement that we have is to be able to monitor the application (using Prometheus for...
Read more >
Configure Performance Monitoring | Microsoft Learn
To configure performance monitoring for AD FS using Performance Monitor · On the Start screen, type Performance Monitor, and then press ENTER.
Read more >
Get started with Performance Monitoring for Android - Firebase
Step 1: Add the Performance Monitoring SDK to your app · Step 2: Add the Performance Monitoring Gradle plugin to your app ·...
Read more >
Monitoring performance | Android Developers
Firebase Performance Monitoring is a service that helps you to gain insight into the performance characteristics of your app.
Read more >
Application Performance Monitoring | New Relic
Analyze 100% of tracing telemetry across your system—no additional infrastructure required. · Instantly visualize the path of any service request so you can ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found