A metric for the number of comments is useful for monitoring.

Example output:

# HELP drupal_comment_count_total Provides metrics for comment counts.
# TYPE drupal_comment_count_total gauge
drupal_comment_count_total 2
drupal_comment_count_total{status="not published"} 1
drupal_comment_count_total{status="published"} 1

Comments

kim.pepper created an issue. See original summary.

kim.pepper’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new6.49 KB

Adds a comment count plugin.

kim.pepper’s picture

StatusFileSize
new6.52 KB
new703 bytes

Add a test group.

kim.pepper’s picture

StatusFileSize
new9.5 KB
new2.02 KB

Fixes an issue with missing config on install.

kim.pepper’s picture

Status: Needs review » Needs work

Feedback from @larowlan on the config install change is that we should do that in the parent module.

kim.pepper’s picture

Status: Needs work » Needs review
StatusFileSize
new12.92 KB
new7.48 KB

Added prometheus_exporter_modules_installed() to add some default config when new modules are enabled.

larowlan’s picture

looks good to me

  • kim.pepper committed e9bce8f on 8.x-1.x
    Issue #3135682 by kim.pepper, larowlan: Add a comment count plugin
    
kim.pepper’s picture

Status: Needs review » Fixed

Committed and pushed to 8.x-1.x. Thanks!

mmbk’s picture

Status: Fixed » Needs work
+++ b/prometheus_exporter.module
@@ -18,3 +18,15 @@ function prometheus_exporter_modules_uninstalled($modules, $is_syncing) {
+
+/**
+ * Implements hook_modules_installed().
+ */
+function prometheus_exporter_modules_installed($modules, $is_syncing) {
+  // @todo replace with $is_syncing once 8.9.x is released.
+  if (!\Drupal::service('config.installer')->isSyncing()) {
+    /** @var \Drupal\prometheus_exporter\MetricsCollectorManager $collector_manager */
+    $collector_manager = \Drupal::service('prometheus_exporter.metrics_collector_manager');
+    $collector_manager->syncPluginConfig();
+  }
+}

This fails with Core 8.8.6 as the second parameter is not defined.

The prototype in core/lib/Drupal/Core/Extension/module.api.php (8.8.6) is not defining the paramater $is_syncing

/**
 * Perform necessary actions after modules are installed.
 *
 * This function differs from hook_install() in that it gives all other modules
 * a chance to perform actions when a module is installed, whereas
 * hook_install() is only called on the module actually being installed. See
 * \Drupal\Core\Extension\ModuleInstaller::install() for a detailed description of
 * the order in which install hooks are invoked.
 *
 * This hook should be implemented in a .module file, not in an .install file.
 *
 * @param $modules
 *   An array of the modules that were installed.
 *
 * @see \Drupal\Core\Extension\ModuleInstaller::install()
 * @see hook_install()
 */
function hook_modules_installed($modules) {

As a result an im port of an existing configuration (and probably a 'drush en prometheus_exporter_MODULE' ) fails with

$ drush cim sync
+------------+------------------------------+-----------+
| Collection | Config                       | Operation |
+------------+------------------------------+-----------+
|            | core.extension               | Update    |
|            | prometheus_exporter.settings | Update    |
|            | smtp.settings                | Update    |
+------------+------------------------------+-----------+

 Import the listed configuration changes? (yes/no) [yes]:
 > 

ArgumentCountError: Too few arguments to function prometheus_exporter_modules_installed(), 1 passed and exactly 2 expected in /srv/httpd/d3ug/htdocs/modules/prometheus_exporter/prometheus_exporter.module on line 25 #0 [internal function]: prometheus_exporter_modules_installed(Array)
kim.pepper’s picture

Status: Needs work » Fixed

Please create a new issue instead of re-opening fixed ones.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.