[agent][metric] Add new metrics for voluntary/involuntary context switches
- Dominant language
- Gherkin
- Stars
- 427
- Forks
- 125
- PR merge metrics
- No merged PRs in 30d
Description
## Description of the issue
The number of context switches can be a good indicator how contented the CPU is. This is especially true for involuntary context switches, which happen when a process reaches its allotted time slice and is suspended by the kernel (in contrast, voluntary context switches happen when the process returns control to the kernel e.g. while waiting on IO or sleeping).
This is a metric that is provided by the system, as such it might be awkward to implement on certain platforms and/or languages. It was also [suggested](https://discuss.elastic.co/t/how-to-capture-cpu-context-switch-from-metricbeat/135083) by a user to include in metricbeat, but AFAICT, nothing came of it so far.
I suggest to include the two values as counters
* `system.process.context_switches.voluntary`
* `system.process.context_switches.involuntary`
(Linux makes naming here a bit difficult. In [getrusage](http://man7.org/linux/man-pages/man2/getrusage.2.html) it is called "involuntary" while in `/proc/$pid/status` it is called "nonvoluntary". I'll let someone with better command of English decide this)
## What we are voting on
Should we include the metric?
## Vote
| Agent | Yes | No | Indifferent | N/A | Link to agent issue
| --------|:----:|:---:|:-----------:|:----:|:-------------------:|
| .NET |
- [ ]
- [ ]
- [ ]
- [ ]
| Go |
- [ ]
- [ ]
- [ ]
- [ ]
| Java |
- [ ]
- [x]
- [ ]
- [ ]
| Node.js |
- [ ]
- [ ]
- [x]
- [ ]
| Python |
- [x]
- [ ]
- [ ]
- [ ]
| Ruby |
- [ ]
- [ ]
- [ ]
- [ ]
| RUM |
- [ ]
- [ ]
- [ ]
- [ ]
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.