-
Notifications
You must be signed in to change notification settings - Fork 809
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ae387d
commit 40f44ce
Showing
5 changed files
with
49 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 15 additions & 15 deletions
30
src/HealthChecks.Prometheus.Metrics/Extensions/ApplicationBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
using HealthChecks.Prometheus.Metrics; | ||
using Microsoft.AspNetCore.Diagnostics.HealthChecks; | ||
using Microsoft.AspNetCore.Http; | ||
|
||
using Microsoft.AspNetCore.Diagnostics.HealthChecks; | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace Microsoft.AspNetCore.Builder | ||
{ | ||
public static class PrometheusHealthCheckMiddleware | ||
{ | ||
public static IApplicationBuilder UseHealthChecksPrometheusExporter(this IApplicationBuilder applicationBuilder, PathString endpoint) | ||
{ | ||
applicationBuilder.UseHealthChecks(endpoint, new HealthCheckOptions | ||
{ | ||
ResponseWriter = PrometheusResponseWriter.WritePrometheusResultText | ||
}); | ||
return applicationBuilder; | ||
} | ||
} | ||
{ | ||
public static class PrometheusHealthCheckMiddleware | ||
{ | ||
public static IApplicationBuilder UseHealthChecksPrometheusExporter(this IApplicationBuilder applicationBuilder, PathString endpoint) | ||
{ | ||
applicationBuilder.UseHealthChecks(endpoint, new HealthCheckOptions | ||
{ | ||
ResponseWriter = PrometheusResponseWriter.WritePrometheusResultText | ||
}); | ||
return applicationBuilder; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 32 additions & 32 deletions
64
...Publisher.Prometheus/DependencyInjection/PrometheusGatewayHealthCheckBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
using HealthChecks.Publisher.Prometheus; | ||
using Microsoft.Extensions.Diagnostics.HealthChecks; | ||
using HealthChecks.Publisher.Prometheus; | ||
using Microsoft.Extensions.Diagnostics.HealthChecks; | ||
using System; | ||
using System.Net.Http; | ||
|
||
namespace Microsoft.Extensions.DependencyInjection | ||
{ | ||
public static class PrometheusGatewayHealthCheckBuilderExtensions | ||
{ | ||
/// <summary> | ||
/// Add a health check publisher for Prometheus Gateway. | ||
/// </summary> | ||
/// <remarks> | ||
/// For each <see cref="HealthReport" /> published a new metric value indicating the health check status (2 Healthy, 1 | ||
/// Degraded, 0 Unhealthy) and the total time the health check took to execute on seconds. | ||
/// </remarks> | ||
/// <param name="builder">The <see cref="IHealthChecksBuilder" />.</param> | ||
/// <param name="endpoint">Endpoint url e.g. http://myendpoint:9091</param> | ||
/// <param name="job"> The job name the series can be filtered on (typically the application name).</param> | ||
/// <param name="instance">If there are multiple instances.</param> | ||
/// <returns>The <see cref="IHealthChecksBuilder" />.</returns> | ||
[Obsolete("This package is deprecated! We recomend using the pull model instead of Gateway. Try to use the package AspNetCore.HealthChecks.Prometheus.Metrics instead of.")] | ||
public static IHealthChecksBuilder AddPrometheusGatewayPublisher(this IHealthChecksBuilder builder, | ||
string endpoint, string job, string instance = null) | ||
{ | ||
builder.Services | ||
.AddHttpClient(); | ||
|
||
builder.Services | ||
using System.Net.Http; | ||
|
||
namespace Microsoft.Extensions.DependencyInjection | ||
{ | ||
public static class PrometheusGatewayHealthCheckBuilderExtensions | ||
{ | ||
/// <summary> | ||
/// Add a health check publisher for Prometheus Gateway. | ||
/// </summary> | ||
/// <remarks> | ||
/// For each <see cref="HealthReport" /> published a new metric value indicating the health check status (2 Healthy, 1 | ||
/// Degraded, 0 Unhealthy) and the total time the health check took to execute on seconds. | ||
/// </remarks> | ||
/// <param name="builder">The <see cref="IHealthChecksBuilder" />.</param> | ||
/// <param name="endpoint">Endpoint url e.g. http://myendpoint:9091</param> | ||
/// <param name="job"> The job name the series can be filtered on (typically the application name).</param> | ||
/// <param name="instance">If there are multiple instances.</param> | ||
/// <returns>The <see cref="IHealthChecksBuilder" />.</returns> | ||
[Obsolete("This package is deprecated! We recomend using the pull model instead of Gateway. Try to use the package AspNetCore.HealthChecks.Prometheus.Metrics instead of.")] | ||
public static IHealthChecksBuilder AddPrometheusGatewayPublisher(this IHealthChecksBuilder builder, | ||
string endpoint, string job, string instance = null) | ||
{ | ||
builder.Services | ||
.AddHttpClient(); | ||
|
||
builder.Services | ||
.AddSingleton<IHealthCheckPublisher>(sp => | ||
{ | ||
return new PrometheusGatewayPublisher(() => sp.GetRequiredService<IHttpClientFactory>().CreateClient(), endpoint, job, instance); | ||
}); | ||
|
||
return builder; | ||
}); | ||
|
||
return builder; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters