< 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: 103
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.ShellFeatures;
 7using Elsa.Platform.PackageManifest.Generator.Hints;
 8using JetBrains.Annotations;
 9using Microsoft.AspNetCore.Routing;
 10using Microsoft.Extensions.DependencyInjection;
 11using Microsoft.Extensions.Hosting;
 12
 13namespace Elsa.Diagnostics.OpenTelemetry.ShellFeatures;
 14
 15[ManifestFeatureCategory("Diagnostics")]
 16[ShellFeature(
 17    DisplayName = "OpenTelemetry Diagnostics",
 18    Description = "Provides OpenTelemetry diagnostics collection, query services, and live updates",
 19    DependsOn = [typeof(ElsaFastEndpointsFeature)])]
 20[UsedImplicitly]
 21public class OpenTelemetryFeature : IFastEndpointsShellFeature, IWebShellFeature
 22{
 023    private static readonly OpenTelemetryDiagnosticsOptions DefaultOptions = new();
 24
 25    [ManifestSetting(
 26        DisplayName = "Trace Capacity",
 27        Description = "Maximum number of recent traces retained in memory.",
 28        Category = "Diagnostics",
 29        DefaultValue = "5000",
 30        RestartRequired = true)]
 031    public int TraceCapacity { get; set; } = DefaultOptions.TraceCapacity;
 32
 33    [ManifestSetting(
 34        DisplayName = "Span Capacity",
 35        Description = "Maximum number of recent spans retained in memory.",
 36        Category = "Diagnostics",
 37        DefaultValue = "25000",
 38        RestartRequired = true)]
 039    public int SpanCapacity { get; set; } = DefaultOptions.SpanCapacity;
 40
 41    [ManifestSetting(
 42        DisplayName = "Metric Point Capacity",
 43        Description = "Maximum number of recent metric points retained in memory.",
 44        Category = "Diagnostics",
 45        DefaultValue = "25000",
 46        RestartRequired = true)]
 047    public int MetricPointCapacity { get; set; } = DefaultOptions.MetricPointCapacity;
 48
 49    [ManifestSetting(
 50        DisplayName = "Log Record Capacity",
 51        Description = "Maximum number of recent OTLP log records retained in memory.",
 52        Category = "Diagnostics",
 53        DefaultValue = "10000",
 54        RestartRequired = true)]
 055    public int LogRecordCapacity { get; set; } = DefaultOptions.LogRecordCapacity;
 56
 57    [ManifestSetting(
 58        DisplayName = "Resource Capacity",
 59        Description = "Maximum number of recent telemetry resources retained in memory.",
 60        Category = "Diagnostics",
 61        DefaultValue = "500",
 62        RestartRequired = true)]
 063    public int ResourceCapacity { get; set; } = DefaultOptions.ResourceCapacity;
 64
 65    [ManifestSetting(
 66        DisplayName = "Subscriber Channel Capacity",
 67        Description = "Maximum queued live updates per subscriber before updates are dropped.",
 68        Category = "Diagnostics",
 69        DefaultValue = "1000",
 70        RestartRequired = true)]
 071    public int SubscriberChannelCapacity { get; set; } = DefaultOptions.SubscriberChannelCapacity;
 72
 73    [ManifestSetting(
 74        DisplayName = "Max HTTP Request Body Size",
 75        Description = "Maximum OTLP HTTP/protobuf request body size in bytes.",
 76        Category = "Diagnostics",
 77        DefaultValue = "10485760",
 78        RestartRequired = true)]
 079    public long MaxHttpRequestBodySize { get; set; } = DefaultOptions.MaxHttpRequestBodySize;
 80
 81    public void ConfigureServices(IServiceCollection services)
 82    {
 083        services.AddOpenTelemetryDiagnosticsServices(ConfigureOptions);
 084    }
 85
 86    public void MapEndpoints(IEndpointRouteBuilder endpoints, IHostEnvironment? environment)
 87    {
 088        endpoints.MapOpenTelemetryHttpProtobufCollector();
 089        endpoints.MapOpenTelemetryGrpcCollector();
 090        endpoints.MapOpenTelemetryHub();
 091    }
 92
 93    private void ConfigureOptions(OpenTelemetryDiagnosticsOptions options)
 94    {
 095        options.TraceCapacity = TraceCapacity;
 096        options.SpanCapacity = SpanCapacity;
 097        options.MetricPointCapacity = MetricPointCapacity;
 098        options.LogRecordCapacity = LogRecordCapacity;
 099        options.ResourceCapacity = ResourceCapacity;
 0100        options.SubscriberChannelCapacity = SubscriberChannelCapacity;
 0101        options.MaxHttpRequestBodySize = MaxHttpRequestBodySize;
 0102    }
 103}