Skip to content

Commit

Permalink
Update Prometheus.Client and implement missing members (#944)
Browse files Browse the repository at this point in the history
  • Loading branch information
rngcntr authored Aug 25, 2023
1 parent 477ddcb commit dbc2179
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 6 deletions.
2 changes: 1 addition & 1 deletion shared.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>

<PropertyGroup>
<Version>0.13.0</Version>
<Version>0.13.1</Version>
<LangVersion>11</LangVersion>
<Nullable>enable</Nullable>
<WarningsAsErrors>CS8600;CS8602;CS8625;CS8618;CS8604;CS8601</WarningsAsErrors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Prometheus.Client" Version="5.0.0" />
<PackageReference Include="Prometheus.Client" Version="5.2.0" />
</ItemGroup>

<Import Project="$(MSBuildThisFileDirectory)../../shared.csproj" />
Expand Down
44 changes: 44 additions & 0 deletions src/Motor.Extensions.Diagnostics.Metrics/MetricsFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ public ICounter CreateCounter(string name, string help, bool includeTimestamp =
return _metricFactory.CreateCounter(metricsName, help, includeTimestamp);
}

public IMetricFamily<ICounter, ValueTuple<string>> CreateCounter(string name, string help, string labelName, bool includeTimestamp = false)
{
var metricsName = PrependNamespace(name);
return _metricFactory.CreateCounter(metricsName, help, labelName, includeTimestamp);
}

public IMetricFamily<ICounter, TLabels> CreateCounter<TLabels>(string name, string help, TLabels labelNames, bool includeTimestamp = false) where TLabels : struct, ITuple, IEquatable<TLabels>
{
var metricsName = PrependNamespace(name);
Expand All @@ -55,6 +61,12 @@ public ICounter<long> CreateCounterInt64(string name, string help, bool includeT
return _metricFactory.CreateCounterInt64(metricsName, help, includeTimestamp);
}

public IMetricFamily<ICounter<long>, ValueTuple<string>> CreateCounterInt64(string name, string help, string labelName, bool includeTimestamp = false)
{
var metricsName = PrependNamespace(name);
return _metricFactory.CreateCounterInt64(metricsName, help, labelName, includeTimestamp);
}

public IMetricFamily<ICounter<long>, TLabels> CreateCounterInt64<TLabels>(string name, string help, TLabels labelNames, bool includeTimestamp = false) where TLabels : struct, ITuple, IEquatable<TLabels>
{
var metricsName = PrependNamespace(name);
Expand Down Expand Up @@ -91,6 +103,12 @@ public IMetricFamily<IGauge> CreateGauge(string name, string help, params string
return _metricFactory.CreateGauge(metricsName, help, labelNames);
}

public IMetricFamily<IGauge, ValueTuple<string>> CreateGauge(string name, string help, string labelName, bool includeTimestamp = false)
{
var metricsName = PrependNamespace(name);
return _metricFactory.CreateGauge(metricsName, help, labelName, includeTimestamp);
}

public IMetricFamily<IGauge> CreateGauge(string name, string help, bool includeTimestamp = false, params string[] labelNames)
{
var metricsName = PrependNamespace(name);
Expand All @@ -103,6 +121,12 @@ public IGauge<long> CreateGaugeInt64(string name, string help, bool includeTimes
return _metricFactory.CreateGaugeInt64(metricsName, help, includeTimestamp);
}

public IMetricFamily<IGauge<long>, ValueTuple<string>> CreateGaugeInt64(string name, string help, string labelName, bool includeTimestamp = false)
{
var metricsName = PrependNamespace(name);
return _metricFactory.CreateGaugeInt64(metricsName, help, labelName, includeTimestamp);
}

public IMetricFamily<IGauge<long>, TLabels> CreateGaugeInt64<TLabels>(string name, string help, TLabels labelNames, bool includeTimestamp = false) where TLabels : struct, ITuple, IEquatable<TLabels>
{
var metricsName = PrependNamespace(name);
Expand All @@ -127,6 +151,13 @@ public IHistogram CreateHistogram(string name, string help, bool includeTimestam
return _metricFactory.CreateHistogram(metricsName, help, includeTimestamp, buckets);
}

public IMetricFamily<IHistogram, ValueTuple<string>> CreateHistogram(string name, string help, string labelName, bool includeTimestamp = false,
double[]? buckets = null)
{
var metricsName = PrependNamespace(name);
return _metricFactory.CreateHistogram(metricsName, help, labelName, includeTimestamp, buckets);
}

public IMetricFamily<IHistogram, TLabels> CreateHistogram<TLabels>(string name, string help, TLabels labelNames, bool includeTimestamp = false,
double[]? buckets = null) where TLabels : struct, ITuple, IEquatable<TLabels>
{
Expand Down Expand Up @@ -165,6 +196,12 @@ public IUntyped CreateUntyped(string name, string help, bool includeTimestamp =
return _metricFactory.CreateUntyped(metricsName, help, includeTimestamp);
}

public IMetricFamily<IUntyped, ValueTuple<string>> CreateUntyped(string name, string help, string labelName, bool includeTimestamp = false)
{
var metricsName = PrependNamespace(name);
return _metricFactory.CreateUntyped(metricsName, help, labelName, includeTimestamp);
}

public IMetricFamily<IUntyped, TLabels> CreateUntyped<TLabels>(string name, string help, TLabels labelNames, bool includeTimestamp = false) where TLabels : struct, ITuple, IEquatable<TLabels>
{
var metricsName = PrependNamespace(name);
Expand Down Expand Up @@ -209,6 +246,13 @@ public ISummary CreateSummary(string name, string help, bool includeTimestamp =
return _metricFactory.CreateSummary(metricsName, help, includeTimestamp, objectives, maxAge, ageBuckets, bufCap);
}

public IMetricFamily<ISummary, ValueTuple<string>> CreateSummary(string name, string help, string labelName, bool includeTimestamp = false,
IReadOnlyList<QuantileEpsilonPair>? objectives = null, TimeSpan? maxAge = null, int? ageBuckets = null, int? bufCap = null)
{
var metricsName = PrependNamespace(name);
return _metricFactory.CreateSummary(metricsName, help, labelName, includeTimestamp, objectives, maxAge, ageBuckets, bufCap);
}

public IMetricFamily<ISummary, TLabels> CreateSummary<TLabels>(string name, string help, TLabels labelNames, bool includeTimestamp = false,
IReadOnlyList<QuantileEpsilonPair>? objectives = null, TimeSpan? maxAge = null, int? ageBuckets = null, int? bufCap = null) where TLabels : struct, ITuple, IEquatable<TLabels>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Prometheus.Client" Version="5.0.0" />
<PackageReference Include="Prometheus.Client.AspNetCore" Version="4.8.0" />
<PackageReference Include="Prometheus.Client" Version="5.2.0" />
<PackageReference Include="Prometheus.Client.AspNetCore" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="7.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Prometheus.Client" Version="5.0.0" />
<PackageReference Include="Prometheus.Client.Abstractions" Version="5.2.0" />
<PackageReference Include="Prometheus.Client" Version="5.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit dbc2179

Please sign in to comment.