< Summary

Information
Class: Elsa.Diagnostics.OpenTelemetry.ShellFeatures.OpenTelemetryFeature
Assembly: Elsa.Diagnostics.OpenTelemetry
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Diagnostics.OpenTelemetry/ShellFeatures/OpenTelemetryFeature.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 22
Coverable lines: 22
Total lines: 101
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 Crap Score Cyclomatic complexity Line coverage
.cctor()100%210%
get_TraceCapacity()100%210%
get_SpanCapacity()100%210%
get_MetricPointCapacity()100%210%
get_LogRecordCapacity()100%210%
get_ResourceCapacity()100%210%
get_SubscriberChannelCapacity()100%210%
get_MaxHttpRequestBodySize()100%210%
ConfigureServices(...)100%210%
MapEndpoints(...)100%210%
ConfigureOptions(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Diagnostics.OpenTelemetry/ShellFeatures/OpenTelemetryFeature.cs

#LineLine coverage
 1using CShells.AspNetCore.Features;
 2using CShells.FastEndpoints.Features;
 3using CShells.Features;
 4using Elsa.Diagnostics.OpenTelemetry.Extensions;
 5using Elsa.Diagnostics.OpenTelemetry.Options;
 6using Elsa.PackageManifest.Generator.Hints;
 7using JetBrains.Annotations;
 8using Microsoft.AspNetCore.Routing;
 9using Microsoft.Extensions.DependencyInjection;
 10using Microsoft.Extensions.Hosting;
 11
 12namespace Elsa.Diagnostics.OpenTelemetry.ShellFeatures;
 13
 14[ShellFeature(
 15    DisplayName = "OpenTelemetry Diagnostics",
 16    Description = "Provides OpenTelemetry diagnostics collection, query services, and live updates",
 17    DependsOn = ["ElsaFastEndpoints"])]
 18[UsedImplicitly]
 19public class OpenTelemetryFeature : IFastEndpointsShellFeature, IWebShellFeature
 20{
 021    private static readonly OpenTelemetryDiagnosticsOptions DefaultOptions = new();
 22
 23    [ManifestSetting(
 24        DisplayName = "Trace Capacity",
 25        Description = "Maximum number of recent traces retained in memory.",
 26        Category = "Diagnostics",
 27        DefaultValue = "5000",
 28        RestartRequired = true)]
 029    public int TraceCapacity { get; set; } = DefaultOptions.TraceCapacity;
 30
 31    [ManifestSetting(
 32        DisplayName = "Span Capacity",
 33        Description = "Maximum number of recent spans retained in memory.",
 34        Category = "Diagnostics",
 35        DefaultValue = "25000",
 36        RestartRequired = true)]
 037    public int SpanCapacity { get; set; } = DefaultOptions.SpanCapacity;
 38
 39    [ManifestSetting(
 40        DisplayName = "Metric Point Capacity",
 41        Description = "Maximum number of recent metric points retained in memory.",
 42        Category = "Diagnostics",
 43        DefaultValue = "25000",
 44        RestartRequired = true)]
 045    public int MetricPointCapacity { get; set; } = DefaultOptions.MetricPointCapacity;
 46
 47    [ManifestSetting(
 48        DisplayName = "Log Record Capacity",
 49        Description = "Maximum number of recent OTLP log records retained in memory.",
 50        Category = "Diagnostics",
 51        DefaultValue = "10000",
 52        RestartRequired = true)]
 053    public int LogRecordCapacity { get; set; } = DefaultOptions.LogRecordCapacity;
 54
 55    [ManifestSetting(
 56        DisplayName = "Resource Capacity",
 57        Description = "Maximum number of recent telemetry resources retained in memory.",
 58        Category = "Diagnostics",
 59        DefaultValue = "500",
 60        RestartRequired = true)]
 061    public int ResourceCapacity { get; set; } = DefaultOptions.ResourceCapacity;
 62
 63    [ManifestSetting(
 64        DisplayName = "Subscriber Channel Capacity",
 65        Description = "Maximum queued live updates per subscriber before updates are dropped.",
 66        Category = "Diagnostics",
 67        DefaultValue = "1000",
 68        RestartRequired = true)]
 069    public int SubscriberChannelCapacity { get; set; } = DefaultOptions.SubscriberChannelCapacity;
 70
 71    [ManifestSetting(
 72        DisplayName = "Max HTTP Request Body Size",
 73        Description = "Maximum OTLP HTTP/protobuf request body size in bytes.",
 74        Category = "Diagnostics",
 75        DefaultValue = "10485760",
 76        RestartRequired = true)]
 077    public long MaxHttpRequestBodySize { get; set; } = DefaultOptions.MaxHttpRequestBodySize;
 78
 79    public void ConfigureServices(IServiceCollection services)
 80    {
 081        services.AddOpenTelemetryDiagnosticsServices(ConfigureOptions);
 082    }
 83
 84    public void MapEndpoints(IEndpointRouteBuilder endpoints, IHostEnvironment? environment)
 85    {
 086        endpoints.MapOpenTelemetryHttpProtobufCollector();
 087        endpoints.MapOpenTelemetryGrpcCollector();
 088        endpoints.MapOpenTelemetryHub();
 089    }
 90
 91    private void ConfigureOptions(OpenTelemetryDiagnosticsOptions options)
 92    {
 093        options.TraceCapacity = TraceCapacity;
 094        options.SpanCapacity = SpanCapacity;
 095        options.MetricPointCapacity = MetricPointCapacity;
 096        options.LogRecordCapacity = LogRecordCapacity;
 097        options.ResourceCapacity = ResourceCapacity;
 098        options.SubscriberChannelCapacity = SubscriberChannelCapacity;
 099        options.MaxHttpRequestBodySize = MaxHttpRequestBodySize;
 0100    }
 101}