feat: Add CPU profiling feature with multi-language support#112
Conversation
Implements CPU profiling infrastructure to capture high CPU usage lines from test scenarios (URLs, test commands, or server runs). This is the foundation for carbon tracking scenarios (#71). Features: - Multi-language profiler adapters (Python, Node.js, Ruby, Go) - Unified JSON format for profiler output - CLI command: carbonara profile with --url, --test, --server options - VS Code integration with diagnostics compatible with semgrep - Database storage in assessment_data table (tool_name: cpu-profiler) - Code snippets for easy profiling setup in VS Code - Comprehensive unit and integration tests The profiler captures CPU hotspot lines and stores them in the same assessment database, enabling future carbon emission calculations based on CPU time and machine specifications. Related: #71
- Add timeoutSeconds parameter to executeCommand method - Update all adapter calls to pass duration/timeout values - Add test-results/ to .gitignore - Update test script to run build before tests to catch TS errors This ensures TypeScript compilation errors are caught during test runs and prevents issues from reaching CI.
- Replace inquirer with @inquirer/prompts (matches existing CLI pattern) - Update prompt API to use select and input functions - Change detectLanguage return type from null to undefined - Add missing CpuProfileLine type import - Add type annotations for forEach callback parameters - Add type assertions for scenario type strings Fixes TypeScript compilation errors in CI build.
- Fix getCpuProfilerDiagnostics to spread readonly array into mutable array - DiagnosticCollection.get() returns readonly Diagnostic[] which cannot be directly returned as mutable Diagnostic[] Fixes TypeScript compilation error in VS Code extension build.
pessi-v
left a comment
There was a problem hiding this comment.
I clicked around a bit. I got some things to run on the CLI, but it's a bit unclear what it's doing and what it's reporting.
The VSCode part I didn't get to work, like, there is no menu item to run this?
Thanks, yes i think this is not fully done yet. There are two options I researched, one was to start a pyroscope / grafana server and then for each programming language there is some exporter. The other one was to use the native profilers @pessi-v I thought requiring the user to start a server might not be the best, but if you think that's ok we could do that too - so i tried the other way. |
Implements CPU profiling infrastructure to capture high CPU usage lines from test scenarios (URLs, test commands, or server runs). This is the foundation for carbon tracking scenarios (#71).
Features:
The profiler captures CPU hotspot lines and stores them in the same assessment database, enabling future carbon emission calculations based on CPU time and machine specifications.
Related: #71
Closes: #58