diff --git a/src/SIL.Machine.Serval.EngineServer/Program.cs b/src/SIL.Machine.Serval.EngineServer/Program.cs index ed1a2f9c6..6ba9b9a5c 100644 --- a/src/SIL.Machine.Serval.EngineServer/Program.cs +++ b/src/SIL.Machine.Serval.EngineServer/Program.cs @@ -1,4 +1,5 @@ using Hangfire; +using OpenTelemetry.Trace; var builder = WebApplication.CreateBuilder(args); @@ -9,6 +10,18 @@ .AddMongoBackgroundJobClient() .AddServalTranslationEngineService(); +builder.Services + .AddOpenTelemetry() + .WithTracing(builder => + { + builder + .AddAspNetCoreInstrumentation() + .AddHttpClientInstrumentation() + .AddGrpcClientInstrumentation() + .AddSource("MongoDB.Driver.Core.Extensions.DiagnosticSources") + .AddConsoleExporter(); + }); + var app = builder.Build(); app.UseHttpsRedirection(); diff --git a/src/SIL.Machine.Serval.EngineServer/SIL.Machine.Serval.EngineServer.csproj b/src/SIL.Machine.Serval.EngineServer/SIL.Machine.Serval.EngineServer.csproj index 2a12ab8da..9a6962da2 100644 --- a/src/SIL.Machine.Serval.EngineServer/SIL.Machine.Serval.EngineServer.csproj +++ b/src/SIL.Machine.Serval.EngineServer/SIL.Machine.Serval.EngineServer.csproj @@ -9,6 +9,12 @@ + + + + + + diff --git a/src/SIL.Machine.Serval.JobServer/Program.cs b/src/SIL.Machine.Serval.JobServer/Program.cs index c468c4936..c39d250c1 100644 --- a/src/SIL.Machine.Serval.JobServer/Program.cs +++ b/src/SIL.Machine.Serval.JobServer/Program.cs @@ -1,3 +1,5 @@ +using OpenTelemetry.Trace; + var builder = WebApplication.CreateBuilder(args); builder.Services @@ -7,6 +9,18 @@ .AddBackgroundJobServer() .AddServalPlatformService(); +builder.Services + .AddOpenTelemetry() + .WithTracing(builder => + { + builder + .AddAspNetCoreInstrumentation() + .AddHttpClientInstrumentation() + .AddGrpcClientInstrumentation() + .AddSource("MongoDB.Driver.Core.Extensions.DiagnosticSources") + .AddConsoleExporter(); + }); + var app = builder.Build(); app.MapHealthChecks("/health"); diff --git a/src/SIL.Machine.Serval.JobServer/SIL.Machine.Serval.JobServer.csproj b/src/SIL.Machine.Serval.JobServer/SIL.Machine.Serval.JobServer.csproj index c33369c73..0e6059cc0 100644 --- a/src/SIL.Machine.Serval.JobServer/SIL.Machine.Serval.JobServer.csproj +++ b/src/SIL.Machine.Serval.JobServer/SIL.Machine.Serval.JobServer.csproj @@ -12,6 +12,11 @@ + + + + +