Skip to content

Commit

Permalink
Added open telemetry instrumentation (#88)
Browse files Browse the repository at this point in the history
* Added open telemetry instrumentation

* Added gRPC instrumentation & moved package references
  • Loading branch information
Enkidu93 authored Sep 22, 2023
1 parent 2340e82 commit b386857
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/SIL.Machine.Serval.EngineServer/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Hangfire;
using OpenTelemetry.Trace;

var builder = WebApplication.CreateBuilder(args);

Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@

<ItemGroup>
<PackageReference Include="icu.net" Version="2.9.0" />
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.6.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.6.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.5.1-beta.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.5.1-beta.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.5.1-beta.1" />

</ItemGroup>

<ItemGroup>
Expand Down
14 changes: 14 additions & 0 deletions src/SIL.Machine.Serval.JobServer/Program.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using OpenTelemetry.Trace;

var builder = WebApplication.CreateBuilder(args);

builder.Services
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@

<ItemGroup>
<PackageReference Include="icu.net" Version="2.9.0" />
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.6.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.6.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.5.1-beta.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.5.1-beta.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.5.1-beta.1" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit b386857

Please sign in to comment.