Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editorial changes for new health checks #2106

Merged
merged 2 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AspNetCore.Diagnostics.HealthChecks.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{A5A8CE48
Directory.Build.targets = Directory.Build.targets
docker-compose.yml = docker-compose.yml
.github\labeler.yml = .github\labeler.yml
build\strongNameKey.snk = build\strongNameKey.snk
build\versions.props = build\versions.props
EndProjectSection
EndProject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.Extensions.DependencyInjection;
/// </summary>
public static class AzureTablesServiceHealthChecksBuilderExtensions
{
private const string HEALTH_CHECK_NAME = "azure_tables";
private const string NAME = "azure_tables";

/// <summary>
/// Add a health check for Azure Tables Service by registering <see cref="AzureTableServiceHealthCheck"/> for given <paramref name="builder"/>.
Expand All @@ -23,7 +23,7 @@ public static class AzureTablesServiceHealthChecksBuilderExtensions
/// An optional factory to obtain <see cref="AzureTableServiceHealthCheckOptions"/> used by the health check.
/// When not provided, defaults are used.
/// </param>
/// <param name="healthCheckName">The health check name. Optional. If <c>null</c> the name 'azure_tables' will be used.</param>
/// <param name="name">The health check name. Optional. If <c>null</c> the name 'azure_tables' will be used.</param>
/// <param name="failureStatus">
/// The <see cref="HealthStatus"/> that should be reported when the health check fails. Optional. If <c>null</c> then
/// the default status of <see cref="HealthStatus.Unhealthy"/> will be reported.
Expand All @@ -35,13 +35,13 @@ public static IHealthChecksBuilder AddAzureTable(
this IHealthChecksBuilder builder,
Func<IServiceProvider, TableServiceClient>? clientFactory = default,
Func<IServiceProvider, AzureTableServiceHealthCheckOptions>? optionsFactory = default,
string? healthCheckName = HEALTH_CHECK_NAME,
string? name = NAME,
HealthStatus? failureStatus = default,
IEnumerable<string>? tags = default,
TimeSpan? timeout = default)
{
return builder.Add(new HealthCheckRegistration(
string.IsNullOrEmpty(healthCheckName) ? HEALTH_CHECK_NAME : healthCheckName!,
name ?? NAME,
sp => new AzureTableServiceHealthCheck(
tableServiceClient: clientFactory?.Invoke(sp) ?? sp.GetRequiredService<TableServiceClient>(),
options: optionsFactory?.Invoke(sp)),
Expand Down
2 changes: 1 addition & 1 deletion src/HealthChecks.Azure.Data.Tables/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ You can additionally add the following parameters:

- `clientFactory`: A factory method to provide `TableServiceClient` instance.
- `optionsFactory`: A factory method to provide `AzureTableServiceHealthCheckOptions` instance. It allows to specify the table name.
- `healthCheckName`: The health check name. The default is `azure_tables`.
- `name`: The health check name. The default is `azure_tables`.
- `failureStatus`: The `HealthStatus` that should be reported when the health check fails. Default is `HealthStatus.Unhealthy`.
- `tags`: A list of tags that can be used to filter sets of health checks.
- `timeout`: A `System.TimeSpan` representing the timeout of the check.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public sealed class AzureKeyVaultSecretsHealthCheck : IHealthCheck
/// <remarks>
/// It uses the provided <paramref name="secretClient"/> to get given <see cref="AzureKeyVaultSecretsHealthCheckOptions.SecretName"/> secret via
/// <see cref="SecretClient.GetSecretAsync(string, string, CancellationToken)"/> method.
/// When the secret is not found, it will try to create it if <see cref="AzureKeyVaultSecretsHealthCheckOptions.CreateWhenNotFound"/> is set to true.
/// When the secret is not found, but <see cref="AzureKeyVaultSecretsHealthCheckOptions.CreateWhenNotFound"/> is false, it returns <see cref="HealthStatus.Healthy"/> status,
/// When the secret is not found, it will try to create it if <see cref="AzureKeyVaultSecretsHealthCheckOptions.CreateWhenNotFound"/> is set to <see langword="true"/>.
/// When the secret is not found, but <see cref="AzureKeyVaultSecretsHealthCheckOptions.CreateWhenNotFound"/> is <see langword="false"/>, it returns <see cref="HealthStatus.Healthy"/> status,
/// as the connection to the service itself can be made.
/// </remarks>
public AzureKeyVaultSecretsHealthCheck(SecretClient secretClient, AzureKeyVaultSecretsHealthCheckOptions? options = default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public string SecretName

/// <summary>
/// A boolean value that indicates whether the secret should be created when it's not found.
/// False by default.
/// <see langword="false"/> by default.
/// </summary>
/// <remarks>
/// Enabling it requires secret set permissions and can be used to improve performance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.Extensions.DependencyInjection;
/// </summary>
public static class AzureKeyVaultHealthChecksBuilderExtensions
{
private const string HEALTH_CHECK_NAME = "azure_key_vault_secret";
private const string NAME = "azure_key_vault_secret";

/// <summary>
/// Add a health check for Azure Key Vault Secrets by registering <see cref="AzureKeyVaultSecretsHealthCheck"/> for given <paramref name="builder"/>.
Expand All @@ -23,7 +23,7 @@ public static class AzureKeyVaultHealthChecksBuilderExtensions
/// An optional factory to obtain <see cref="AzureKeyVaultSecretsHealthCheckOptions"/> used by the health check.
/// When not provided, defaults are used.
/// </param>
/// <param name="healthCheckName">The health check name. Optional. If <c>null</c> the name 'azure_key_vault_secret' will be used.</param>
/// <param name="name">The health check name. Optional. If <c>null</c> the name 'azure_key_vault_secret' will be used.</param>
/// <param name="failureStatus">
/// The <see cref="HealthStatus"/> that should be reported when the health check fails. Optional. If <c>null</c> then
/// the default status of <see cref="HealthStatus.Unhealthy"/> will be reported.
Expand All @@ -35,13 +35,13 @@ public static IHealthChecksBuilder AddAzureKeyVaultSecrets(
this IHealthChecksBuilder builder,
Func<IServiceProvider, SecretClient>? clientFactory = default,
Func<IServiceProvider, AzureKeyVaultSecretsHealthCheckOptions>? optionsFactory = default,
string? healthCheckName = HEALTH_CHECK_NAME,
string? name = NAME,
HealthStatus? failureStatus = default,
IEnumerable<string>? tags = default,
TimeSpan? timeout = default)
{
return builder.Add(new HealthCheckRegistration(
string.IsNullOrEmpty(healthCheckName) ? HEALTH_CHECK_NAME : healthCheckName!,
name ?? NAME,
sp => new AzureKeyVaultSecretsHealthCheck(
secretClient: clientFactory?.Invoke(sp) ?? sp.GetRequiredService<SecretClient>(),
options: optionsFactory?.Invoke(sp)),
Expand Down
4 changes: 2 additions & 2 deletions src/HealthChecks.Azure.KeyVault.Secrets/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Azure KeyVault Health Check
## Azure KeyVault Secrets Health Check

This health check verifies the ability to communicate with [Azure Key Vault Secrets](https://azure.microsoft.com/services/key-vault/). It uses the provided [SecretClient](https://learn.microsoft.com/dotnet/api/azure.security.keyvault.secrets.secretclient) to get configured secret. When the connection to the service itself can be made, but secret is not found, it returns `HealthStatus.Healthy` status.

Expand All @@ -20,7 +20,7 @@ You can additionally add the following parameters:

- `clientFactory`: A factory method to provide `SecretClient` instance.
- `optionsFactory`: A factory method to provide `AzureKeyVaultSecretsHealthCheckOptions` instance. It allows to specify the secret name and whether the secret should be created when it's not found.
- `healthCheckName`: The health check name. The default is `azure_key_vault_secret`.
- `name`: The health check name. The default is `azure_key_vault_secret`.
- `failureStatus`: The `HealthStatus` that should be reported when the health check fails. Default is `HealthStatus.Unhealthy`.
- `tags`: A list of tags that can be used to filter sets of health checks.
- `timeout`: A `System.TimeSpan` representing the timeout of the check.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.Extensions.DependencyInjection;
/// </summary>
public static class AzureEventHubHealthChecksBuilderExtensions
{
private const string HEALTH_CHECK_NAME = "azure_event_hub";
private const string NAME = "azure_event_hub";

/// <summary>
/// Add a health check for Azure Event Hub by registering <see cref="AzureEventHubHealthCheck"/> for given <paramref name="builder"/>.
Expand All @@ -19,7 +19,7 @@ public static class AzureEventHubHealthChecksBuilderExtensions
/// An optional factory to obtain <see cref="EventHubProducerClient" /> instance.
/// When not provided, <see cref="EventHubProducerClient" /> is simply resolved from <see cref="IServiceProvider"/>.
/// </param>
/// <param name="healthCheckName">The health check name. Optional. If <c>null</c> the name 'azure_event_hub' will be used.</param>
/// <param name="name">The health check name. Optional. If <c>null</c> the name 'azure_event_hub' will be used.</param>
/// <param name="failureStatus">
/// The <see cref="HealthStatus"/> that should be reported when the health check fails. Optional. If <c>null</c> then
/// the default status of <see cref="HealthStatus.Unhealthy"/> will be reported.
Expand All @@ -30,13 +30,13 @@ public static class AzureEventHubHealthChecksBuilderExtensions
public static IHealthChecksBuilder AddAzureEventHub(
this IHealthChecksBuilder builder,
Func<IServiceProvider, EventHubProducerClient>? clientFactory = default,
string? healthCheckName = HEALTH_CHECK_NAME,
string? name = NAME,
HealthStatus? failureStatus = default,
IEnumerable<string>? tags = default,
TimeSpan? timeout = default)
{
return builder.Add(new HealthCheckRegistration(
string.IsNullOrEmpty(healthCheckName) ? HEALTH_CHECK_NAME : healthCheckName!,
name ?? NAME,
sp => new AzureEventHubHealthCheck(clientFactory?.Invoke(sp) ?? sp.GetRequiredService<EventHubProducerClient>()),
failureStatus,
tags,
Expand Down
4 changes: 2 additions & 2 deletions src/HealthChecks.Azure.Messaging.EventHubs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ void Configure(IHealthChecksBuilder builder)
.AddKeyedSingleton(serviceKey: "eventHubName1", (serviceProvider, serviceKey) => new EventHubProducerClient("fullyQualifiedNamespace", "eventHubName1", new DefaultAzureCredential()))
.AddKeyedSingleton(serviceKey: "eventHubName2", (serviceProvider, serviceKey) => new EventHubProducerClient("fullyQualifiedNamespace", "eventHubName2", new DefaultAzureCredential()))
.AddHealthChecks()
.AddAzureKeyVaultSecrets(clientFactory: serviceProvider => serviceProvider.GetRequiredKeyedService<EventHubProducerClient>("eventHubName1"), healthCheckName: "event_hub_1")
.AddAzureKeyVaultSecrets(clientFactory: serviceProvider => serviceProvider.GetRequiredKeyedService<EventHubProducerClient>("eventHubName2"), healthCheckName: "event_hub_2");
.AddAzureKeyVaultSecrets(clientFactory: serviceProvider => serviceProvider.GetRequiredKeyedService<EventHubProducerClient>("eventHubName1"), name: "event_hub_1")
.AddAzureKeyVaultSecrets(clientFactory: serviceProvider => serviceProvider.GetRequiredKeyedService<EventHubProducerClient>("eventHubName2"), name: "event_hub_2");

}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.Extensions.DependencyInjection;
/// </summary>
public static class AzureBlobStorageHealthChecksBuilderExtensions
{
private const string HEALTH_CHECK_NAME = "azure_blob_storage";
private const string NAME = "azure_blob_storage";

/// <summary>
/// Add a health check for Azure Blob Storage by registering <see cref="AzureBlobStorageHealthCheck"/> for given <paramref name="builder"/>.
Expand All @@ -23,7 +23,7 @@ public static class AzureBlobStorageHealthChecksBuilderExtensions
/// An optional factory to obtain <see cref="AzureBlobStorageHealthCheckOptions"/> used by the health check.
/// When not provided, defaults are used.
/// </param>
/// <param name="healthCheckName">The health check name. Optional. If <c>null</c> the name 'azure_blob_storage' will be used.</param>
/// <param name="name">The health check name. Optional. If <c>null</c> the name 'azure_blob_storage' will be used.</param>
/// <param name="failureStatus">
/// The <see cref="HealthStatus"/> that should be reported when the health check fails. Optional. If <c>null</c> then
/// the default status of <see cref="HealthStatus.Unhealthy"/> will be reported.
Expand All @@ -35,13 +35,13 @@ public static IHealthChecksBuilder AddAzureBlobStorage(
this IHealthChecksBuilder builder,
Func<IServiceProvider, BlobServiceClient>? clientFactory = default,
Func<IServiceProvider, AzureBlobStorageHealthCheckOptions>? optionsFactory = default,
string? healthCheckName = HEALTH_CHECK_NAME,
string? name = NAME,
HealthStatus? failureStatus = default,
IEnumerable<string>? tags = default,
TimeSpan? timeout = default)
{
return builder.Add(new HealthCheckRegistration(
string.IsNullOrEmpty(healthCheckName) ? HEALTH_CHECK_NAME : healthCheckName!,
name ?? NAME,
sp => new AzureBlobStorageHealthCheck(
blobServiceClient: clientFactory?.Invoke(sp) ?? sp.GetRequiredService<BlobServiceClient>(),
options: optionsFactory?.Invoke(sp)),
Expand Down
2 changes: 1 addition & 1 deletion src/HealthChecks.Azure.Storage.Blobs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ You can additionally add the following parameters:

- `clientFactory`: A factory method to provide `BlobServiceClient` instance.
- `optionsFactory`: A factory method to provide `AzureBlobStorageHealthCheckOptions` instance. It allows to specify the container name.
- `healthCheckName`: The health check name. The default is `azure_blob_storage`.
- `name`: The health check name. The default is `azure_blob_storage`.
- `failureStatus`: The `HealthStatus` that should be reported when the health check fails. Default is `HealthStatus.Unhealthy`.
- `tags`: A list of tags that can be used to filter sets of health checks.
- `timeout`: A `System.TimeSpan` representing the timeout of the check.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.Extensions.DependencyInjection;
/// </summary>
public static class AzureFileShareStorageHealthChecksBuilderExtensions
{
private const string HEALTH_CHECK_NAME = "azure_file_share";
private const string NAME = "azure_file_share";

/// <summary>
/// Add a health check for Azure Files by registering <see cref="AzureFileShareHealthCheck"/> for given <paramref name="builder"/>.
Expand All @@ -23,7 +23,7 @@ public static class AzureFileShareStorageHealthChecksBuilderExtensions
/// An optional factory to obtain <see cref="AzureFileShareHealthCheckOptions"/> used by the health check.
/// When not provided, defaults are used.
/// </param>
/// <param name="healthCheckName">The health check name. Optional. If <c>null</c> the name 'azure_file_share' will be used.</param>
/// <param name="name">The health check name. Optional. If <c>null</c> the name 'azure_file_share' will be used.</param>
/// <param name="failureStatus">
/// The <see cref="HealthStatus"/> that should be reported when the health check fails. Optional. If <c>null</c> then
/// the default status of <see cref="HealthStatus.Unhealthy"/> will be reported.
Expand All @@ -35,13 +35,13 @@ public static IHealthChecksBuilder AddAzureFileShare(
this IHealthChecksBuilder builder,
Func<IServiceProvider, ShareServiceClient>? clientFactory = default,
Func<IServiceProvider, AzureFileShareHealthCheckOptions>? optionsFactory = default,
string? healthCheckName = HEALTH_CHECK_NAME,
string? name = NAME,
HealthStatus? failureStatus = default,
IEnumerable<string>? tags = default,
TimeSpan? timeout = default)
{
return builder.Add(new HealthCheckRegistration(
string.IsNullOrEmpty(healthCheckName) ? HEALTH_CHECK_NAME : healthCheckName!,
name ?? NAME,
sp => new AzureFileShareHealthCheck(
shareServiceClient: clientFactory?.Invoke(sp) ?? sp.GetRequiredService<ShareServiceClient>(),
options: optionsFactory?.Invoke(sp)),
Expand Down
2 changes: 1 addition & 1 deletion src/HealthChecks.Azure.Storage.Files.Shares/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ You can additionally add the following parameters:

- `clientFactory`: A factory method to provide `ShareServiceClient` instance.
- `optionsFactory`: A factory method to provide `AzureFileShareHealthCheckOptions` instance. It allows to specify the share name.
- `healthCheckName`: The health check name. The default is `azure_file_share`.
- `name`: The health check name. The default is `azure_file_share`.
- `failureStatus`: The `HealthStatus` that should be reported when the health check fails. Default is `HealthStatus.Unhealthy`.
- `tags`: A list of tags that can be used to filter sets of health checks.
- `timeout`: A `System.TimeSpan` representing the timeout of the check.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.Extensions.DependencyInjection;
/// </summary>
public static class AzureQueueStorageHealthChecksBuilderExtensions
{
private const string HEALTH_CHECK_NAME = "azure_queue_storage";
private const string NAME = "azure_queue_storage";

/// <summary>
/// Add a health check for Azure Queue Storage by registering <see cref="AzureQueueStorageHealthCheck"/> for given <paramref name="builder"/>.
Expand All @@ -23,7 +23,7 @@ public static class AzureQueueStorageHealthChecksBuilderExtensions
/// An optional factory to obtain <see cref="AzureQueueStorageHealthCheckOptions"/> used by the health check.
/// When not provided, defaults are used.
/// </param>
/// <param name="healthCheckName">The health check name. Optional. If <c>null</c> the name 'azure_queue_storage' will be used.</param>
/// <param name="name">The health check name. Optional. If <c>null</c> the name 'azure_queue_storage' will be used.</param>
/// <param name="failureStatus">
/// The <see cref="HealthStatus"/> that should be reported when the health check fails. Optional. If <c>null</c> then
/// the default status of <see cref="HealthStatus.Unhealthy"/> will be reported.
Expand All @@ -35,13 +35,13 @@ public static IHealthChecksBuilder AddAzureQueueStorage(
this IHealthChecksBuilder builder,
Func<IServiceProvider, QueueServiceClient>? clientFactory = default,
Func<IServiceProvider, AzureQueueStorageHealthCheckOptions>? optionsFactory = default,
string? healthCheckName = HEALTH_CHECK_NAME,
string? name = NAME,
HealthStatus? failureStatus = default,
IEnumerable<string>? tags = default,
TimeSpan? timeout = default)
{
return builder.Add(new HealthCheckRegistration(
string.IsNullOrEmpty(healthCheckName) ? HEALTH_CHECK_NAME : healthCheckName!,
name ?? NAME,
sp => new AzureQueueStorageHealthCheck(
queueServiceClient: clientFactory?.Invoke(sp) ?? sp.GetRequiredService<QueueServiceClient>(),
options: optionsFactory?.Invoke(sp)),
Expand Down
2 changes: 1 addition & 1 deletion src/HealthChecks.Azure.Storage.Queues/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ You can additionally add the following parameters:

- `clientFactory`: A factory method to provide `QueueServiceClient` instance.
- `optionsFactory`: A factory method to provide `AzureQueueStorageHealthCheckOptions` instance. It allows to specify the queue name.
- `healthCheckName`: The health check name. The default is `azure_queue_storage`.
- `name`: The health check name. The default is `azure_queue_storage`.
- `failureStatus`: The `HealthStatus` that should be reported when the health check fails. Default is `HealthStatus.Unhealthy`.
- `tags`: A list of tags that can be used to filter sets of health checks.
- `timeout`: A `System.TimeSpan` representing the timeout of the check.
Expand Down
Loading