Skip to content
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
Binary file added .assets/Nano-Application-Architecture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- master
env:
APP_NAME: Nano.Library
VERSION: 10.0.0-rc5
VERSION: 10.0.0
jobs:
build-and-deploy:
runs-on: windows-latest
Expand Down
6 changes: 3 additions & 3 deletions .tests/Tests.Nano.Library/Tests.Nano.Library.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

<ItemGroup>
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.5.0" />
<PackageReference Include="MSTest.TestAdapter" Version="4.2.1" />
<PackageReference Include="MSTest.TestFramework" Version="4.2.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.8.1" />
<PackageReference Include="MSTest.TestAdapter" Version="4.3.2" />
<PackageReference Include="MSTest.TestFramework" Version="4.3.2" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions Nano.All/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
***

## Table of Contents
* **[Home](https://github.com/Nano-Core/Nano.Library/tree/master/README.md#nanolibrary)**
* **[Home](https://github.com/Nano-Core/Nano.Library/blob/master/README.md#nanolibrary)**
* **[Summary](#summary)**

## Summary
Includes all Nano packages bundled into a single package for convenience.

> 📖 Explore the full **[Nano Documentation](https://github.com/Nano-Core/Nano.Library/tree/master/README.md#nanolibrary)**.
> 📖 Explore the full **[Nano Documentation](https://github.com/Nano-Core/Nano.Library/blob/master/README.md#nanolibrary)**.

> ⚠️ While this package provides everything out of the box, it’s generally recommended to reference individual Nano packages as needed in your application.
> Learn more about **[Nano NuGet Packages](https://github.com/Nano-Core/Nano.Library#nuget-packages)**.
5 changes: 5 additions & 0 deletions Nano.App.Api/Config/ApiOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public class ApiOptions : BaseAppOptions
/// </summary>
public virtual HealthCheckOptions? HealthCheck { get; set; }

/// <summary>
/// Metrics configuration options.
/// </summary>
public virtual MetricsOptions? Metrics { get; set; }

/// <summary>
/// API documentation options.
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions Nano.App.Api/Config/MetricsOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Nano.App.Api.Config;

/// <summary>
/// Options for configuring metrics behavior.
/// </summary>
public class MetricsOptions;
15 changes: 15 additions & 0 deletions Nano.App.Api/Extensions/ApplicationBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -678,4 +678,19 @@ internal static IApplicationBuilder UseNanoHealthChecks(this IApplicationBuilder

return applicationBuilder;
}

internal static IApplicationBuilder UseNanoMetrics(this IApplicationBuilder applicationBuilder, MetricsOptions? options = null)
{
ArgumentNullException.ThrowIfNull(applicationBuilder);

if (options == null)
{
return applicationBuilder;
}

applicationBuilder
.UseOpenTelemetryPrometheusScrapingEndpoint();

return applicationBuilder;
}
}
24 changes: 22 additions & 2 deletions Nano.App.Api/Extensions/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
using System;
using System.Linq;
using System.Text.Json.Serialization;
using OpenTelemetry.Metrics;
using Vivet.AspNetCore.RequestTimeZone.Enums;
using Vivet.AspNetCore.RequestTimeZone.Extensions;
using Vivet.AspNetCore.RequestTimeZone.Providers;
Expand Down Expand Up @@ -65,8 +66,9 @@ internal static IServiceCollection ConfigureNanoApiServices(this IServiceCollect
.AddNanoFormOptions(options.Hosting.MultipartLimits)
.AddNanoHttpsRedirection(options.Hosting.Http, options.Hosting.Https)
.AddNanoMvc()
.AddNanoMetrics()
.AddNanoDocumentation(options.Documentation)
.AddNanoSelfHealthChecking()
.AddNanoStartupHealthCheck()
.AddHttpContextAccessor();

return services;
Expand Down Expand Up @@ -460,6 +462,24 @@ internal static IServiceCollection AddNanoMvc(this IServiceCollection services)
return services;
}

internal static IServiceCollection AddNanoMetrics(this IServiceCollection services)
{
ArgumentNullException.ThrowIfNull(services);

services
.AddOpenTelemetry()
.WithMetrics(metrics =>
{
metrics
.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddRuntimeInstrumentation()
.AddPrometheusExporter();
});

return services;
}

internal static IServiceCollection AddNanoDocumentation(this IServiceCollection services, DocumentationOptions? options = null)
{
ArgumentNullException.ThrowIfNull(services);
Expand Down Expand Up @@ -490,7 +510,7 @@ internal static IServiceCollection AddNanoDocumentation(this IServiceCollection
return services;
}

internal static IServiceCollection AddNanoSelfHealthChecking(this IServiceCollection services)
internal static IServiceCollection AddNanoStartupHealthCheck(this IServiceCollection services)
{
ArgumentNullException.ThrowIfNull(services);

Expand Down
1 change: 1 addition & 0 deletions Nano.App.Api/Extensions/WebApplicationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ internal static WebApplication ConfigureNanoApiApplication(this WebApplication w
.UseStaticFiles()
.UseCookiePolicy()
.UseRouting()
.UseNanoMetrics(options.Metrics)
.UseNanoHttpCorsPolicy(options.HttpPolicyHeaders.Cors)
.UseAuthentication()
.UseAuthorization()
Expand Down
9 changes: 7 additions & 2 deletions Nano.App.Api/Nano.App.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="10.0.0" />
<PackageReference Include="AspNetCore.HealthChecks.System" Version="9.0.0" />
<PackageReference Include="Google.Apis.Auth" Version="1.75.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.9" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="10.0.9" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="10.0.10" />
<PackageReference Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.17.0-beta.1" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.17.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.17.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.17.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.17.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.2.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="10.2.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="10.2.3" />
Expand Down
2 changes: 1 addition & 1 deletion Nano.App.Api/NanoApiApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Nano.App.Api;
/// <summary>
/// Represents a Nano API application.
/// </summary>
/// <remarks>Documentation: <see href="https://github.com/Nano-Core/Nano.Library/tree/master/Nano.App.Api/README.md#nanoappapi">Nano Api Application</see></remarks>
/// <remarks>Documentation: <see href="https://github.com/Nano-Core/Nano.Library/blob/master/Nano.App.Api/README.md#nanoappapi">Nano Api Application</see></remarks>
public class NanoApiApplication : BaseNanoApplication<IApiApplication, WebApplication, WebApplicationBuilder>, IApiApplication
{
/// <summary>
Expand Down
Loading
Loading