1- // using Hangfire.PostgreSql;
2-
3- using System ;
4- using System . Diagnostics ;
1+ using System ;
52using System . Linq ;
6- using System . Net . Http ;
73using Dapper ;
84using Hangfire ;
95using Hangfire . Console ;
106using Hangfire . RecurringJobExtensions ;
117using Hangfire . Redis . StackExchange ;
12- using Microsoft . ApplicationInsights . Channel ;
13- using Microsoft . ApplicationInsights . DataContracts ;
14- using Microsoft . ApplicationInsights . Extensibility ;
158using Microsoft . AspNetCore . Builder ;
169using Microsoft . AspNetCore . DataProtection ;
1710using Microsoft . AspNetCore . Hosting ;
2720using Microsoft . Extensions . Options ;
2821using Microsoft . OpenApi . Models ;
2922using Newtonsoft . Json ;
30- using OpenTelemetry ;
3123using OpenTelemetry . Exporter ;
3224using OpenTelemetry . Resources ;
3325using OpenTelemetry . Trace ;
@@ -56,8 +48,6 @@ public Startup(IConfiguration configuration, IHostEnvironment hostEnvironment)
5648 // This method gets called by the runtime. Use this method to add services to the container.
5749 public void ConfigureServices ( IServiceCollection services )
5850 {
59- SetupApplicationInsightsFilters ( ) ;
60-
6151 services . AddCors ( ) ;
6252 services . AddResponseCompression ( ) ;
6353 services . AddHttpContextAccessor ( ) ;
@@ -74,9 +64,7 @@ public void ConfigureServices(IServiceCollection services)
7464 services . AddLogging ( loggingBuilder =>
7565 {
7666 loggingBuilder . AddConfiguration ( Configuration . GetSection ( "Logging" ) ) ;
77- loggingBuilder . SetMinimumLevel ( HostEnvironment . IsProduction ( )
78- ? LogLevel . Warning
79- : LogLevel . Information ) ;
67+ loggingBuilder . SetMinimumLevel ( LogLevel . Information ) ;
8068 loggingBuilder . AddConsole ( ) ;
8169 loggingBuilder . AddDebug ( ) ;
8270 } ) ;
@@ -301,14 +289,6 @@ public void RunMigrations(DbService db)
301289 }
302290 }
303291
304- public void SetupApplicationInsightsFilters ( )
305- {
306- var builder = TelemetryConfiguration . Active . TelemetryProcessorChainBuilder ;
307- builder . Use ( next => new HangfireRequestFilter ( next ) ) ;
308-
309- builder . Build ( ) ;
310- }
311-
312292 public void SetupAuthentication ( IServiceCollection services )
313293 {
314294 var userStore = new EnvUserStore ( Configuration ) ;
@@ -345,40 +325,6 @@ public void SetupAuthentication(IServiceCollection services)
345325 }
346326 }
347327
348- public class HangfireRequestFilter : ITelemetryProcessor
349- {
350- // Link processors to each other in a chain.
351- public HangfireRequestFilter ( ITelemetryProcessor next )
352- {
353- Next = next ;
354- }
355-
356- private ITelemetryProcessor Next { get ; }
357-
358- // You can pass values from .config
359- public string MyParamFromConfigFile { get ; set ; }
360-
361- public void Process ( ITelemetry item )
362- {
363- // To filter out an item, just return
364- if ( ! OKtoSend ( item ) ) { return ; }
365-
366- Next . Process ( item ) ;
367- }
368-
369- // Example: replace with your own criteria.
370- private bool OKtoSend ( ITelemetry item )
371- {
372- var request = item as RequestTelemetry ;
373- if ( request == null )
374- {
375- return true ;
376- }
377-
378- return ! request . Url . AbsolutePath . StartsWith ( "/relisten-admin/hangfire" ) ;
379- }
380- }
381-
382328 public class RelistenApiJsonOptionsWrapper : IConfigureOptions < MvcNewtonsoftJsonOptions >
383329 {
384330 public static readonly JsonSerializerSettings DefaultSerializerSettings =
0 commit comments