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

Add profile processing option to Express middleware for improved function naming #88

Open
harshrai654 opened this issue Jul 10, 2024 · 0 comments

Comments

@harshrai654
Copy link

harshrai654 commented Jul 10, 2024

Hi,
Currently, the ContinuousProfiler includes profile processing functionality. We propose extending this capability to the Express middleware by introducing a configuration option that utilizes the processProfile utility function.

Key points:

  1. New Configuration Option:

    • Introduce a config option in the Express middleware to enable profile processing.
    • This would leverage the existing processProfile utility function.
  2. Documentation Update:

    • The current documentation for pull mode with Express middleware is incomplete.
    • The NodeJS SDK documentation only mentions pull mode with Grafana Alloy or Grafana Agent.
    • We should add detailed instructions for using pull mode with Express middleware.
  3. Improved Function Naming:

    • This feature would be particularly beneficial for scenarios involving anonymous functions.
    • Instead of generic "anonymous function" labels in the profile output, users would see filenames, enhancing debuggability.
    • This improvement is inspired by the discussion in issue Restore fileName to anonymous function names #84.
  4. Real-world Use Case:

    • Our team encountered this need and believes it could be generally useful.

    • As a temporary solution, we patched the middleware to call the processProfile utility function:

      async function collectProfile(profiler) {
          const profile = profiler.profile().profile;
          const processedProfile = processProfile(profile)
          profiler.stop();
          return encode(processedProfile);
      }
    • This workaround functions correctly with pull mode.

By implementing this feature, we can enhance the profiling capabilities of the Express middleware, providing more detailed and useful information to users, especially in scenarios involving anonymous functions.

I am more than happy to implement this feature and contribute to the project if needed. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant