From b386857c7867fee928bf1fff5680aa78e865bc0d Mon Sep 17 00:00:00 2001 From: "Eli C. Lowry" <83078660+Enkidu93@users.noreply.github.com> Date: Fri, 22 Sep 2023 12:59:05 -0400 Subject: [PATCH] Added open telemetry instrumentation (#88) * Added open telemetry instrumentation * Added gRPC instrumentation & moved package references --- src/SIL.Machine.Serval.EngineServer/Program.cs | 13 +++++++++++++ .../SIL.Machine.Serval.EngineServer.csproj | 6 ++++++ src/SIL.Machine.Serval.JobServer/Program.cs | 14 ++++++++++++++ .../SIL.Machine.Serval.JobServer.csproj | 5 +++++ 4 files changed, 38 insertions(+) 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 @@ + + + + +