Skip to content

Commit

Permalink
Merge pull request #15 from PandaTechAM/development
Browse files Browse the repository at this point in the history
OpenTelemetry bug fix
  • Loading branch information
HaikAsatryan authored Dec 5, 2024
2 parents fc352d9 + 993460a commit e6fd4c7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
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

0 comments on commit e6fd4c7

Please sign in to comment.