diff --git a/Readme.md b/Readme.md
index 8a965f3..655229c 100644
--- a/Readme.md
+++ b/Readme.md
@@ -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:
diff --git a/SharedKernel.sln.DotSettings b/SharedKernel.sln.DotSettings
index 7dbf180..767c278 100644
--- a/SharedKernel.sln.DotSettings
+++ b/SharedKernel.sln.DotSettings
@@ -1,3 +1,4 @@
True
+ True
True
\ No newline at end of file
diff --git a/src/SharedKernel/Extensions/OpenTelemetryExtension.cs b/src/SharedKernel/Extensions/OpenTelemetryExtension.cs
index 41cd924..46af69a 100644
--- a/src/SharedKernel/Extensions/OpenTelemetryExtension.cs
+++ b/src/SharedKernel/Extensions/OpenTelemetryExtension.cs
@@ -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;
}
diff --git a/src/SharedKernel/SharedKernel.csproj b/src/SharedKernel/SharedKernel.csproj
index 186964d..a103239 100644
--- a/src/SharedKernel/SharedKernel.csproj
+++ b/src/SharedKernel/SharedKernel.csproj
@@ -8,13 +8,13 @@
Readme.md
Pandatech
MIT
- 1.0.14
+ 1.0.15
Pandatech.SharedKernel
Pandatech Shared Kernel Library
Pandatech, shared kernel, library, OpenAPI, Swagger, utilities, scalar
Pandatech.SharedKernel provides centralized configurations, utilities, and extensions for ASP.NET Core projects. For more information refere to readme.md document.
https://github.com/PandaTechAM/be-lib-sharedkernel
- OpenTelemetry upgrade
+ OpenTelemetry bug fix