Skip to content

Commit

Permalink
cleanup prometheus
Browse files Browse the repository at this point in the history
  • Loading branch information
christiannagel committed Sep 18, 2024
1 parent be75aaf commit 311ed61
Showing 1 changed file with 7 additions and 50 deletions.
57 changes: 7 additions & 50 deletions ch11/Codebreaker.ServiceDefaults/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,62 +1,18 @@
using Azure.Identity;
using Azure.Monitor.OpenTelemetry.AspNetCore;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Logging;
using OpenTelemetry.Logs;

using OpenTelemetry;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;

namespace Microsoft.Extensions.Hosting;

public static class Extensions
{
// public static void AddAppConfiguration(this IHostApplicationBuilder builder)
// {
// if (!builder.Environment.IsPrometheus())
// {
//#if DEBUG

// DefaultAzureCredentialOptions credentialOptions = new()
// {
// Diagnostics =
// {
// LoggedHeaderNames = { "x-ms-request-id" },
// LoggedQueryParameters = { "api-version" },
// IsLoggingContentEnabled = true
// },
// ExcludeSharedTokenCacheCredential = true,
// ExcludeAzurePowerShellCredential = true,
// ExcludeVisualStudioCodeCredential = true,
// ExcludeEnvironmentCredential = true,
// ExcludeInteractiveBrowserCredential = true,
// ExcludeAzureCliCredential = false,
// ExcludeManagedIdentityCredential = false,
// ExcludeVisualStudioCredential = false
// };
//#elif RELEASE
// string? managedIdentityClientId = builder.Configuration["ManagedIdentityClientId"];

// DefaultAzureCredentialOptions credentialOptions = new()
// {
// ManagedIdentityClientId = managedIdentityClientId,
// ExcludeSharedTokenCacheCredential = true,
// ExcludeAzurePowerShellCredential = true,
// ExcludeVisualStudioCodeCredential = true,
// ExcludeEnvironmentCredential = true,
// ExcludeInteractiveBrowserCredential = true,
// ExcludeAzureCliCredential = false,
// ExcludeManagedIdentityCredential = false,
// ExcludeVisualStudioCredential = false
// };
//#endif

// DefaultAzureCredential credential = new(credentialOptions);
// }
// }

public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBuilder builder)
{
builder.ConfigureOpenTelemetry();
Expand Down Expand Up @@ -90,7 +46,7 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati
{
metrics.AddRuntimeInstrumentation()
.AddHttpClientInstrumentation()
.AddRuntimeInstrumentation();
.AddAspNetCoreInstrumentation();
})
.WithTracing(tracing =>
{
Expand Down Expand Up @@ -119,9 +75,10 @@ private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostAppli

if (useOtlpExporter)
{
builder.Services.Configure<OpenTelemetryLoggerOptions>(logging => logging.AddOtlpExporter());
builder.Services.ConfigureOpenTelemetryMeterProvider(metrics => metrics.AddOtlpExporter());
builder.Services.ConfigureOpenTelemetryTracerProvider(tracing => tracing.AddOtlpExporter());
builder.Services.AddOpenTelemetry().UseOtlpExporter();
//builder.Services.Configure<OpenTelemetryLoggerOptions>(logging => logging.AddOtlpExporter());
//builder.Services.ConfigureOpenTelemetryMeterProvider(metrics => metrics.AddOtlpExporter());
//builder.Services.ConfigureOpenTelemetryTracerProvider(tracing => tracing.AddOtlpExporter());
}
if (Environment.GetEnvironmentVariable("StartupMode") == "OnPremises")
{
Expand Down

0 comments on commit 311ed61

Please sign in to comment.