Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Instrumentation.Process] Update .NET API for virtual memory usage #762

Merged
merged 9 commits into from
Nov 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Instrumentation.Process/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

* Update the .NET API used to retrieve `process.memory.virtual` metric to be
`Process.VirtualMemorySize64`.
([#762](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/762))

* Update OTel API version to be `1.4.0-beta.2` and change process metrics type
from ObservableGauge to `ObservableUpDownCounter`. Updated instruments are:
"process.memory.usage", "process.memory.virtual" and "process.threads".
Expand Down
4 changes: 2 additions & 2 deletions src/OpenTelemetry.Instrumentation.Process/ProcessMetrics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public ProcessMetrics(ProcessInstrumentationOptions options)
"process.memory.virtual",
() =>
{
return Diagnostics.Process.GetCurrentProcess().PrivateMemorySize64;
return Diagnostics.Process.GetCurrentProcess().VirtualMemorySize64;
},
unit: "By",
description: "The amount of virtual memory allocated for this process that cannot be shared with other processes.");
description: "The amount of committed virtual memory for this process.");

this.MeterInstance.CreateObservableCounter(
"process.cpu.time",
Expand Down
10 changes: 6 additions & 4 deletions src/OpenTelemetry.Instrumentation.Process/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,19 @@ allocated for the associated process.

### process.memory.virtual

The amount of virtual memory allocated for this process
that cannot be shared with other processes.
The amount of committed virtual memory for this process.
One way to think of this is all the address space this process can read from
without trigerring an access violation; this includes memory backed solely by RAM,
by a swapfile/pagefile and by other mapped files on disk.

| Units | Instrument Type | Value Type |
|-------|-------------------------|------------|
| `By` | ObservableUpDownCounter | `Double` |

The API used to retrieve the value is:

* [Process.WorkingSet64](https://learn.microsoft.com/dotnet/api/system.diagnostics.process.privatememorysize64):
Yun-Ting marked this conversation as resolved.
Show resolved Hide resolved
Gets the amount of private memory, in bytes,
* [Process.VirtualMemorySize64](https://learn.microsoft.com/dotnet/api/system.diagnostics.process.virtualmemorysize64):
Gets the amount of the virtual memory, in bytes,
allocated for the associated process.

### process.cpu.time
Expand Down