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

Aleshchev/k8s insights #7

Merged
merged 2 commits into from
May 9, 2024
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
11 changes: 11 additions & 0 deletions src/Bss.Platform.Kubernetes/Bss.Platform.Kubernetes.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Luxoft.Bss.Platform.Kubernetes</PackageId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" />
</ItemGroup>
</Project>
32 changes: 32 additions & 0 deletions src/Bss.Platform.Kubernetes/DependencyInjection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Microsoft.ApplicationInsights.DependencyCollector;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace Bss.Platform.Kubernetes;

public static class DependencyInjection
{
private const string SqlHealthCheck = "SQLCheck";

public static IServiceCollection AddPlatformKubernetesInsights(this IServiceCollection services, IConfiguration configuration) =>
services
.AddApplicationInsightsTelemetry(configuration)
.ConfigureTelemetryModule<DependencyTrackingTelemetryModule>((x, _) => { x.EnableSqlCommandTextInstrumentation = true; })
.AddApplicationInsightsKubernetesEnricher();

public static IServiceCollection AddPlatformKubernetesHealthChecks(this IServiceCollection services, string connectionString)
{
services
.AddHealthChecks()
.AddSqlServer(connectionString, name: SqlHealthCheck);

return services;
}

public static IApplicationBuilder UsePlatformKubernetesHealthChecks(this IApplicationBuilder app) =>
app
.UseHealthChecks("/health/live", new HealthCheckOptions { Predicate = _ => false })
.UseHealthChecks("/health/ready", new HealthCheckOptions { Predicate = x => x.Name == SqlHealthCheck });
}
9 changes: 9 additions & 0 deletions src/Bss.Platform.sln
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Api", "Api", "{8F22FE4E-8FD
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bss.Platform.Api.Documentation", "Bss.Platform.Api.Documentation\Bss.Platform.Api.Documentation.csproj", "{0005DAE1-3F66-4A98-A11B-DEFDF2BD7EA3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Kubernetes", "Kubernetes", "{51F57F48-6CDC-43E2-90DA-B73C12EA2185}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bss.Platform.Kubernetes", "Bss.Platform.Kubernetes\Bss.Platform.Kubernetes.csproj", "{1BD00077-8005-42E9-AEFE-62A21E057858}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -34,6 +38,7 @@ Global
{16BA5D44-4C8F-4EF6-9633-C4502ED91A22} = {C53E37ED-7EFD-4383-9D89-A3CD4B8ED2AB}
{2417B26C-C12D-4E63-8996-395DD78F81A1} = {D07584C3-F6D5-472C-8515-7D38F4C54F11}
{0005DAE1-3F66-4A98-A11B-DEFDF2BD7EA3} = {8F22FE4E-8FD4-4309-8B47-C33AA6E52052}
{1BD00077-8005-42E9-AEFE-62A21E057858} = {51F57F48-6CDC-43E2-90DA-B73C12EA2185}
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{860BFBD8-26EA-44F9-980E-21B828FC8F72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
Expand All @@ -60,5 +65,9 @@ Global
{0005DAE1-3F66-4A98-A11B-DEFDF2BD7EA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0005DAE1-3F66-4A98-A11B-DEFDF2BD7EA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0005DAE1-3F66-4A98-A11B-DEFDF2BD7EA3}.Release|Any CPU.Build.0 = Release|Any CPU
{1BD00077-8005-42E9-AEFE-62A21E057858}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1BD00077-8005-42E9-AEFE-62A21E057858}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1BD00077-8005-42E9-AEFE-62A21E057858}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1BD00077-8005-42E9-AEFE-62A21E057858}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
4 changes: 4 additions & 0 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="AspNetCore.HealthChecks.SqlServer" Version="8.0.2" />
<PackageVersion Include="Microsoft.ApplicationInsights" Version="2.22.0" />
<PackageVersion Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0" />
<PackageVersion Include="Microsoft.ApplicationInsights.Kubernetes" Version="6.1.2" />
<PackageVersion Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="5.2.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
Expand Down
6 changes: 3 additions & 3 deletions src/__SolutionItems/CommonAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
[assembly: AssemblyCompany("Luxoft")]
[assembly: AssemblyCopyright("Copyright © Luxoft 2024")]

[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0.0")]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0.0")]

#if DEBUG
[assembly: AssemblyConfiguration("Debug")]
Expand Down