Skip to content

Commit 8f6638e

Browse files
committed
Revert "#13 Use Untyped for some defaults metrics"
This reverts commit 779d94d. # Conflicts: # src/Prometheus.Client/Collectors/DotNetStatsCollector.cs
1 parent 812a0f7 commit 8f6638e

4 files changed

Lines changed: 22 additions & 20 deletions

File tree

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ deploy:
3434
symbol_server: https://www.myget.org/F/phnx47-beta/symbols/api/v2/package
3535
artifact: MyGet
3636
on:
37-
branch: master
38-
appveyor_repo_tag: false
37+
branch: 2.2
38+
appveyor_repo_tag: false

src/Prometheus.Client/Collectors/DotNetStatsCollector.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ namespace Prometheus.Client.Collectors
1111
public class DotNetStatsCollector : IOnDemandCollector
1212
{
1313
private readonly MetricFactory _metricFactory;
14+
1415
private readonly List<Counter.LabelledCounter> _collectionCounts = new List<Counter.LabelledCounter>();
15-
private Untyped _totalMemory;
16+
private Gauge _totalMemory;
17+
1618
private Counter _errorCounter;
1719

1820
/// <inheritdoc />
@@ -39,7 +41,7 @@ public void RegisterMetrics()
3941

4042
var collectionCountsParent = _metricFactory.CreateCounter("dotnet_collection_count_total", "GC collection count", "generation");
4143

42-
_totalMemory = _metricFactory.CreateUntyped("dotnet_totalmemory", "Total known allocated memory");
44+
_totalMemory = _metricFactory.CreateGauge("dotnet_totalmemory", "Total known allocated memory");
4345

4446
for (var gen = 0; gen <= GC.MaxGeneration; gen++)
4547
_collectionCounts.Add(collectionCountsParent.Labels(gen.ToString()));

src/Prometheus.Client/Collectors/ProcessCollector.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ public class ProcessCollector : IOnDemandCollector
1414
private readonly Process _process;
1515
private Counter _cpuTotal;
1616
private Counter _errorCounter;
17-
18-
private Untyped _numThreads;
19-
private Untyped _privateMemorySize;
20-
private Untyped _virtualMemorySize;
21-
private Untyped _workingSet;
17+
18+
private Gauge _numThreads;
19+
private Gauge _privateMemorySize;
20+
private Gauge _virtualMemorySize;
21+
private Gauge _workingSet;
2222

2323

2424
/// <inheritdoc />
@@ -47,16 +47,16 @@ public void RegisterMetrics()
4747
_cpuTotal = _metricFactory.CreateCounter("process_cpu_seconds_total", "Total user and system CPU time spent in seconds");
4848

4949
var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
50-
50+
5151
_metricFactory.CreateGauge("process_start_time_seconds", "Start time of the process since unix epoch in seconds")
5252
.Set((_process.StartTime.ToUniversalTime() - epoch).TotalSeconds);
53-
54-
_virtualMemorySize = _metricFactory.CreateUntyped("process_virtual_bytes", "Process virtual memory size");
55-
_workingSet = _metricFactory.CreateUntyped("process_working_set", "Process working set");
56-
_privateMemorySize = _metricFactory.CreateUntyped("process_private_bytes", "Process private memory size");
57-
_numThreads = _metricFactory.CreateUntyped("process_num_threads", "Total number of threads");
58-
59-
_metricFactory.CreateUntyped("process_processid", "Process ID").Set(_process.Id);
53+
54+
_virtualMemorySize = _metricFactory.CreateGauge("process_virtual_bytes", "Process virtual memory size");
55+
_workingSet = _metricFactory.CreateGauge("process_working_set", "Process working set");
56+
_privateMemorySize = _metricFactory.CreateGauge("process_private_bytes", "Process private memory size");
57+
_numThreads = _metricFactory.CreateGauge("process_num_threads", "Total number of threads");
58+
59+
_metricFactory.CreateGauge("process_processid", "Process ID").Set(_process.Id); // todo: Untyped
6060
}
6161

6262
public void UpdateMetrics()
@@ -66,7 +66,7 @@ public void UpdateMetrics()
6666
_process.Refresh();
6767

6868
_cpuTotal.Inc(_process.TotalProcessorTime.TotalSeconds - _cpuTotal.Value);
69-
69+
7070
_virtualMemorySize.Set(_process.VirtualMemorySize64);
7171
_workingSet.Set(_process.WorkingSet64);
7272
_privateMemorySize.Set(_process.PrivateMemorySize64);
@@ -78,4 +78,4 @@ public void UpdateMetrics()
7878
}
7979
}
8080
}
81-
}
81+
}

src/Prometheus.Client/Prometheus.Client.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Description>.NET client for Prometheus</Description>
44
<Copyright>2019 © Sergey Kuznetsov</Copyright>
55
<AssemblyTitle>Prometheus.Client</AssemblyTitle>
6-
<VersionPrefix>2.2.0</VersionPrefix>
6+
<VersionPrefix>2.2.1</VersionPrefix>
77
<Authors>Sergey Kuznetsov</Authors>
88
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard1.3;netstandard2.0</TargetFrameworks>
99
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net45;netstandard1.3;netstandard2.0</TargetFrameworks>

0 commit comments

Comments
 (0)