Skip to content

in_windows_exporter_metrics: Implement user-defined performance counters w/ PDH#12006

Open
cosmo0920 wants to merge 1 commit into
masterfrom
cosmo0920-implement-user-defined-windows-metrics-with-performance-counters
Open

in_windows_exporter_metrics: Implement user-defined performance counters w/ PDH#12006
cosmo0920 wants to merge 1 commit into
masterfrom
cosmo0920-implement-user-defined-windows-metrics-with-performance-counters

Conversation

@cosmo0920

@cosmo0920 cosmo0920 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

In the current implementation of windows exporter metrics, we do not provide user-defined PerformanceCounter query capability.
So, it'll be useful to define an arbitrary query not to be implemented by default.


Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • Example configuration file for the change
[SERVICE]
    flush_interval 3
    HTTP_Server On
    HTTP_Port 2020
    Log_Level debug

[INPUT]
    Name    windows_exporter_metrics
    Tag     windows
    Scrape_Interval  2
    Metrics cpu,logical_disk,memory,performancecounter

    # Example: custom Performance Counters
    PerformanceCounter process_fluent_bit_thread_count=\Process(fluent-bit)\Thread Count
    PerformanceCounter gpu_3d_utilization=\GPU Engine(*engtype_3D)\Utilization Percentage
    PerformanceCounter gpu_copy_utilization=\GPU Engine(*engtype_Copy)\Utilization Percentage
    PerformanceCounter gpu_video_decode_utilization=\GPU Engine(*engtype_VideoDecode)\Utilization Percentage

[OUTPUT]
    Name stdout
  • Debug log output from testing the change
Fluent Bit v5.0.8
* Copyright (C) 2015-2026 The Fluent Bit Authors
* Fluent Bit is a CNCF graduated project under the Fluent organization
* https://fluentbit.io

______ _                  _    ______ _ _           _____  _____
|  ___| |                | |   | ___ (_) |         |  ___||  _  |
| |_  | |_   _  ___ _ __ | |_  | |_/ /_| |_  __   _|___ \ | |/' |
|  _| | | | | |/ _ \ '_ \| __| | ___ \ | __| \ \ / /   \ \|  /| |
| |   | | |_| |  __/ | | | |_  | |_/ / | |_   \ V //\__/ /\ |_/ /
\_|   |_|\__,_|\___|_| |_|\__| \____/|_|\__|   \_/ \____(_)\___/


