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

[feat] Add health checks #377

Merged
merged 11 commits into from
Nov 26, 2023
Merged

Conversation

philip-reed
Copy link
Contributor

@philip-reed philip-reed commented Nov 24, 2023

Adds functionality discussed in #366.

Closes #366

Adds support for AspNet Core Health Checks using the HealthChecks.CosmosDb package.

Setup

To configure Cosmos DB health checks:

services.AddHealthChecks().AddCosmosRepository();

By default, this will scan all of the assemblies in your solution to locate the container names for each of your IItem types. To refine this, and potentially reduce startup times, pass in the Assemblies containing your IItem types:

services.AddHealthChecks().AddCosmosRepository(assemblies: typeof(ExampleItem).Assembly);

The Cosmos Repository Health package supports all of the existing functionality of Health Checks, such as failureStatus and tags, see the Microsoft Documentation for configuration details.

@mumby0168
Copy link
Collaborator

@all-contributors please add @philip-reed for docs, code and tests

Copy link
Contributor

@mumby0168

I've put up a pull request to add @philip-reed! 🎉

Philip Reed and others added 6 commits November 24, 2023 12:53
# Conflicts:
#	samples/Microsoft.Azure.CosmosEventSourcing/BasicEventSourcingSample/BasicEventSourcingSample.csproj
#	samples/Microsoft.Azure.CosmosEventSourcing/BasicEventSourcingSample/Program.cs
#	src/Microsoft.Azure.CosmosRepository.AspNetCore/Microsoft.Azure.CosmosRepository.AspNetCore.csproj
Copy link
Collaborator

@mumby0168 mumby0168 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice work.

ICosmosItemConfigurationProvider itemConfigProvider =
sp.GetRequiredService<ICosmosItemConfigurationProvider>();
IEnumerable<string> containers = itemConfigProvider.GetAllItemConfigurations(assemblies)
.Select(i => i.ContainerName).Distinct();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.Select(i => i.ContainerName).Distinct();
.DistinctBy(i => i.ContainerName);

@IEvangelist IEvangelist merged commit 0f8bd8a into IEvangelist:main Nov 26, 2023
3 checks passed
@philip-reed philip-reed deleted the addHealthChecks branch November 27, 2023 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide a way to integrate with AspNetCore.Diagnostics.HealthChecks
3 participants