Skip to content

Commit

Permalink
Update OpenTelemetry logging
Browse files Browse the repository at this point in the history
  • Loading branch information
austins committed Sep 20, 2024
1 parent 45b35da commit 1da950c
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/DiscordTranslationBot/Telemetry/TelemetryExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,17 @@ public static void AddTelemetry(this WebApplicationBuilder builder)

var headers = $"X-Seq-ApiKey={options.ApiKey}";

builder.Logging.AddOpenTelemetry(
o => o.AddOtlpExporter(
e =>
{
e.Protocol = OtlpExportProtocol.HttpProtobuf;
e.Endpoint = options.LoggingEndpointUrl!;
e.Headers = headers;
}));

builder
.Services
.AddOpenTelemetry()
.ConfigureResource(
b => b
.AddService(builder.Environment.ApplicationName)
.AddAttributes(
new Dictionary<string, object> { ["environment"] = builder.Environment.EnvironmentName }))
new Dictionary<string, object>
{
["deployment.environment"] = builder.Environment.EnvironmentName
}))
.WithMetrics(b => b.AddAspNetCoreInstrumentation().AddHttpClientInstrumentation().AddPrometheusExporter())
.WithTracing(
b => b
Expand All @@ -51,6 +45,21 @@ public static void AddTelemetry(this WebApplicationBuilder builder)
e.Endpoint = options.TracingEndpointUrl!;
e.Headers = headers;
}));

builder.Logging.AddOpenTelemetry(
o =>
{
o.IncludeFormattedMessage = true;
o.IncludeScopes = true;

o.AddOtlpExporter(
e =>
{
e.Protocol = OtlpExportProtocol.HttpProtobuf;
e.Endpoint = options.LoggingEndpointUrl!;
e.Headers = headers;
});
});
}

public static void UseTelemetry(this WebApplication app)
Expand Down

0 comments on commit 1da950c

Please sign in to comment.