Skip to content

Commit 39e2c91

Browse files
authored
[Instrumentation.Process] Update OTel API version to 1.4.0-beta.2 and change runtime metrics type to ObservableUpDownCounter (#751)
1 parent 30eddfa commit 39e2c91

6 files changed

Lines changed: 22 additions & 18 deletions

File tree

src/OpenTelemetry.Instrumentation.Process/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
* Update OTel API version to be `1.4.0-beta.2` and change process metrics type
6+
from ObservableGauge to `ObservableUpDownCounter`. Updated instruments are:
7+
"process.memory.usage", "process.memory.virtual" and "process.threads".
8+
([#751](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/751))
9+
310
## 0.1.0-alpha.1
411

512
Released 2022-Oct-14

src/OpenTelemetry.Instrumentation.Process/OpenTelemetry.Instrumentation.Process.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="OpenTelemetry.Api" Version="$(OpenTelemetryCoreLatestVersion)" />
12+
<PackageReference Include="OpenTelemetry.Api" Version="1.4.0-beta.2" />
1313
</ItemGroup>
1414

1515
<ItemGroup>

src/OpenTelemetry.Instrumentation.Process/ProcessMetrics.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ public ProcessMetrics(ProcessInstrumentationOptions options)
3838
this.lastCollectedUserProcessorTime = Diagnostics.Process.GetCurrentProcess().UserProcessorTime.TotalSeconds;
3939
this.lastCollectedPrivilegedProcessorTime = Diagnostics.Process.GetCurrentProcess().PrivilegedProcessorTime.TotalSeconds;
4040

41-
// TODO: change to ObservableUpDownCounter
42-
this.MeterInstance.CreateObservableGauge(
41+
this.MeterInstance.CreateObservableUpDownCounter(
4342
"process.memory.usage",
4443
() =>
4544
{
@@ -48,8 +47,7 @@ public ProcessMetrics(ProcessInstrumentationOptions options)
4847
unit: "By",
4948
description: "The amount of physical memory allocated for this process.");
5049

51-
// TODO: change to ObservableUpDownCounter
52-
this.MeterInstance.CreateObservableGauge(
50+
this.MeterInstance.CreateObservableUpDownCounter(
5351
"process.memory.virtual",
5452
() =>
5553
{
@@ -81,8 +79,7 @@ public ProcessMetrics(ProcessInstrumentationOptions options)
8179
unit: "1",
8280
description: "Difference in process.cpu.time since the last measurement, divided by the elapsed time and number of CPUs available to the process.");
8381

84-
// TODO: change to ObservableUpDownCounter
85-
this.MeterInstance.CreateObservableGauge(
82+
this.MeterInstance.CreateObservableUpDownCounter(
8683
"process.threads",
8784
() =>
8885
{

src/OpenTelemetry.Instrumentation.Process/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ complete demo.
4949

5050
The amount of physical memory allocated for this process.
5151

52-
| Units | Instrument Type | Value Type |
53-
|-------|-------------------|------------|
54-
| `By` | ObservableGauge | `Double` |
52+
| Units | Instrument Type | Value Type |
53+
|-------|-------------------------|------------|
54+
| `By` | ObservableUpDownCounter | `Double` |
5555

5656
The API used to retrieve the value is:
5757

@@ -64,9 +64,9 @@ allocated for the associated process.
6464
The amount of virtual memory allocated for this process
6565
that cannot be shared with other processes.
6666

67-
| Units | Instrument Type | Value Type |
68-
|-------|-------------------|------------|
69-
| `By` | ObservableGauge | `Double` |
67+
| Units | Instrument Type | Value Type |
68+
|-------|-------------------------|------------|
69+
| `By` | ObservableUpDownCounter | `Double` |
7070

7171
The API used to retrieve the value is:
7272

@@ -111,9 +111,9 @@ Gets the privileged processor time for this process.
111111

112112
Process threads count.
113113

114-
| Units | Instrument Type | Value Type |
115-
|-----------------|-------------------|------------|
116-
| `{threads}` | ObservableGauge | `Int32` |
114+
| Units | Instrument Type | Value Type |
115+
|------------|-------------------------|------------|
116+
| `{threads}`| ObservableUpDownCounter | `Int32` |
117117

118118
The API used to retrieve the value is:
119119

test/OpenTelemetry.Instrumentation.Process.Tests/OpenTelemetry.Instrumentation.Process.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<ItemGroup>
99
<PackageReference Include="coverlet.collector" Version="$(CoverletCollectorPkgVer)" />
1010
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPkgVer)" />
11-
<PackageReference Include="OpenTelemetry.Exporter.InMemory" Version="$(OpenTelemetryExporterInMemoryPkgVer)" />
11+
<PackageReference Include="OpenTelemetry.Exporter.InMemory" Version="1.4.0-beta.2" />
1212
<PackageReference Include="xunit" Version="$(XUnitPkgVer)" />
1313
<PackageReference Condition="$([MSBuild]::IsOsPlatform('Windows'))" Include="xunit.runner.visualstudio" Version="$(XUnitRunnerVisualStudioPkgVer)">
1414
<PrivateAssets>all</PrivateAssets>

test/OpenTelemetry.Instrumentation.Process.Tests/ProcessMetricsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ private static double GetValue(Metric metric)
158158
{
159159
if (metric.MetricType.IsLong())
160160
{
161-
sum += metricPoint.GetGaugeLastValueLong();
161+
sum += metricPoint.GetSumLong();
162162
}
163163
}
164164

0 commit comments

Comments
 (0)