< Summary - Syki

Information
Class: Syki.Back.Configs.OpenTelemetryConfigs
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Configs/OpenTelemetryConfigs.cs
Tag: 21_17346963026
Line coverage
3%
Covered lines: 1
Uncovered lines: 30
Coverable lines: 31
Total lines: 52
Line coverage: 3.2%
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%623.22%

File(s)

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

#LineLine coverage
 1using Npgsql;
 2using OpenTelemetry.Logs;
 3using OpenTelemetry.Trace;
 4using OpenTelemetry.Metrics;
 5using OpenTelemetry.Resources;
 6
 7namespace Syki.Back.Configs;
 8
 9public static class OpenTelemetryConfigs
 10{
 11    public static void AddOpenTelemetryConfigs(this WebApplicationBuilder builder)
 12    {
 413        if (Env.IsTesting()) return;
 14
 15        // builder.Logging.AddOpenTelemetry(logging =>
 16        // {
 17        //     logging.IncludeScopes = true;
 18        //     logging.IncludeFormattedMessage = true;
 19        // });
 20
 021        var settings = builder.Configuration.Tracing();
 22
 023        builder.Services
 024            .AddOpenTelemetry()
 025            .ConfigureResource(resource => resource.AddService("Back"))
 026            // .WithMetrics(metrics =>
 027            // {
 028            //     metrics
 029            //         .AddNpgsqlInstrumentation()
 030            //         .AddRuntimeInstrumentation()
 031            //         .AddAspNetCoreInstrumentation()
 032            //         .AddHttpClientInstrumentation();
 033
 034            //     metrics.AddMeter("Microsoft.AspNetCore.Hosting");
 035            //     metrics.AddMeter("Microsoft.AspNetCore.Server.Kestrel");
 036
 037            //     metrics.AddOtlpExporter();
 038            // })
 039            .WithTracing(tracing =>
 040            {
 041                tracing
 042                    .AddNpgsql()
 043                    .AddQuartzInstrumentation()
 044                    .AddHttpClientInstrumentation()
 045                    .AddAspNetCoreInstrumentation();
 046
 047                tracing
 048                    .SetSampler(new TraceIdRatioBasedSampler(settings.SamplingRatio))
 049                    .AddOtlpExporter();
 050            });
 051    }
 52}