Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 1 addition & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,7 @@ Integrate OpenTelemetry for observability, including metrics, traces, and loggin
To configure the OTLP exporter, ensure the following entries are present in your appsettings{Environment}.json or as environment variables:
```json
{
"OTEL_EXPORTER_OTLP_ENDPOINT": "http://localhost:4317",
"OTEL_SERVICE_NAME": "OTLP-Example"
"OTEL_EXPORTER_OTLP_ENDPOINT": "http://localhost:4317"
}
```
4. Included Features:
Expand Down
1 change: 1 addition & 0 deletions SharedKernel.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=mediat/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=otlp/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=sharedkernel/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
18 changes: 12 additions & 6 deletions src/SharedKernel/Extensions/OpenTelemetryExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,31 @@ public static WebApplicationBuilder AddOpenTelemetry(this WebApplicationBuilder

builder.Services
.AddOpenTelemetry()
.UseOtlpExporter()
.ConfigureResource(resource => resource.AddService(builder.Environment.ApplicationName))
.WithMetrics(metrics =>
{
metrics.AddRuntimeInstrumentation()
.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddPrometheusExporter()
.AddOtlpExporter();
.AddPrometheusExporter();
})
.WithTracing(tracing =>
{
tracing.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddEntityFrameworkCoreInstrumentation()
.AddOtlpExporter();
.AddEntityFrameworkCoreInstrumentation();
});

var otlpEnabled = !string.IsNullOrEmpty(builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"]);

builder.Logging.AddOpenTelemetry(logging => logging.AddOtlpExporter());
if (!otlpEnabled)
{
return builder;
}

builder.Services.ConfigureOpenTelemetryLoggerProvider(l => l.AddOtlpExporter());
builder.Services.ConfigureOpenTelemetryTracerProvider(t => t.AddOtlpExporter());
builder.Services.ConfigureOpenTelemetryTracerProvider(t => t.AddOtlpExporter());

return builder;
}
Expand Down
4 changes: 2 additions & 2 deletions src/SharedKernel/SharedKernel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
<PackageReadmeFile>Readme.md</PackageReadmeFile>
<Authors>Pandatech</Authors>
<Copyright>MIT</Copyright>
<Version>1.0.14</Version>
<Version>1.0.15</Version>
<PackageId>Pandatech.SharedKernel</PackageId>
<Title>Pandatech Shared Kernel Library</Title>
<PackageTags>Pandatech, shared kernel, library, OpenAPI, Swagger, utilities, scalar</PackageTags>
<Description>Pandatech.SharedKernel provides centralized configurations, utilities, and extensions for ASP.NET Core projects. For more information refere to readme.md document.</Description>
<RepositoryUrl>https://github.com/PandaTechAM/be-lib-sharedkernel</RepositoryUrl>
<PackageReleaseNotes>OpenTelemetry upgrade</PackageReleaseNotes>
<PackageReleaseNotes>OpenTelemetry bug fix</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
Expand Down