Skip to content

Commit

Permalink
Remove TODO's
Browse files Browse the repository at this point in the history
  • Loading branch information
unaizorrilla committed May 18, 2020
1 parent 5ae387d commit 40f44ce
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 51 deletions.
4 changes: 2 additions & 2 deletions build/dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@
<HealthCheckUIMySqlStorage>3.1.1-preview3</HealthCheckUIMySqlStorage>
<HealthCheckPublisherAppplicationInsights>3.1.1</HealthCheckPublisherAppplicationInsights>
<HealthCheckPublisherDatadog>3.1.1</HealthCheckPublisherDatadog>
<HealthCheckPublisherPrometheus>3.1.2</HealthCheckPublisherPrometheus>
<HealthCheckPrometheusMetrics>3.1.2</HealthCheckPrometheusMetrics>
<HealthCheckPublisherPrometheus>3.1.3</HealthCheckPublisherPrometheus>
<HealthCheckPrometheusMetrics>3.1.3</HealthCheckPrometheusMetrics>
<HealthCheckAWSS3>3.1.1</HealthCheckAWSS3>
<HealthCheckKeyVault>3.1.1</HealthCheckKeyVault>
<HealthCheckPublisherSeq>3.1.1</HealthCheckPublisherSeq>
Expand Down
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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public abstract class LivenessPrometheusMetrics

internal LivenessPrometheusMetrics()
{
// TODO: Allow injecting a custom registry
Registry = global::Prometheus.Metrics.DefaultRegistry;
var factory = global::Prometheus.Metrics.WithCustomRegistry(Registry);

Expand Down
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;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public abstract class LivenessPrometheusMetrics

internal LivenessPrometheusMetrics()
{
// TODO: Allow injecting a custom registry
Registry = Metrics.DefaultRegistry;
var factory = Metrics.WithCustomRegistry(Registry);

Expand Down

0 comments on commit 40f44ce

Please sign in to comment.