Skip to content

Commit 2ec793b

Browse files
committed
open telemetry upgrade
1 parent 69aec70 commit 2ec793b

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

Readme.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -536,14 +536,25 @@ Integrate OpenTelemetry for observability, including metrics, traces, and loggin
536536
app.Run();
537537
```
538538
2. Prometheus Endpoints:
539-
- Metrics: `url/above-board/metrics`
540-
- Health Metrics: `url/above-board/metrics/health`
541-
3. Included Features:
539+
- Metrics: `url/above-board/prometheus`
540+
- Health Metrics: `url/above-board/prometheus/health`
541+
542+
3. OTLP Configuration:
543+
To configure the OTLP exporter, ensure the following entries are present in your appsettings{Environment}.json or as environment variables:
544+
```json
545+
{
546+
"OTEL_EXPORTER_OTLP_ENDPOINT": "http://localhost:4317",
547+
"OTEL_SERVICE_NAME": "OTLP-Example"
548+
}
549+
```
550+
4. Included Features:
542551
- ASP.NET Core metrics
543552
- HTTP client telemetry
544553
- Distributed tracing
545554
- Logging
546555
- Prometheus exporter
556+
- OTLP exporter
557+
- EF Core telemetry
547558

548559
## HealthChecks
549560

src/SharedKernel/Extensions/OpenTelemetryExtension.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
using Microsoft.Extensions.DependencyInjection;
44
using Microsoft.Extensions.Diagnostics.HealthChecks;
55
using Microsoft.Extensions.Logging;
6+
using OpenTelemetry;
7+
using OpenTelemetry.Logs;
68
using OpenTelemetry.Metrics;
79
using OpenTelemetry.Resources;
810
using OpenTelemetry.Trace;
@@ -22,28 +24,34 @@ public static WebApplicationBuilder AddOpenTelemetry(this WebApplicationBuilder
2224

2325
builder.Services
2426
.AddOpenTelemetry()
27+
.UseOtlpExporter()
2528
.ConfigureResource(resource => resource.AddService(builder.Environment.ApplicationName))
2629
.WithMetrics(metrics =>
2730
{
2831
metrics.AddRuntimeInstrumentation()
2932
.AddAspNetCoreInstrumentation()
3033
.AddHttpClientInstrumentation()
31-
.AddPrometheusExporter();
34+
.AddPrometheusExporter()
35+
.AddOtlpExporter();
3236
})
3337
.WithTracing(tracing =>
3438
{
3539
tracing.AddAspNetCoreInstrumentation()
36-
.AddHttpClientInstrumentation();
40+
.AddHttpClientInstrumentation()
41+
.AddEntityFrameworkCoreInstrumentation()
42+
.AddOtlpExporter();
3743
});
3844

45+
builder.Logging.AddOpenTelemetry(logging => logging.AddOtlpExporter());
46+
3947
return builder;
4048
}
4149

4250
public static WebApplication MapPrometheusExporterEndpoints(this WebApplication app)
4351
{
44-
app.MapPrometheusScrapingEndpoint($"{EndpointConstants.BasePath}/metrics");
52+
app.MapPrometheusScrapingEndpoint($"{EndpointConstants.BasePath}/prometheus");
4553

46-
app.UseHealthChecksPrometheusExporter($"{EndpointConstants.BasePath}/metrics/health",
54+
app.UseHealthChecksPrometheusExporter($"{EndpointConstants.BasePath}/prometheus/health",
4755
options => options.ResultStatusCodes[HealthStatus.Unhealthy] = (int)HttpStatusCode.OK);
4856

4957
return app;

src/SharedKernel/SharedKernel.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
<PackageReadmeFile>Readme.md</PackageReadmeFile>
99
<Authors>Pandatech</Authors>
1010
<Copyright>MIT</Copyright>
11-
<Version>1.0.13</Version>
11+
<Version>1.0.14</Version>
1212
<PackageId>Pandatech.SharedKernel</PackageId>
1313
<Title>Pandatech Shared Kernel Library</Title>
1414
<PackageTags>Pandatech, shared kernel, library, OpenAPI, Swagger, utilities, scalar</PackageTags>
1515
<Description>Pandatech.SharedKernel provides centralized configurations, utilities, and extensions for ASP.NET Core projects. For more information refere to readme.md document.</Description>
1616
<RepositoryUrl>https://github.com/PandaTechAM/be-lib-sharedkernel</RepositoryUrl>
17-
<PackageReleaseNotes>Language iso code helper added</PackageReleaseNotes>
17+
<PackageReleaseNotes>OpenTelemetry upgrade</PackageReleaseNotes>
1818
</PropertyGroup>
1919

2020
<ItemGroup>
@@ -43,6 +43,7 @@
4343
<PackageReference Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.8.0-rc.1"/>
4444
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.10.0" />
4545
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.9.0"/>
46+
<PackageReference Include="OpenTelemetry.Instrumentation.EntityFrameworkCore" Version="1.0.0-beta.12" />
4647
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.10.0" />
4748
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.9.0"/>
4849
<PackageReference Include="Pandatech.Crypto" Version="4.1.1" />
@@ -51,7 +52,7 @@
5152
<PackageReference Include="Pandatech.PandaVaultClient" Version="4.0.3" />
5253
<PackageReference Include="Pandatech.RegexBox" Version="3.0.0" />
5354
<PackageReference Include="Pandatech.ResponseCrafter" Version="5.0.3" />
54-
<PackageReference Include="Scalar.AspNetCore" Version="1.2.46" />
55+
<PackageReference Include="Scalar.AspNetCore" Version="1.2.48" />
5556
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />
5657
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="7.1.0" />
5758
</ItemGroup>

0 commit comments

Comments
 (0)