Skip to content
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
7 changes: 7 additions & 0 deletions src/OpenTelemetry.Instrumentation.Process/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## Unreleased

* Following changes related to [Semantic Convention v1.25.0](https://github.com/open-telemetry/semantic-conventions/blob/v1.25.0/docs/system/process-metrics.md)
* `process.cpu.time` metric attribute renamed from `state` to `process.cpu.state`,
* Metric descriptions fixed for `process.memory.usage` and `process.memory.virtual`,
* Metric `process.threads` renamed to `process.thread.count`
(its unit changed from `{threads}` to `{thread}`).
([#1643](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1643))

## 0.5.0-beta.5

Released 2024-Apr-05
Expand Down
12 changes: 6 additions & 6 deletions src/OpenTelemetry.Instrumentation.Process/ProcessMetrics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static ProcessMetrics()
return Diagnostics.Process.GetCurrentProcess().WorkingSet64;
},
unit: "By",
description: "The amount of physical memory allocated for this process.");
description: "The amount of physical memory in use.");

MeterInstance.CreateObservableUpDownCounter(
"process.memory.virtual",
Expand All @@ -36,7 +36,7 @@ static ProcessMetrics()
return Diagnostics.Process.GetCurrentProcess().VirtualMemorySize64;
},
unit: "By",
description: "The amount of committed virtual memory for this process.");
description: "The amount of committed virtual memory.");

MeterInstance.CreateObservableCounter(
"process.cpu.time",
Expand All @@ -45,8 +45,8 @@ static ProcessMetrics()
var process = Diagnostics.Process.GetCurrentProcess();
return new[]
{
new Measurement<double>(process.UserProcessorTime.TotalSeconds, new KeyValuePair<string, object?>("state", "user")),
new Measurement<double>(process.PrivilegedProcessorTime.TotalSeconds, new KeyValuePair<string, object?>("state", "system")),
new Measurement<double>(process.UserProcessorTime.TotalSeconds, new KeyValuePair<string, object?>("process.cpu.state", "user")),
new Measurement<double>(process.PrivilegedProcessorTime.TotalSeconds, new KeyValuePair<string, object?>("process.cpu.state", "system")),
};
},
unit: "s",
Expand All @@ -62,12 +62,12 @@ static ProcessMetrics()
description: "The number of processors (CPU cores) available to the current process.");

MeterInstance.CreateObservableUpDownCounter(
"process.threads",
"process.thread.count",
() =>
{
return Diagnostics.Process.GetCurrentProcess().Threads.Count;
},
unit: "{threads}",
unit: "{thread}",
description: "Process threads count.");
}

Expand Down
10 changes: 5 additions & 5 deletions src/OpenTelemetry.Instrumentation.Process/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ process.

Total CPU seconds broken down by states.

| Units | Instrument Type | Value Type | Attribute Key(s) | Attribute Values |
|-------|-------------------|------------|------------------|------------------|
| `s` | ObservableCounter | `Double` | state | user, system |
| Units | Instrument Type | Value Type | Attribute Key(s) | Attribute Values |
|-------|-------------------|------------|-------------------|------------------|
| `s` | ObservableCounter | `Double` | process.cpu.state | user, system |

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not a blocking comment but spec defines this as Counter and we have it as ObservableCounter. I do not know the history of this, @Yun-Ting any idea?


The APIs used to retrieve the values are:

Expand Down Expand Up @@ -130,13 +130,13 @@ and not part of the [Process Metrics
Spec](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/semantic_conventions/process-metrics.md)
at this time.

### process.threads
### process.thread.count

Process threads count.

| Units | Instrument Type | Value Type |
|------------|-------------------------|------------|
| `{threads}`| ObservableUpDownCounter | `Int32` |
| `{thread}` | ObservableUpDownCounter | `Int32` |

The API used to retrieve the value is:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ public void CpuTimeMetricsAreCaptured()
{
Assert.NotNull(tag.Value);

if (tag.Key == "state" && tag.Value!.ToString() == "user")
if (tag.Key == "process.cpu.state" && tag.Value!.ToString() == "user")
{
userTimeCaptured = true;
}
else if (tag.Key == "state" && tag.Value!.ToString() == "system")
else if (tag.Key == "process.cpu.state" && tag.Value!.ToString() == "system")
{
systemTimeCaptured = true;
}
Expand Down Expand Up @@ -133,7 +133,7 @@ public void ProcessMetricsAreCapturedWhenTasksOverlap()

Task.WaitAll(tasks.ToArray());

Assert.True(exportedItemsA.Count == 5);
Assert.Equal(5, exportedItemsA.Count);
var physicalMemoryMetricA = exportedItemsA.FirstOrDefault(i => i.Name == "process.memory.usage");
Assert.NotNull(physicalMemoryMetricA);
var virtualMemoryMetricA = exportedItemsA.FirstOrDefault(i => i.Name == "process.memory.virtual");
Expand All @@ -142,10 +142,10 @@ public void ProcessMetricsAreCapturedWhenTasksOverlap()
Assert.NotNull(cpuTimeMetricA);
var processorCountMetricA = exportedItemsA.FirstOrDefault(i => i.Name == "process.cpu.count");
Assert.NotNull(processorCountMetricA);
var threadMetricA = exportedItemsA.FirstOrDefault(i => i.Name == "process.threads");
var threadMetricA = exportedItemsA.FirstOrDefault(i => i.Name == "process.thread.count");
Assert.NotNull(threadMetricA);

Assert.True(exportedItemsB.Count == 5);
Assert.Equal(5, exportedItemsB.Count);
var physicalMemoryMetricB = exportedItemsB.FirstOrDefault(i => i.Name == "process.memory.usage");
Assert.NotNull(physicalMemoryMetricB);
var virtualMemoryMetricB = exportedItemsB.FirstOrDefault(i => i.Name == "process.memory.virtual");
Expand All @@ -154,7 +154,7 @@ public void ProcessMetricsAreCapturedWhenTasksOverlap()
Assert.NotNull(cpuTimeMetricB);
var processorCountMetricB = exportedItemsB.FirstOrDefault(i => i.Name == "process.cpu.count");
Assert.NotNull(processorCountMetricB);
var threadMetricB = exportedItemsB.FirstOrDefault(i => i.Name == "process.threads");
var threadMetricB = exportedItemsB.FirstOrDefault(i => i.Name == "process.thread.count");
Assert.NotNull(threadMetricB);
}

Expand Down