Add a threshold $setting

Created on 2 July 2024, 5 months ago
Updated 4 July 2024, 5 months ago

I wanted to keep this module running but not to bloat the watchdog table with unnecessary low memory profiling, so I thought of adding a threshold. While this can be made a config, as this is a more low-level module I did it simpler with the use of $settings.

✨ Feature request
Status

Needs review

Version

2.0

Component

Code

Created by

🇦🇷Argentina hanoii 🇦🇷UTC-3

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @hanoii
  • Merge request !5Resolve #3458629 "Add a threshold" → (Open) created by hanoii
  • Status changed to Needs review 5 months ago
  • 🇦🇷Argentina hanoii 🇦🇷UTC-3

    MR!5 is a simple addition to the code.

  • 🇧🇷Brazil renatog Campinas

    Great, thanks @hanoii

    P.S. I think the category should be Feature Request instead of Support, right?

  • 🇦🇷Argentina hanoii 🇦🇷UTC-3

    Yes, I accidentally selected support. After using this, making it a $setting is even better than a config because it allows for dynamic configurations on settings.php.

    i.e.

    $settings['memory_profiler_threshold'] = 120;
    
    // Admin paths
    $admin_paths = [
      '/knowledgebase/admin',
      '/knowledgebase/node/add',
      '/knowledgebase/node/%node/edit',
    ];
    foreach ($admin_paths as $path) {
      if (strpos($current_path, $path) === 0) {
        ini_set('memory_limit', '256M');
        $settings['memory_profiler_threshold'] = 240;
      }
    }
    
    $high_memory_paths = [
      '/knowledgebase/metrics',
    ];
    foreach ($high_memory_paths as $path) {
      if (strpos($current_path, $path) === 0) {
        ini_set('memory_limit', '512M');
        $settings['memory_profiler_threshold'] = 500;
      }
    }
    
    
Production build 0.71.5 2024