grafana / grafana/pyroscope-nodejs

Add profile processing option to Express middleware for improved function naming

Open
#88 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
51
Forks
36
PR merge metrics
No merged PRs in 30d

Description

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](https://grafana.com/docs/pyroscope/latest/configure-client/language-sdks/nodejs/) 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 #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:

```javascript
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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.