[2026/06/26 17:03:04.236] [ info] Configuration:
[2026/06/26 17:03:04.236] [ info]  flush time     | 1.000000 seconds
[2026/06/26 17:03:04.236] [ info]  grace          | 5 seconds
[2026/06/26 17:03:04.236] [ info]  daemon         | 0
[2026/06/26 17:03:04.236] [ info] ___________
[2026/06/26 17:03:04.236] [ info]  inputs:
[2026/06/26 17:03:04.236] [ info]      windows_exporter_metrics
[2026/06/26 17:03:04.236] [ info] ___________
[2026/06/26 17:03:04.236] [ info]  filters:
[2026/06/26 17:03:04.236] [ info] ___________
[2026/06/26 17:03:04.236] [ info]  outputs:
[2026/06/26 17:03:04.236] [ info]      stdout.0
[2026/06/26 17:03:04.236] [ info] ___________
[2026/06/26 17:03:04.236] [ info]  collectors:
[2026/06/26 17:03:04.238] [ info] [fluent bit] version=5.0.8, commit=d4e7541139, pid=180644
[2026/06/26 17:03:04.238] [debug] [engine] maxstdio set: 512
[2026/06/26 17:03:04.238] [debug] [engine] coroutine stack size: 98302 bytes (96.0K)
[2026/06/26 17:03:04.238] [ info] [storage] ver=1.5.4, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2026/06/26 17:03:04.239] [ info] [simd    ] SSE2
[2026/06/26 17:03:04.239] [ info] [cmetrics] version=2.1.5
[2026/06/26 17:03:04.239] [ info] [ctraces ] version=0.7.1
[2026/06/26 17:03:04.239] [ info] [input:windows_exporter_metrics:windows_exporter_metrics.0] initializing
[2026/06/26 17:03:04.239] [ info] [input:windows_exporter_metrics:windows_exporter_metrics.0] storage_strategy='memory' (memory only)
[2026/06/26 17:03:04.239] [debug] [windows_exporter_metrics:windows_exporter_metrics.0] created event channels: read=780 write=784
[2026/06/26 17:03:04.314] [debug] [input:windows_exporter_metrics:windows_exporter_metrics.0] enabled metrics cpu
[2026/06/26 17:03:04.314] [debug] [input:windows_exporter_metrics:windows_exporter_metrics.0] enabled metrics logical_disk
[2026/06/26 17:03:04.314] [debug] [input:windows_exporter_metrics:windows_exporter_metrics.0] enabled metrics memory
[2026/06/26 17:03:04.314] [debug] [input:windows_exporter_metrics:windows_exporter_metrics.0] enabled metrics performancecounter
[2026/06/26 17:03:04.673] [debug] [stdout:stdout.0] created event channels: read=1132 write=1136
[2026/06/26 17:03:04.675] [ info] [output:stdout:stdout.0] worker #0 started
[2026/06/26 17:03:04.675] [ info] [http_server] listen iface=0.0.0.0 tcp_port=2020
[2026/06/26 17:03:04.676] [ info] [sp] stream processor started
[2026/06/26 17:03:04.676] [ info] [engine] Shutdown Grace Period=5, Shutdown Input Grace Period=2
[2026/06/26 17:03:06.683] [debug] [input:windows_exporter_metrics:windows_exporter_metrics.0] initializing WMI instance....
[2026/06/26 17:03:06.716] [debug] [input:windows_exporter_metrics:windows_exporter_metrics.0] deinitializing WMI instance....
[2026/06/26 17:03:07.676] [debug] [task] created task=00000276559C2230 id=0 OK
[2026/06/26 17:03:07.676] [debug] [output:stdout:stdout.0] task_id=0 assigned to thread #0
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,0",state="c1"} = 9295.8910732000004
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,0",state="c2"} = 208.55313200000001
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,0",state="c3"} = 137219.84215790001
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,1",state="c1"} = 13442.286695700001
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,1",state="c2"} = 272.55754489999998
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,1",state="c3"} = 136962.5192066
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,2",state="c1"} = 18363.891972599999
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,2",state="c2"} = 130.2987411
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,2",state="c3"} = 140891.89595420001
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,3",state="c1"} = 18394.690231299999
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,3",state="c2"} = 146.87673810000001
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,3",state="c3"} = 140614.4917019
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,4",state="c1"} = 18393.324182699998
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,4",state="c2"} = 130.91331339999999
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,4",state="c3"} = 140901.0956615
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,5",state="c1"} = 18356.969965600001
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,5",state="c2"} = 113.67996549999999
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,5",state="c3"} = 141123.31954900001
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,6",state="c1"} = 17327.0885958
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,6",state="c2"} = 219.56994119999999
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,6",state="c3"} = 139757.0300653
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,7",state="c1"} = 17522.962978299998
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,7",state="c2"} = 180.63305130000001
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,7",state="c3"} = 140218.1078233
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,8",state="c1"} = 17600.4568697
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,8",state="c2"} = 173.8375892
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,8",state="c3"} = 140489.54279070001
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,9",state="c1"} = 17522.5240448
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,9",state="c2"} = 177.59460970000001
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,9",state="c3"} = 140558.4336283
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,10",state="c1"} = 7762.4903029999996
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,10",state="c2"} = 193.61915740000001
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,10",state="c3"} = 138503.0911967
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,11",state="c1"} = 14252.7444524
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,11",state="c2"} = 962.90285440000002
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,11",state="c3"} = 129627.62236769999
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,12",state="c1"} = 7819.5007047999998
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,12",state="c2"} = 212.41929239999999
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,12",state="c3"} = 138384.3488759
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,13",state="c1"} = 11326.6528275
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,13",state="c2"} = 207.2948868
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,13",state="c3"} = 138482.50026629999
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,14",state="c1"} = 17740.0271999
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,14",state="c2"} = 207.73055909999999
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,14",state="c3"} = 140331.86538619999
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,15",state="c1"} = 17539.975118999999
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,15",state="c2"} = 181.21429939999999
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,15",state="c3"} = 140559.91205079999
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,16",state="c1"} = 17623.824232300001
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,16",state="c2"} = 176.00649759999999
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,16",state="c3"} = 140619.0150168
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,17",state="c1"} = 17398.990005399999
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,17",state="c2"} = 182.73010669999999
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,17",state="c3"} = 140581.14175040001
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,18",state="c1"} = 17332.445049900001
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,18",state="c2"} = 232.4264986
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,18",state="c3"} = 140056.1589023
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,19",state="c1"} = 17441.164998100001
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,19",state="c2"} = 197.2230146
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,19",state="c3"} = 140462.38961380001
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,20",state="c1"} = 17434.880455499999
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,20",state="c2"} = 184.2476417
2026-06-26T08:03:06.674139500Z windows_cpu_cstate_seconds_total{core="0,20",state="c3"} = 140615.51527470001
<snip>
2026-06-26T08:03:06.773174800Z windows_performancecounter_process_fluent_bit_thread_count = 13
<snip>
2026-06-26T08:03:06.773174800Z windows_performancecounter_gpu_3d_utilization{instance="pid_11872_luid_0x00000000_0x00014485_phys_0_eng_0_engtype_3D#0"} = 0
2026-06-26T08:03:06.773174800Z windows_performancecounter_gpu_3d_utilization{instance="pid_12304_luid_0x00000000_0x0001406D_phys_0_eng_0_engtype_3D#0"} = 0.038007811308556433
<snip>
2026-06-26T08:03:06.773174800Z windows_performancecounter_gpu_3d_utilization{instance="pid_2660_luid_0x00000000_0x0001406D_phys_0_eng_0_engtype_3D#0"} = 14.387620901817147
2026-06-26T08:03:06.773174800Z windows_performancecounter_gpu_3d_utilization{instance="pid_2660_luid_0x00000000_0x00014453_phys_0_eng_0_engtype_3D#0"} = 0
<snip>
2026-06-26T08:03:06.773174800Z windows_performancecounter_gpu_3d_utilization{instance="pid_2660_luid_0x00000000_0x00014485_phys_0_eng_0_engtype_3D#0"} = 0.36890835688568813
2026-06-26T08:03:06.773174800Z windows_performancecounter_gpu_3d_utilization{instance="pid_27548_luid_0x00000000_0x0001406D_phys_0_eng_0_engtype_3D#0"} = 0
2026-06-26T08:03:06.773174800Z windows_performancecounter_gpu_3d_utilization{instance="pid_27548_luid_0x00000000_0x00014485_phys_0_eng_0_engtype_3D#0"} = 0
2026-06-26T08:03:06.773174800Z windows_performancecounter_gpu_3d_utilization{instance="pid_28064_luid_0x00000000_0x0001406D_phys_0_eng_0_engtype_3D#0"} = 2.6018428983539654
2026-06-26T08:03:06.773174800Z windows_performancecounter_gpu_3d_utilization{instance="pid_28692_luid_0x00000000_0x0001406D_phys_0_eng_0_engtype_3D#0"} = 0
2026-06-26T08:03:06.773174800Z windows_performancecounter_gpu_3d_utilization{instance="pid_29320_luid_0x00000000_0x0001406D_phys_0_eng_0_engtype_3D#0"} = 0
2026-06-26T08:03:06.773174800Z windows_performancecounter_gpu_3d_utilization{instance="pid_30636_luid_0x00000000_0x00014485_phys_0_eng_0_engtype_3D#0"} = 0
2026-06-26T08:03:06.773174800Z windows_performancecounter_gpu_3d_utilization{instance="pid_3080_luid_0x00000000_0x0001406D_phys_0_eng_0_engtype_3D#0"} = 1.1449325076998662
2026-06-26T08:03:06.773174800Z windows_performancecounter_gpu_3d_utilization{instance="pid_31488_luid_0x00000000_0x0001406D_phys_0_eng_0_engtype_3D#0"} = 0
2026-06-26T08:03:06.773174800Z windows_performancecounter_gpu_3d_utilization{instance="pid_33040_luid_0x00000000_0x0001406D_phys_0_eng_0_engtype_3D#0"} = 0
2026-06-26T08:03:06.773174800Z windows_performancecounter_gpu_3d_utilization{instance="pid_33080_luid_0x00000000_0x0001406D_phys_0_eng_0_engtype_3D#0"} = 14.838853983013891
2026-06-26T08:03:06.773174800Z windows_performancecounter_gpu_3d_utilization{instance="pid_33348_luid_0x00000000_0x0001406D_phys_0_eng_0_engtype_3D#0"} = 0
2026-06-26T08:03:06.773174800Z windows_performancecounter_gpu_3d_utilization{instance="pid_35248_luid_0x00000000_0x0001406D_phys_0_eng_0_engtype_3D#0"} = 13.977334308435408
<snip>
2026-06-26T08:03:06.773174800Z windows_performancecounter_gpu_3d_utilization{instance="pid_4_luid_0x00000000_0x0001406D_phys_0_eng_0_engtype_3D#0"} = 0.099330051393413152
2026-06-26T08:03:06.773174800Z windows_performancecounter_gpu_3d_utilization{instance="pid_4_luid_0x00000000_0x00014453_phys_0_eng_0_engtype_3D#0"} = 0
<snip>
[2026/06/26 17:03:07.680] [debug] [output:stdout:stdout.0] cmt decode msgpack returned : 1
[2026/06/26 17:03:07.680] [debug] [out flush] cb_destroy coro_id=0
[2026/06/26 17:03:07.680] [debug] [task] destroy task=00000276559C2230 (task_id=0)
[2026/06/26 17:03:08] [engine] caught signal (SIGINT)
[2026/06/26 17:03:08.689] [debug] [input:windows_exporter_metrics:windows_exporter_metrics.0] initializing WMI instance....
[2026/06/26 17:03:08.713] [debug] [input:windows_exporter_metrics:windows_exporter_metrics.0] deinitializing WMI instance....
[2026/06/26 17:03:08.782] [debug] [task] created task=00000276559ACF30 id=0 OK
[2026/06/26 17:03:08.782] [debug] [output:stdout:stdout.0] task_id=0 assigned to thread #0
[2026/06/26 17:03:08.782] [ warn] [engine] service will shutdown in max 5 seconds
[2026/06/26 17:03:08.782] [debug] [engine] task 0 already scheduled to run, not re-scheduling it.
[2026/06/26 17:03:08.782] [ info] [engine] pausing all inputs..
[2026/06/26 17:03:08.782] [ info] [input] pausing windows_exporter_metrics.0
  • Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • Run local packaging test showing all targets (including any new ones) build.
  • Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • Documentation required for this feature

