You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The [App.Metrics.Extensions.HealthChecks](https://www.nuget.org/packages/App.Metrics.Extensions.HealthChecks/) nuget package records AspNetCore health check results as metrics allowing results to be flushed to a supported TSDB via one of the App Metrics metrics [available reporters]({{< ref "reporting/reporters/_index.md" >}}).
9
+
10
+
11
+
## How to use
12
+
13
+
With App Metrics configured in either an AspNetCore application or dotnet core application enable the `Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheckPublisher` implementation to record health check results as metrics on the `IServiceCollection`
Copy file name to clipboardexpand all lines: content/web-monitoring/aspnet-core/reporting.md
+50-13
Original file line number
Diff line number
Diff line change
@@ -6,15 +6,16 @@ weight: 5
6
6
icon: "/images/reporting.png"
7
7
---
8
8
9
-
The [App.Metrics.AspNetCore.Reporting](https://www.nuget.org/packages/App.Metrics.AspNetCore.Reporting/) nuget package provides functionality to schedule metrics reporting using one or more of the [metric reporters]({{< ref "reporting/reporters/_index.md" >}}) in an ASP.NET Core application.
9
+
The [App.Metrics.Extensions.Hosting](https://www.nuget.org/packages/App.Metrics.Extensions.Hosting/) nuget package provides functionality to schedule metrics reporting using one or more of the [metric reporters]({{< ref "reporting/reporters/_index.md" >}}) in an ASP.NET Core application.
10
10
11
-
App Metrics uses an[Microsoft.Extensions.Hosting.IHostedService](https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.hosting.ihostedservice?view=aspnetcore-2.0) implementation for scheduling reporters which is automatically configured if reporting is enabled when using the `UseMetrics`[Microsoft.Extensions.Hosting.IWebHostBuilder](https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.hosting.iwebhostbuilder?view=aspnetcore-2.0) extensions.
11
+
App Metrics uses a[Microsoft.Extensions.Hosting.IHostedService](https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.hosting.ihostedservice?view=aspnetcore-2.0) implementation for scheduling reporters which is automatically configured if reporting is enabled when using the `UseMetrics`[Microsoft.Extensions.Hosting.IHostBuilder](https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.hosting.ihostbuilder?view=dotnet-plat-ext-3.1) extensions.
12
12
13
13
## How to use
14
14
15
-
`App.Metrics.AspNetCore.Reporting` can be configured a couple of ways in an ASP.NET Core application:
15
+
Reporting can be configured a few of ways in an ASP.NET Core application:
16
16
17
-
1. Using the `Microsoft.AspNetCore.WebHost` in a `Program.cs`.
17
+
1. Using the legacy `Microsoft.AspNetCore.WebHost` in a `Program.cs`.
18
+
1. Using the `Microsoft.Extensions.Hosting.Host` in a `Program.cs`.
18
19
1. Using the `Microsoft.AspNetCore.Builder.IApplicationBuilder` in a `Startup.cs`.
19
20
20
21
<iclass="fa fa-hand-o-right"></i> First create a [new ASP.NET Core MVC project](https://docs.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/start-mvc).
@@ -23,10 +24,10 @@ App Metrics uses an [Microsoft.Extensions.Hosting.IHostedService](https://docs.m
23
24
24
25
This is a simpler approach as it will wire up the App Metrics feature middleware on the IApplicationBuilder, as well as the metrics infrastructure on the `IServiceCollection` for you.
25
26
26
-
<iclass="fa fa-hand-o-right"></i> First install the [nuget package](https://www.nuget.org/packages/App.Metrics.AspNetCore/):
27
+
<iclass="fa fa-hand-o-right"></i> First install the [nuget package](https://www.nuget.org/packages/App.Metrics.AspNetCore.All/):
27
28
28
29
```console
29
-
nuget install App.Metrics.AspNetCore
30
+
nuget install App.Metrics.AspNetCore.All
30
31
```
31
32
32
33
<iclass="fa fa-hand-o-right"></i> Then modify the `Program.cs` using the `UseMetrics` extension on `IWebHostBuilder` to configure all the App Metrics defaults including report scheduling, and also the `ConfigureMetricsWithDefaults` extension method to add the desired [metrics reporter(s)]({{< ref "reporting/reporters/_index.md" >}}).
The [App.Metrics.AspNetCore](https://www.nuget.org/packages/App.Metrics.AspNetCore/) nuget packages is sort of a meta package which references other App Metrics ASP.NET core features. If it is preferred to cherry pick App Metrics ASP.NET Core functionality, feature packages can be referenced explicity instead, in this case we can configure App Metrics report scheduling using `IApplicationBuider` extensions in the `Startup.cs`.
58
+
This is a simpler approach as it will wire up the App Metrics feature middleware on the IApplicationBuilder, as well as the metrics infrastructure on the `IServiceCollection` for you.
58
59
59
-
<iclass="fa fa-hand-o-right"></i> First install the [nuget package](https://www.nuget.org/packages/App.Metrics.AspNetCore.Reporting/):
60
+
<iclass="fa fa-hand-o-right"></i> First install the [nuget package](https://www.nuget.org/packages/App.Metrics.AspNetCore.All/):
60
61
61
62
```console
62
-
nuget install App.Metrics.AspNetCore.Reporting
63
+
nuget install App.Metrics.AspNetCore.All
63
64
```
64
65
65
-
{{% notice note %}}
66
-
The `App.Metrics.AspNetCore.Reporting` nuget package only references core ASP.NET Core App Metrics functionality rather than all available feature packages.
66
+
<iclass="fa fa-hand-o-right"></i> Then modify the `Program.cs` using the `UseMetrics` extension on `IHostBuilder` to configure all the App Metrics defaults including report scheduling, and also the `ConfigureMetricsWithDefaults` extension method to add the desired [metrics reporter(s)]({{< ref "reporting/reporters/_index.md" >}}).
The same approach can be used for non-web applications using the Hosting building via the [App.Metrics.App.All](https://www.nuget.org/packages/App.Metrics.App.All/) nuget package.
67
94
{{% /notice %}}
68
95
96
+
### Bootstrapping Startup.cs
97
+
98
+
The [App.Metrics.AspNetCore.All](https://www.nuget.org/packages/App.Metrics.AspNetCore.All/) nuget packages is a metapackage which references all App Metrics ASP.NET core features. If it is preferred to cherry pick App Metrics ASP.NET Core functionality, feature packages can be referenced explicity instead, in this case we can configure App Metrics report scheduling using `IApplicationBuider` extensions in the `Startup.cs`.
99
+
100
+
<iclass="fa fa-hand-o-right"></i> First install the [nuget package](https://www.nuget.org/packages/App.Metrics.AspNetCore.All/):
101
+
102
+
```console
103
+
nuget install App.Metrics.AspNetCore.All
104
+
```
105
+
69
106
<iclass="fa fa-hand-o-right"></i> Then modify the `Startup.cs` to add App Metrics and the metrics report scheduling feature using the `IServiceCollection` extensions:
70
107
71
108
```csharp
@@ -91,7 +128,7 @@ public class Startup
91
128
```
92
129
93
130
{{% notice info %}}
94
-
The `App.Metrics.AspNetCore.Reporting` nuget package does not reference any metric reporter packages, install and configure one of the [available reporters]({{< ref "reporting/reporters/_index.md" >}}) in the *"configure a reporter"* comment in the previous code snippet.
131
+
The `App.Metrics.AspNetCore.All` nuget package does not reference any metric reporter packages, install and configure one of the [available reporters]({{< ref "reporting/reporters/_index.md" >}}) in the *"configure a reporter"* comment in the previous code snippet.
0 commit comments