Skip to content

Commit 0b455a9

Browse files
committed
remove application insights
1 parent 8e602a6 commit 0b455a9

File tree

2 files changed

+2
-57
lines changed

2 files changed

+2
-57
lines changed

RelistenApi/RelistenApi.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
<PackageReference Include="OpenTelemetry.Instrumentation.StackExchangeRedis" Version="1.11.0-beta.1" />
3535
<PackageReference Include="Polly" Version="8.5.2" />
3636
<PackageReference Include="Swashbuckle.AspNetCore" Version="8.1.1" />
37-
<PackageReference Include="Microsoft.AspNetCore.ApplicationInsights.HostingStartup" Version="2.3.0" />
3837
<PackageReference Include="Simple.Migrations" Version="0.9.21"/>
3938
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="9.0.4" />
4039
<PackageReference Include="Hangfire.Redis.StackExchange" Version="1.12.0" />

RelistenApi/Startup.cs

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
// using Hangfire.PostgreSql;
2-
3-
using System;
4-
using System.Diagnostics;
1+
using System;
52
using System.Linq;
6-
using System.Net.Http;
73
using Dapper;
84
using Hangfire;
95
using Hangfire.Console;
106
using Hangfire.RecurringJobExtensions;
117
using Hangfire.Redis.StackExchange;
12-
using Microsoft.ApplicationInsights.Channel;
13-
using Microsoft.ApplicationInsights.DataContracts;
14-
using Microsoft.ApplicationInsights.Extensibility;
158
using Microsoft.AspNetCore.Builder;
169
using Microsoft.AspNetCore.DataProtection;
1710
using Microsoft.AspNetCore.Hosting;
@@ -27,7 +20,6 @@
2720
using Microsoft.Extensions.Options;
2821
using Microsoft.OpenApi.Models;
2922
using Newtonsoft.Json;
30-
using OpenTelemetry;
3123
using OpenTelemetry.Exporter;
3224
using OpenTelemetry.Resources;
3325
using 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

Comments
 (0)