< Summary - Estud

Information
Class: Estud.Back.Configs.OpenTelemetryConfigs
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Configs/OpenTelemetryConfigs.cs
Tag: 114_29044117136
Line coverage
6%
Covered lines: 2
Uncovered lines: 28
Coverable lines: 30
Total lines: 48
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 Estud.Back.Configs;
 7
 8public static class OpenTelemetryConfigs
 9{
 10    public const string CommandsProcessing = nameof(CommandsProcessing);
 11    public const string WebhookCallsProcessing = nameof(WebhookCallsProcessing);
 12    public const string WebhookEventsProcessing = nameof(WebhookEventsProcessing);
 13
 14    public static void AddOpenTelemetryConfigs(this WebApplicationBuilder builder)
 15    {
 216        var settings = builder.Configuration.OpenTelemetry;
 17
 418        if (!settings.Enabled) return;
 19
 020        builder.Services
 021            .AddOpenTelemetry()
 022            .ConfigureResource(resource => resource.AddService("Back"))
 023            .WithMetrics(metrics =>
 024            {
 025                metrics
 026                    .AddNpgsqlInstrumentation()
 027                    .AddRuntimeInstrumentation()
 028                    .AddAspNetCoreInstrumentation()
 029                    .AddHttpClientInstrumentation();
 030
 031                metrics
 032                    .AddMeter("Microsoft.AspNetCore.Hosting")
 033                    .AddMeter("Microsoft.AspNetCore.Server.Kestrel")
 034                    .AddOtlpExporter();
 035            })
 036            .WithTracing(tracing =>
 037            {
 038                tracing
 039                    .AddNpgsql()
 040                    .AddHttpClientInstrumentation()
 041                    .AddAspNetCoreInstrumentation();
 042
 043                tracing
 044                    .SetSampler(new TraceIdRatioBasedSampler(settings.TracingSamplingRatio))
 045                    .AddOtlpExporter();
 046            });
 047    }
 48}