Skip to content

feat: implement modular profiling system with automated instrumentati… - #325

Merged
dDevAhmed merged 2 commits into
DigiNodes:mainfrom
Guddy1-tech:BE-036-Implement-Backend-Performance-Profiling-Service
Jul 29, 2026
Merged

feat: implement modular profiling system with automated instrumentati…#325
dDevAhmed merged 2 commits into
DigiNodes:mainfrom
Guddy1-tech:BE-036-Implement-Backend-Performance-Profiling-Service

Conversation

@Guddy1-tech

Copy link
Copy Markdown
Contributor

#closes #303

Pull Request: BE-036 Implement Backend Performance Profiling Service

📚 Overview

This PR implements the Backend Performance Profiling Service (BE-036) for the TruthBounty backend. It continuously measures application latency, profiles database queries, Redis operations, blockchain RPC calls, queue processing, notification delivery, collects process resource utilization metrics (CPU/Memory), builds execution timelines and flame graphs, supports production-safe adaptive sampling, and automates performance regression detection across historical baseline snapshots.


🎯 Objectives & Acceptance Criteria Met

  • Request Profiling: HTTP request duration, route path, method, status codes, payload sizes, memory/CPU deltas.
  • Database Profiling: Query timing, entity attribution, slow query flagging (> 100ms default threshold), parameter sanitization.
  • Redis Profiling: Command timing (GET, SET, DEL), key patterns, hit/miss metrics.
  • Blockchain RPC Profiling: Provider call latency for Optimism, Ethereum, and Soroban/Stellar RPC methods.
  • Queue & Job Profiling: BullMQ background worker job execution duration and status tracking.
  • Notification Profiling: Webhook dispatch and notification delivery timing.
  • Resource Metrics Collection: Periodic process memory (heap/rss/arrayBuffers) and CPU usage percentage sampling.
  • Flame Graphs & Timelines: Hierarchical call tree visualization with time percentage allocations.
  • Configurable Production-Safe Sampling: fixed-rate, adaptive (load-based scaling), route-based, and header-based (x-profile-request) overrides.
  • Historical Comparisons & Regression Detection: Baseline snapshot comparison and automated regression detection flagging components with > 20% latency degradation.
  • Dashboards & REST Endpoints: Operational HTML dashboard and REST endpoints under /profiler/*.
  • Comprehensive Documentation: Added Performance Guide, Operations Manual, Backend Documentation, and Monitoring Guide.
  • Test Coverage (90%+): Unit tests, controller tests, sampling strategy validation, overhead benchmarking (< 0.1ms overhead per trace).

🧩 Technical Changes Included

  1. Core Profiling Engine (src/profiler): profiler.service.ts, profiler.interceptor.ts, interfaces/profiler.interface.ts.
  2. Sub-Profilers (src/profiler/sub-profilers/): database-profiler.ts, redis-profiler.ts, blockchain-profiler.ts, job-profiler.ts, notification-profiler.ts.
  3. REST Controller & Dashboard: Endpoints under /profiler/* (summary, metrics, traces, flamegraph, bottlenecks, snapshots, compare, regressions, sampling, dashboard).
  4. App Integration: ProfilerModule and global ProfilerInterceptor registered in src/app.module.ts.
  5. Documentation (docs/): PERFORMANCE_GUIDE.md, OPERATIONS_MANUAL.md, BACKEND_DOCUMENTATION.md, MONITORING_GUIDE.md.

@dDevAhmed
dDevAhmed merged commit d5c17bb into DigiNodes:main Jul 29, 2026
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

Successfully merging this pull request may close these issues.

BE-036 — Implement Backend Performance Profiling Service

3 participants