Skip to content

Commit 87ebfb7

Browse files
committed
feat: update hrd
1 parent 34680f6 commit 87ebfb7

File tree

9 files changed

+36
-64
lines changed

9 files changed

+36
-64
lines changed

Prometheus.Client.Examples.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HealthChecks", "src\HealthC
1111
EndProject
1212
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNetCore_6.0", "src\AspNetCore_6.0\AspNetCore_6.0.csproj", "{297EA5CD-C468-40CA-A97C-8A5DC28CF701}"
1313
EndProject
14-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebHttpRequestDurations_3.1", "src\WebHttpRequestDurations_3.1\WebHttpRequestDurations_3.1.csproj", "{83246BAD-85BA-4532-84BF-70D18B7FF66A}"
14+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpRequestDurations", "src\HttpRequestDurations\HttpRequestDurations.csproj", "{83246BAD-85BA-4532-84BF-70D18B7FF66A}"
1515
EndProject
1616
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebMetricPusher_3.1", "src\WebMetricPusher_3.1\WebMetricPusher_3.1.csproj", "{FC8559F9-D535-47C7-9964-AE754E8FB158}"
1717
EndProject

src/WebHttpRequestDurations_3.1/Controllers/CounterController.cs renamed to src/HttpRequestDurations/Controllers/CounterController.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,28 @@
22
using Microsoft.AspNetCore.Mvc;
33
using Prometheus.Client;
44

5-
namespace WebHttpRequestDurations.Controllers;
5+
namespace HttpRequestDurations.Controllers;
66

77
[Route("[controller]")]
88
public class CounterController : Controller
99
{
1010
private readonly ICounter _counter;
1111
private readonly ICounter _counterTs;
1212
private readonly IMetricFamily<ICounter, ValueTuple<string, string>> _conterLabel;
13-
13+
1414
public CounterController(IMetricFactory metricFactory)
1515
{
1616
_counter = metricFactory.CreateCounter("my_counter", "some help about this");
1717
_conterLabel = metricFactory.CreateCounter("my_counter_label", "some help about this", ("label1","label2"));
1818
_counterTs = metricFactory.CreateCounter("my_counter_ts", "some help about this", true);
1919
}
20-
20+
2121
[HttpGet]
2222
public IActionResult Get()
23-
{
23+
{
2424
_counter.Inc();
2525
_counterTs.Inc(3);
2626
_conterLabel.WithLabels(("my_label", "my_label2")).Inc();
2727
return Ok();
2828
}
29-
}
29+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System;
2+
using Microsoft.AspNetCore.Mvc;
3+
using Prometheus.Client;
4+
5+
namespace HttpRequestDurations.Controllers;
6+
7+
[Route("[controller]")]
8+
public class HistogramController : Controller
9+
{
10+
private readonly IMetricFamily<IHistogram, ValueTuple<string>> _histogram;
11+
12+
public HistogramController(IMetricFactory metricFactory)
13+
{
14+
_histogram = metricFactory.CreateHistogram("test_hist", "help_text", ValueTuple.Create("params1"));
15+
}
16+
17+
[HttpGet]
18+
public IActionResult Get()
19+
{
20+
_histogram.WithLabels("test1").Observe(1);
21+
_histogram.WithLabels("test2").Observe(2);
22+
return Ok();
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22
<PropertyGroup>
3-
<TargetFramework>netcoreapp3.1</TargetFramework>
4-
<RootNamespace>WebHttpRequestDurations</RootNamespace>
5-
<InvariantGlobalization>true</InvariantGlobalization>
3+
<TargetFramework>net6.0</TargetFramework>
64
</PropertyGroup>
75
<ItemGroup>
86
<PackageReference Include="Prometheus.Client" Version="5.2.0" />
97
<PackageReference Include="Prometheus.Client.AspNetCore" Version="5.0.0" />
108
<PackageReference Include="Prometheus.Client.DependencyInjection" Version="1.4.0" />
11-
<PackageReference Include="Prometheus.Client.HttpRequestDurations" Version="3.6.0" />
9+
<PackageReference Include="Prometheus.Client.HttpRequestDurations" Version="3.6.0.131-g1e3d7fa" />
1210
</ItemGroup>
1311
</Project>

src/WebHttpRequestDurations_3.1/Program.cs renamed to src/HttpRequestDurations/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using Microsoft.AspNetCore.Hosting;
22
using Microsoft.Extensions.Hosting;
33

4-
namespace WebHttpRequestDurations;
4+
namespace HttpRequestDurations;
55

66
public class Program
77
{
@@ -16,4 +16,4 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
1616
{
1717
webBuilder.UseStartup<Startup>();
1818
});
19-
}
19+
}

src/WebHttpRequestDurations_3.1/Startup.cs renamed to src/HttpRequestDurations/Startup.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
using Prometheus.Client.DependencyInjection;
1010
using Prometheus.Client.HttpRequestDurations;
1111

12-
namespace WebHttpRequestDurations;
12+
namespace HttpRequestDurations;
1313

1414
public class Startup
1515
{
@@ -20,14 +20,12 @@ public Startup(IConfiguration configuration)
2020

2121
public IConfiguration Configuration { get; }
2222

23-
// This method gets called by the runtime. Use this method to add services to the container.
2423
public void ConfigureServices(IServiceCollection services)
2524
{
2625
services.AddControllers();
2726
services.AddMetricFactory();
2827
}
2928

30-
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
3129
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
3230
{
3331
app.UseRouting();
@@ -52,7 +50,6 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
5250
{ new Regex(@"\/[0-9]{1,}(?![a-z])"), "/id" }
5351
};
5452

55-
// Just for example. Not for Production
5653
q.CustomLabels = new Dictionary<string, Func<string>>
5754
{
5855
{
@@ -69,4 +66,4 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
6966
endpoints.MapControllers();
7067
});
7168
}
72-
}
69+
}

src/WebHttpRequestDurations_3.1/Controllers/HistogramController.cs

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/WebHttpRequestDurations_3.1/appsettings.Development.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/WebHttpRequestDurations_3.1/appsettings.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)