< Summary

Information
Class: Intentum.AspNetCore.IntentumAspNetCoreExtensions
Assembly: Intentum.AspNetCore
File(s): /home/runner/work/Intentum/Intentum/src/Intentum.AspNetCore/IntentumAspNetCoreExtensions.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 25
Coverable lines: 25
Total lines: 61
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.cctor()100%110%
AddIntentum(...)100%110%
AddIntentum(...)100%110%
UseIntentumBehaviorObservation(...)100%110%
AddIntentumHealthChecks(...)100%110%

File(s)

/home/runner/work/Intentum/Intentum/src/Intentum.AspNetCore/IntentumAspNetCoreExtensions.cs

#LineLine coverage
 1using Intentum.Core.Behavior;
 2using Microsoft.AspNetCore.Builder;
 3using Microsoft.Extensions.DependencyInjection;
 4
 5namespace Intentum.AspNetCore;
 6
 7/// <summary>
 8/// Extension methods for integrating Intentum with ASP.NET Core.
 9/// </summary>
 10public static class IntentumAspNetCoreExtensions
 11{
 012    private static readonly string[] HealthCheckTagsEmbedding = ["intentum", "embedding"];
 013    private static readonly string[] HealthCheckTagsPolicy = ["intentum", "policy"];
 14
 15    /// <summary>
 16    /// Adds Intentum services to the service collection.
 17    /// </summary>
 18    public static IServiceCollection AddIntentum(this IServiceCollection services)
 019    {
 020        services.AddSingleton<BehaviorSpace>();
 021        return services;
 022    }
 23
 24    /// <summary>
 25    /// Adds Intentum services with a custom BehaviorSpace instance.
 26    /// </summary>
 27    public static IServiceCollection AddIntentum(this IServiceCollection services, BehaviorSpace behaviorSpace)
 028    {
 029        services.AddSingleton(behaviorSpace);
 030        return services;
 031    }
 32
 33    /// <summary>
 34    /// Uses Intentum behavior observation middleware.
 35    /// </summary>
 36    public static IApplicationBuilder UseIntentumBehaviorObservation(
 37        this IApplicationBuilder app,
 38        BehaviorObservationOptions? options = null)
 039    {
 040        var behaviorSpace = app.ApplicationServices.GetRequiredService<BehaviorSpace>();
 041        return app.UseMiddleware<BehaviorObservationMiddleware>(behaviorSpace, options);
 042    }
 43
 44    /// <summary>
 45    /// Adds Intentum health checks.
 46    /// </summary>
 47    public static IHealthChecksBuilder AddIntentumHealthChecks(
 48        this IServiceCollection services)
 049    {
 050        services.AddSingleton<HealthChecks.EmbeddingProviderHealthCheck>();
 051        services.AddSingleton<HealthChecks.PolicyEngineHealthCheck>();
 52
 053        return services.AddHealthChecks()
 054            .AddCheck<HealthChecks.EmbeddingProviderHealthCheck>(
 055                "embedding-provider",
 056                tags: HealthCheckTagsEmbedding)
 057            .AddCheck<HealthChecks.PolicyEngineHealthCheck>(
 058                "policy-engine",
 059                tags: HealthCheckTagsPolicy);
 060    }
 61}