]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
gpu_sysman: skip common metric prefix in metrics logging
authorEero Tamminen <eero.t.tamminen@intel.com>
Fri, 23 Feb 2024 13:32:33 +0000 (15:32 +0200)
committerEero Tamminen <eero.t.tamminen@intel.com>
Wed, 28 Feb 2024 15:21:09 +0000 (17:21 +0200)
Signed-off-by: Eero Tamminen <eero.t.tamminen@intel.com>
src/gpu_sysman.c

index 84bb57debb32b1752716986307e0d26a7c5b3bac..babf0221ca93a301009a46cee3939c797b4922ef 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * collectd - src/gpu_sysman.c
  *
- * Copyright(c) 2020-2023 Intel Corporation. All rights reserved.
+ * Copyright(c) 2020-2024 Intel Corporation. All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -775,13 +775,21 @@ static int gpu_init(void) {
  * Resets metric family after dispatch */
 static void gpu_submit(gpu_device_t *gpu, metric_family_t *fam) {
   struct timespec ts;
+  /* cdtime() is not monotonic */
   clock_gettime(CLOCK_MONOTONIC, &ts);
+
   const char *pci_bdf = gpu->pci_bdf;
   /* logmetrics readability: skip common BDF address prefix */
-  if (strncmp("0000:", pci_bdf, 5) == 0) {
+  if (strncmp(pci_bdf, "0000:", 5) == 0) {
     pci_bdf += 5;
   }
 
+  const char *name = fam->name;
+  /* logmetrics readability: skip common metric prefix */
+  if (strncmp(name, METRIC_PREFIX, strlen(METRIC_PREFIX)) == 0) {
+    name += strlen(METRIC_PREFIX);
+  }
+
   for (size_t i = 0; i < fam->metric.num; i++) {
     metric_t *m = fam->metric.ptr + i;
 
@@ -797,7 +805,7 @@ static void gpu_submit(gpu_device_t *gpu, metric_family_t *fam) {
         }
       }
       INFO("[%7ld.%03ld] %s: %s / %s [%ld]: %.3f", ts.tv_sec,
-           ts.tv_nsec / 1000000, pci_bdf, fam->name, type, i,
+           ts.tv_nsec / 1000000, pci_bdf, name, type, i,
            fam->type == METRIC_TYPE_COUNTER ? m->value.counter
                                             : m->value.gauge);
     }