From 8ce3e68b817aa917adfbfc6458c96d8ddb5f9f3e Mon Sep 17 00:00:00 2001 From: XShine555 Date: Fri, 20 Mar 2026 22:18:37 +0100 Subject: [PATCH] OT --- Infrastructure/Infrastructure.csproj | 1 + .../InfrastructureDependencyInjection.cs | 3 +++ .../OpenTelemetryDependencyInjection.cs | 23 +++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 Infrastructure/Observability/OpenTelemetryDependencyInjection.cs diff --git a/Infrastructure/Infrastructure.csproj b/Infrastructure/Infrastructure.csproj index 3bc091b..a813415 100644 --- a/Infrastructure/Infrastructure.csproj +++ b/Infrastructure/Infrastructure.csproj @@ -22,6 +22,7 @@ + diff --git a/Infrastructure/InfrastructureDependencyInjection.cs b/Infrastructure/InfrastructureDependencyInjection.cs index 64e7474..8923781 100644 --- a/Infrastructure/InfrastructureDependencyInjection.cs +++ b/Infrastructure/InfrastructureDependencyInjection.cs @@ -4,6 +4,7 @@ using Musify.Application.Contracts.Infrastructure; using Musify.Infrastructure.Configuration; using Musify.Infrastructure.Identity; using Musify.Infrastructure.Messaging; +using Musify.Infrastructure.Observability; using Musify.Infrastructure.Persistence; using Musify.Infrastructure.Pictures; using Musify.Infrastructure.Storage; @@ -20,6 +21,7 @@ namespace Musify.Infrastructure .AddKeycloakService(configuration) .AddStorageHandler() .AddPictureHandler() + .AddInfrastructureOpenTelemetry() .AddMassTransitClient() .AddScoped() .AddScoped(); @@ -34,6 +36,7 @@ namespace Musify.Infrastructure .AddDatabase(configuration) .AddStorageHandler() .AddPictureHandler() + .AddInfrastructureOpenTelemetry() .AddMassTransitConsumers() .AddScoped() .AddScoped(); diff --git a/Infrastructure/Observability/OpenTelemetryDependencyInjection.cs b/Infrastructure/Observability/OpenTelemetryDependencyInjection.cs new file mode 100644 index 0000000..4618185 --- /dev/null +++ b/Infrastructure/Observability/OpenTelemetryDependencyInjection.cs @@ -0,0 +1,23 @@ +using Microsoft.Extensions.DependencyInjection; + +namespace Musify.Infrastructure.Observability +{ + public static class OpenTelemetryDependencyInjection + { + public static IServiceCollection AddInfrastructureOpenTelemetry(this IServiceCollection serviceDescriptors) + { + serviceDescriptors + .AddOpenTelemetry() + .WithTracing(tracing => + { + tracing.AddSource("MassTransit"); + } ) + .WithMetrics(metrics => + { + metrics.AddMeter("MassTransit"); + } ); + + return serviceDescriptors; + } + } +}