Skip to content

Commit c2fe642

Browse files
authored
merge(#41): enable OTLP exporter
2 parents 1b85f45 + 88142ce commit c2fe642

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/CrowdParlay.Social.Infrastructure.Communication/Extensions/ConfigureOpenTelemetry.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Microsoft.Extensions.Configuration;
22
using Microsoft.Extensions.DependencyInjection;
3-
using OpenTelemetry;
3+
using OpenTelemetry.Exporter;
44
using OpenTelemetry.Metrics;
55
using OpenTelemetry.Resources;
66
using OpenTelemetry.Trace;
@@ -20,7 +20,7 @@ private static IServiceCollection ConfigureOpenTelemetry(this IServiceCollection
2020
.ValidateOnStart()
2121
.Bind(openTelemetryConfiguration);
2222

23-
var openTelemetryBuilder = services.AddOpenTelemetry().UseOtlpExporter();
23+
var openTelemetryBuilder = services.AddOpenTelemetry();
2424

2525
openTelemetryBuilder.ConfigureResource(resource => resource
2626
.AddService(openTelemetrySettings.ServiceName));
@@ -32,12 +32,22 @@ private static IServiceCollection ConfigureOpenTelemetry(this IServiceCollection
3232
.AddHttpClientInstrumentation()
3333
.AddEntityFrameworkCoreInstrumentation()
3434
.AddMassTransitInstrumentation()
35-
.AddRedisInstrumentation());
35+
.AddRedisInstrumentation()
36+
.AddOtlpExporter(exporter =>
37+
{
38+
exporter.Endpoint = new Uri(openTelemetrySettings.OtlpEndpoint);
39+
exporter.Protocol = OtlpExportProtocol.HttpProtobuf;
40+
}));
3641

3742
openTelemetryBuilder.WithMetrics(metrics => metrics
3843
.AddMeter(openTelemetrySettings.MeterName)
3944
.AddAspNetCoreInstrumentation()
40-
.AddHttpClientInstrumentation());
45+
.AddHttpClientInstrumentation()
46+
.AddOtlpExporter(exporter =>
47+
{
48+
exporter.Endpoint = new Uri(openTelemetrySettings.OtlpEndpoint);
49+
exporter.Protocol = OtlpExportProtocol.HttpProtobuf;
50+
}));
4151

4252
return services;
4353
}

0 commit comments

Comments
 (0)