Skip to content

Commit

Permalink
chore(graphql): revert to old app insights config (#1347)
Browse files Browse the repository at this point in the history
Revert to old app insights config for graphql to fix
ApplicationInsightsEventListener.
  • Loading branch information
knuhau authored Oct 25, 2024
1 parent e31c08b commit 0c0a4da
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Digdir.Domain.Dialogporten.GraphQL/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@
using Microsoft.Extensions.Options;

// Using two-stage initialization to catch startup errors.
var telemetryConfiguration = TelemetryConfiguration.CreateDefault();
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Warning()
.Enrich.FromLogContext()
.WriteTo.Console(formatProvider: CultureInfo.InvariantCulture)
.WriteTo.ApplicationInsights(telemetryConfiguration, TelemetryConverter.Traces)
.WriteTo.ApplicationInsights(TelemetryConfiguration.CreateDefault(), TelemetryConverter.Traces)
.CreateBootstrapLogger();

try
{
BuildAndRun(args, telemetryConfiguration);
BuildAndRun(args);
}
catch (Exception ex) when (ex is not OperationCanceledException)
{
Expand All @@ -41,7 +40,7 @@
Log.CloseAndFlush();
}

static void BuildAndRun(string[] args, TelemetryConfiguration telemetryConfiguration)
static void BuildAndRun(string[] args)
{
var builder = WebApplication.CreateBuilder(args);

Expand All @@ -51,7 +50,7 @@ static void BuildAndRun(string[] args, TelemetryConfiguration telemetryConfigura
.ReadFrom.Services(services)
.Enrich.FromLogContext()
.WriteTo.Console(formatProvider: CultureInfo.InvariantCulture)
.WriteTo.ApplicationInsights(telemetryConfiguration, TelemetryConverter.Traces));
.WriteTo.ApplicationInsights(services.GetRequiredService<TelemetryConfiguration>(), TelemetryConverter.Traces));

builder.Configuration
.AddAzureConfiguration(builder.Environment.EnvironmentName)
Expand All @@ -77,6 +76,7 @@ static void BuildAndRun(string[] args, TelemetryConfiguration telemetryConfigura
.WithPubCapabilities()
.Build()
.AddAutoMapper(Assembly.GetExecutingAssembly())
.AddApplicationInsightsTelemetry()
.AddScoped<IUser, ApplicationUser>()
.AddValidatorsFromAssembly(thisAssembly, ServiceLifetime.Transient, includeInternalTypes: true)
.AddAzureAppConfiguration()
Expand Down

0 comments on commit 0c0a4da

Please sign in to comment.