Skip to content

Commit

Permalink
Merge pull request #40 from prom-client-net/feat/update-prom-client
Browse files Browse the repository at this point in the history
feat: update prom-client
  • Loading branch information
phnx47 authored Aug 22, 2022
2 parents d1b1d73 + 6001da2 commit 779d957
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Prometheus.Client.AspNetCore.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>ASP.NET Core middleware for the Prometheus.Client</Description>
<VersionPrefix>4.6.0</VersionPrefix>
<VersionPrefix>4.7.0</VersionPrefix>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<PackageId>Prometheus.Client.AspNetCore</PackageId>
<RepositoryUrl>https://github.com/prom-client-net/prom-client-aspnetcore</RepositoryUrl>
Expand All @@ -12,7 +12,7 @@
<None Include="../icon.png" Visible="false" Pack="true" PackagePath="" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Prometheus.Client" Version="[4.5.3,5.0.0)" />
<PackageReference Include="Prometheus.Client" Version="[5.0.0,6.0.0)" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1' OR '$(TargetFramework)' == 'net5.0' OR '$(TargetFramework)' == 'net6.0'">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
Expand Down
9 changes: 8 additions & 1 deletion src/PrometheusExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ public static IApplicationBuilder UsePrometheusServer(this IApplicationBuilder a
throw new ArgumentException($"MapPath '{options.MapPath}' should start with '/'");

if (options.UseDefaultCollectors)
options.CollectorRegistryInstance.UseDefaultCollectors(options.MetricPrefixName);
{
#pragma warning disable CS0618
if (options.AddLegacyMetrics)
options.CollectorRegistryInstance.UseDefaultCollectors(options.MetricPrefixName, options.AddLegacyMetrics);
else
options.CollectorRegistryInstance.UseDefaultCollectors(options.MetricPrefixName);
#pragma warning restore CS0618
}

var contentType = "text/plain; version=0.0.4";

Expand Down
18 changes: 17 additions & 1 deletion src/PrometheusOptions.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Text;
using Prometheus.Client.Collectors;

Expand All @@ -14,7 +15,7 @@ public class PrometheusOptions
public string MapPath { get; set; } = "/metrics";

/// <summary>
/// When specified only allow access to metrics on this port, otherwise return 404, default = null.
/// When specified only allow access to metrics on this port, otherwise return 404
/// </summary>
public int? Port { get; set; }

Expand All @@ -37,5 +38,20 @@ public class PrometheusOptions
/// Metric prefix for Default collectors
/// </summary>
public string MetricPrefixName { get; set; } = "";

/// <summary>
/// Add legacy metrics to Default collectors
/// </summary>
/// <remarks>
/// Some metrics renamed since v5, <c>AddLegacyMetrics</c> will add old and new name<br />
/// <para>
/// process_virtual_bytes -> process_virtual_memory_bytes<br />
/// process_private_bytes -> process_private_memory_bytes<br />
/// process_working_set -> process_working_set_bytes<br />
/// dotnet_totalmemory -> dotnet_total_memory_bytes
/// </para>
/// </remarks>
[Obsolete("'AddLegacyMetrics' will be removed in future versions")]
public bool AddLegacyMetrics { get; set; }
}
}

0 comments on commit 779d957

Please sign in to comment.