Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add open telemetry #137

Merged
merged 8 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/SIL.DataAccess/IServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Action<IMongoDataAccessConfigurator> configure
services.Configure<MongoDataAccessOptions>(options => options.Url = new MongoUrl(connectionString));
services.AddTransient<SIL.DataAccess.IIdGenerator, ObjectIdGenerator>();
var clientSettings = MongoClientSettings.FromConnectionString(connectionString);
clientSettings.ClusterConfigurator = cb => cb.Subscribe(new DiagnosticsActivityEventSubscriber());
clientSettings.LinqProvider = LinqProvider.V2;
services.AddSingleton<IMongoClient>(sp => new MongoClient(clientSettings));
services.AddSingleton(
Expand Down
1 change: 1 addition & 0 deletions src/SIL.DataAccess/SIL.DataAccess.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
<PackageReference Include="MongoDB.Driver" Version="2.20.0" />
<PackageReference Include="MongoDB.Driver.Core.Extensions.DiagnosticSources" Version="1.3.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Nito.AsyncEx" Version="5.1.2" />
<PackageReference Include="SIL.Core" Version="12.0.1" />
Expand Down
1 change: 1 addition & 0 deletions src/SIL.DataAccess/Usings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
global using MongoDB.Bson.Serialization;
global using MongoDB.Bson.Serialization.Conventions;
global using MongoDB.Bson.Serialization.Serializers;
global using MongoDB.Driver.Core.Extensions.DiagnosticSources;
global using MongoDB.Driver;
global using MongoDB.Driver.Linq;
global using Nito.AsyncEx;
Expand Down
4 changes: 4 additions & 0 deletions src/Serval.ApiServer/Serval.ApiServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<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.Http" Version="1.5.1-beta.1" />
</ItemGroup>

<ItemGroup>
Expand Down
9 changes: 9 additions & 0 deletions src/Serval.ApiServer/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,15 @@ public void ConfigureServices(IServiceCollection services)
};
});
}

services
.AddOpenTelemetry()
.WithTracing(builder =>
{
builder.AddAspNetCoreInstrumentation().AddConsoleExporter();
builder.AddHttpClientInstrumentation().AddConsoleExporter();
builder.AddSource("MongoDB.Driver.Core.Extensions.DiagnosticSources").AddConsoleExporter();
});
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
Expand Down
3 changes: 3 additions & 0 deletions src/Serval.ApiServer/Usings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
global using Microsoft.AspNetCore.Authorization;
global using Microsoft.AspNetCore.Diagnostics.HealthChecks;
global using Microsoft.Extensions.Diagnostics.HealthChecks;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.IdentityModel.Tokens;
global using NJsonSchema;
global using NJsonSchema.Generation;
global using NSwag;
global using NSwag.AspNetCore;
global using NSwag.Generation.Processors.Security;
global using OpenTelemetry;
global using OpenTelemetry.Trace;
global using Serval.Shared.Contracts;
global using Serval.Shared.Controllers;
global using Serval.Shared.Models;
Expand Down