diff --git a/Web/Resgrid.Web.ServicesCore/Program.cs b/Web/Resgrid.Web.ServicesCore/Program.cs index 002f0235..5a5bcb17 100644 --- a/Web/Resgrid.Web.ServicesCore/Program.cs +++ b/Web/Resgrid.Web.ServicesCore/Program.cs @@ -42,6 +42,10 @@ public static IHostBuilder CreateHostBuilder(string[] args) => options.AttachStacktrace = true; options.SendDefaultPii = true; options.AutoSessionTracking = true; + + if (ExternalErrorConfig.SentryPerfSampleRate > 0) + options.EnableTracing = true; + options.TracesSampleRate = ExternalErrorConfig.SentryPerfSampleRate; options.Environment = ExternalErrorConfig.Environment; options.Release = Assembly.GetEntryAssembly().GetName().Version.ToString(); diff --git a/Web/Resgrid.Web.ServicesCore/Startup.cs b/Web/Resgrid.Web.ServicesCore/Startup.cs index 2862e36c..3a5b6476 100644 --- a/Web/Resgrid.Web.ServicesCore/Startup.cs +++ b/Web/Resgrid.Web.ServicesCore/Startup.cs @@ -482,26 +482,26 @@ public void ConfigureServices(IServiceCollection services) // .AddService("ResgridApi")) // .AddConsoleExporter(); //}); - services.AddOpenTelemetry() - .ConfigureResource(resource => resource.AddService("ResgridApi")) - .WithTracing(tracing => tracing - .AddAspNetCoreInstrumentation() - .AddConsoleExporter()) - .WithMetrics(metrics => metrics - .AddAspNetCoreInstrumentation() - .AddConsoleExporter()); - - // For options which can be bound from IConfiguration. - services.Configure(this.Configuration.GetSection("AspNetCoreInstrumentation")); - - // For options which can be configured from code only. - services.Configure(options => - { - options.Filter = (req) => - { - return req.Request.Host != null; - }; - }); + //services.AddOpenTelemetry() + // .ConfigureResource(resource => resource.AddService("ResgridApi")) + // .WithTracing(tracing => tracing + // .AddAspNetCoreInstrumentation() + // .AddConsoleExporter()) + // .WithMetrics(metrics => metrics + // .AddAspNetCoreInstrumentation() + // .AddConsoleExporter()); + + //// For options which can be bound from IConfiguration. + //services.Configure(this.Configuration.GetSection("AspNetCoreInstrumentation")); + + //// For options which can be configured from code only. + //services.Configure(options => + //{ + // options.Filter = (req) => + // { + // return req.Request.Host != null; + // }; + //}); services.AddAuthentication("BasicAuthentication") @@ -522,16 +522,16 @@ public void ConfigureServices(IServiceCollection services) //services.AddHostedService(); this.Services = services; - if (Config.ExternalErrorConfig.ApplicationInsightsEnabled) - { - services.AddSingleton(); + //if (Config.ExternalErrorConfig.ApplicationInsightsEnabled) + //{ + // services.AddSingleton(); - var aiOptions = new ApplicationInsightsServiceOptions(); - aiOptions.InstrumentationKey = ExternalErrorConfig.ApplicationInsightsInstrumentationKey; - aiOptions.ConnectionString = ExternalErrorConfig.ApplicationInsightsConnectionString; + // var aiOptions = new ApplicationInsightsServiceOptions(); + // aiOptions.InstrumentationKey = ExternalErrorConfig.ApplicationInsightsInstrumentationKey; + // aiOptions.ConnectionString = ExternalErrorConfig.ApplicationInsightsConnectionString; - services.AddApplicationInsightsTelemetry(aiOptions); - } + // services.AddApplicationInsightsTelemetry(aiOptions); + //} } public void ConfigureContainer(ContainerBuilder builder) diff --git a/Web/Resgrid.WebCore/Areas/User/Views/Shared/_UserLayout.cshtml b/Web/Resgrid.WebCore/Areas/User/Views/Shared/_UserLayout.cshtml index 43a211b1..b20dae3a 100644 --- a/Web/Resgrid.WebCore/Areas/User/Views/Shared/_UserLayout.cshtml +++ b/Web/Resgrid.WebCore/Areas/User/Views/Shared/_UserLayout.cshtml @@ -34,9 +34,16 @@ } - @if (Resgrid.Config.ExternalErrorConfig.ApplicationInsightsEnabled) + @if (Resgrid.Config.ExternalErrorConfig.SentryPerfSampleRate > 0 && !String.IsNullOrWhiteSpace(Resgrid.Config.ExternalErrorConfig.ExternalErrorServiceUrlForWebsite)) { - //@Html.Raw(JavaScriptSnippet.FullScript) + + } diff --git a/Web/Resgrid.WebCore/Program.cs b/Web/Resgrid.WebCore/Program.cs index ae8fc779..3abc239b 100644 --- a/Web/Resgrid.WebCore/Program.cs +++ b/Web/Resgrid.WebCore/Program.cs @@ -29,8 +29,6 @@ public static IHostBuilder CreateHostBuilder(string[] args) => }) .ConfigureWebHostDefaults(webBuilder => { - webBuilder.UseStartup(); - if (!string.IsNullOrWhiteSpace(Config.ExternalErrorConfig.ExternalErrorServiceUrlForWebsite)) { webBuilder.UseSentry(options => @@ -40,6 +38,10 @@ public static IHostBuilder CreateHostBuilder(string[] args) => options.Dsn = Config.ExternalErrorConfig.ExternalErrorServiceUrlForWebsite; options.AttachStacktrace = true; options.SendDefaultPii = true; + + if (ExternalErrorConfig.SentryPerfSampleRate > 0) + options.EnableTracing = true; + options.TracesSampleRate = ExternalErrorConfig.SentryPerfSampleRate; options.Environment = ExternalErrorConfig.Environment; options.AutoSessionTracking = true; @@ -69,6 +71,8 @@ public static IHostBuilder CreateHostBuilder(string[] args) => }; }); } + + webBuilder.UseStartup(); }); } } diff --git a/Web/Resgrid.WebCore/Startup.cs b/Web/Resgrid.WebCore/Startup.cs index 6411a18f..c66be8a4 100644 --- a/Web/Resgrid.WebCore/Startup.cs +++ b/Web/Resgrid.WebCore/Startup.cs @@ -402,15 +402,15 @@ public void ConfigureServices(IServiceCollection services) this.Services = services; - if (Config.ExternalErrorConfig.ApplicationInsightsEnabled) - { - services.AddSingleton(); - - var aiOptions = new ApplicationInsightsServiceOptions(); - aiOptions.InstrumentationKey = ExternalErrorConfig.ApplicationInsightsInstrumentationKey; - aiOptions.ConnectionString = ExternalErrorConfig.ApplicationInsightsConnectionString; - services.AddApplicationInsightsTelemetry(aiOptions); - } + //if (Config.ExternalErrorConfig.ApplicationInsightsEnabled) + //{ + // services.AddSingleton(); + + // var aiOptions = new ApplicationInsightsServiceOptions(); + // aiOptions.InstrumentationKey = ExternalErrorConfig.ApplicationInsightsInstrumentationKey; + // aiOptions.ConnectionString = ExternalErrorConfig.ApplicationInsightsConnectionString; + // services.AddApplicationInsightsTelemetry(aiOptions); + //} } public void ConfigureContainer(ContainerBuilder builder)