fluent/fluent-bit-docs#2610

Backporting

  • Backport to latest stable release.

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

Summary by CodeRabbit

  • New Features

    • Added Windows performance counter metric collection support.
    • New configuration options let you set a scrape interval and define performance counter metrics.
  • Bug Fixes

    • Improved metric lifecycle handling so the new collector pauses, resumes, and shuts down cleanly with the rest of the plugin.
    • Added support for wildcard counter paths and per-instance labels for more detailed metric output.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a Windows PerformanceCounter collector, its PDH-backed registration and sampling code, and plugin wiring for configuration, scheduling, lifecycle, and metric publication.

Changes

Windows PerformanceCounter collector

Layer / File(s) Summary
Contracts and build inputs
plugins/in_windows_exporter_metrics/CMakeLists.txt, plugins/in_windows_exporter_metrics/we.h, plugins/in_windows_exporter_metrics/we_performancecounter.h
Adds PDH headers, performance-counter state fields, the collector interface header, and the new source and library entries.
Counter parsing and registration
plugins/in_windows_exporter_metrics/we_performancecounter.c
Parses configured counter entries, derives metric-safe names and instance labels, expands wildcard paths, and registers PDH counters.
Collector lifecycle and samples
plugins/in_windows_exporter_metrics/we_performancecounter.c
Allocates the PDH query, collects formatted counter values into gauges, and removes registered counters during cleanup.
Plugin wiring and config
plugins/in_windows_exporter_metrics/we.c
Adds the callback hooks, timed collector setup, lifecycle handling, and new configuration mappings for PerformanceCounter.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Suggested reviewers

  • edsiper

