< Summary - Syki

Information
Class: Syki.Back.Configs.OpenTelemetryConfigs
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Configs/OpenTelemetryConfigs.cs
Tag: 56_26538939494
Line coverage
6%
Covered lines: 2
Uncovered lines: 28
Coverable lines: 30
Total lines: 47
Line coverage: 6.6%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
AddOpenTelemetryConfigs(...)50%526.66%

File(s)

/home/runner/work/syki/syki/Back/Configs/OpenTelemetryConfigs.cs

#LineLine coverage
 1using Npgsql;
 2using OpenTelemetry.Trace;
 3using OpenTelemetry.Metrics;
 4using OpenTelemetry.Resources;
 5
 6namespace Syki.Back.Configs;
 7
 8public static class OpenTelemetryConfigs
 9{
 10    public const string CommandsProcessing = nameof(CommandsProcessing);
 11    public const string WebhookEventsProcessing = nameof(WebhookEventsProcessing);
 12
 13    public static void AddOpenTelemetryConfigs(this WebApplicationBuilder builder)
 14    {
 215        var settings = builder.Configuration.OpenTelemetry;
 16
 417        if (!settings.Enabled) return;
 18
 019        builder.Services
 020            .AddOpenTelemetry()
 021            .ConfigureResource(resource => resource.AddService("Back"))
 022            .WithMetrics(metrics =>
 023            {
 024                metrics
 025                    .AddNpgsqlInstrumentation()
 026                    .AddRuntimeInstrumentation()
 027                    .AddAspNetCoreInstrumentation()
 028                    .AddHttpClientInstrumentation();
 029
 030                metrics
 031                    .AddMeter("Microsoft.AspNetCore.Hosting")
 032                    .AddMeter("Microsoft.AspNetCore.Server.Kestrel")
 033                    .AddOtlpExporter();
 034            })
 035            .WithTracing(tracing =>
 036            {
 037                tracing
 038                    .AddNpgsql()
 039                    .AddHttpClientInstrumentation()
 040                    .AddAspNetCoreInstrumentation();
 041
 042                tracing
 043                    .SetSampler(new TraceIdRatioBasedSampler(settings.TracingSamplingRatio))
 044                    .AddOtlpExporter();
 045            });
 046    }
 47}