- Move all .NET (6 projects, solution, Directory.*.props, nuget.config) into backend/ so the monorepo root can host non-.NET projects later - Remove throwaway test artifacts: player.html, pl.json - Trim dead Flutter rules from .gitignore Build from backend/Musify.slnx: 0 warnings, 0 errors. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
60 lines
2.3 KiB
C#
60 lines
2.3 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Options;
|
|
using Musify.Infrastructure.Configuration;
|
|
using OpenTelemetry.Exporter;
|
|
using OpenTelemetry.Logs;
|
|
using OpenTelemetry.Metrics;
|
|
using OpenTelemetry.Resources;
|
|
using OpenTelemetry.Trace;
|
|
|
|
namespace Musify.Infrastructure.Observability
|
|
{
|
|
public static class OpenTelemetryDependencyInjection
|
|
{
|
|
public static IServiceCollection AddObservability(this IServiceCollection serviceDescriptors, IConfiguration configuration)
|
|
{
|
|
serviceDescriptors
|
|
.AddOptionsWithValidateOnStart<OpenTelemetryConfiguration>()
|
|
.Bind(configuration.GetRequiredSection(OpenTelemetryConfiguration.SectionName))
|
|
.ValidateDataAnnotations();
|
|
|
|
serviceDescriptors.AddSingleton(serviceProvider =>
|
|
serviceProvider.GetRequiredService<IOptions<OpenTelemetryConfiguration>>().Value);
|
|
|
|
serviceDescriptors
|
|
.AddOptions<OtlpExporterOptions>()
|
|
.Configure<OpenTelemetryConfiguration>((exporterOptions, openTelemetryConfiguration) =>
|
|
{
|
|
exporterOptions.Endpoint = new Uri(openTelemetryConfiguration.OtlpEndpoint);
|
|
} );
|
|
|
|
serviceDescriptors
|
|
.AddOpenTelemetry()
|
|
.ConfigureResource(resource =>
|
|
{
|
|
resource.AddService("Musify");
|
|
} )
|
|
.WithTracing(tracing =>
|
|
tracing.AddSource("MassTransit")
|
|
.AddAspNetCoreInstrumentation()
|
|
.AddHttpClientInstrumentation()
|
|
.AddEntityFrameworkCoreInstrumentation()
|
|
.AddOtlpExporter()
|
|
)
|
|
.WithMetrics(metrics =>
|
|
metrics.AddMeter("MassTransit")
|
|
.AddAspNetCoreInstrumentation()
|
|
.AddHttpClientInstrumentation()
|
|
.AddRuntimeInstrumentation()
|
|
.AddProcessInstrumentation()
|
|
.AddOtlpExporter()
|
|
)
|
|
.WithLogging(logging =>
|
|
logging.AddOtlpExporter()
|
|
);
|
|
|
|
return serviceDescriptors;
|
|
}
|
|
}
|
|
} |