Poem

Hop, hop — the counters sprang to life,
PDH sang through the rabbit night.
I twitched my nose and watched them bloom,
then bounded off with metrics in tow. 🐰

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding user-defined performance counters via PDH in the Windows exporter metrics plugin.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cosmo0920-implement-user-defined-windows-metrics-with-performance-counters

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c15919bfb9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread plugins/in_windows_exporter_metrics/we_performancecounter.c Outdated
Comment thread plugins/in_windows_exporter_metrics/we_performancecounter.c
Comment thread plugins/in_windows_exporter_metrics/we_performancecounter.c Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@plugins/in_windows_exporter_metrics/we_performancecounter.c`:
- Around line 397-403: The PDH query open failure path in
we_performancecounter_init should return a non-zero failure code instead of 0 so
the caller can reject the collector initialization. Update the error branch
after PdhOpenQueryW in we_performancecounter_init to propagate failure
consistently with the rest of the init flow, ensuring we.c sees the
initialization as failed and does not leave the plugin enabled in a broken
state.
- Around line 187-192: The allocation-failure path in add_counter_path() is
freeing caller-owned metric_name, which later gets freed again by add_counter()
and the wildcard path. Update the failure handling around the counter allocation
in add_counter_path() so it only releases memory owned by that function (such as
path_w) and leaves metric_name for the caller to free after the return value is
handled.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 97d64cad-0c95-45b4-ab8b-42988ebb7055

📥 Commits

Reviewing files that changed from the base of the PR and between f317143 and c15919b.

📒 Files selected for processing (5)
  • plugins/in_windows_exporter_metrics/CMakeLists.txt
  • plugins/in_windows_exporter_metrics/we.c
  • plugins/in_windows_exporter_metrics/we.h
  • plugins/in_windows_exporter_metrics/we_performancecounter.c
  • plugins/in_windows_exporter_metrics/we_performancecounter.h

Comment thread plugins/in_windows_exporter_metrics/we_performancecounter.c
Comment thread plugins/in_windows_exporter_metrics/we_performancecounter.c Outdated
…ers w/ PDH

Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant