add some performance troubleshooting env vars (#2745)
* add slow query logging * add slow api logging for jellyfin * add configurable jellyfin page size * feedback
This commit is contained in:
@@ -408,6 +408,12 @@ public class Startup
|
||||
var sqliteConnectionString = $"Data Source={FileSystemLayout.DatabasePath};foreign keys=true;";
|
||||
string mySqlConnectionString = Configuration.GetValue<string>("MySql:ConnectionString");
|
||||
|
||||
SlowQueryInterceptor interceptor = null;
|
||||
if (SystemEnvironment.SlowDbMs.HasValue)
|
||||
{
|
||||
interceptor = new SlowQueryInterceptor(SystemEnvironment.SlowDbMs.Value);
|
||||
}
|
||||
|
||||
services.AddDbContext<TvContext>(
|
||||
options =>
|
||||
{
|
||||
@@ -438,6 +444,11 @@ public class Startup
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (interceptor != null)
|
||||
{
|
||||
options.AddInterceptors(interceptor);
|
||||
}
|
||||
},
|
||||
ServiceLifetime.Scoped,
|
||||
ServiceLifetime.Singleton);
|
||||
@@ -467,6 +478,11 @@ public class Startup
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (interceptor != null)
|
||||
{
|
||||
options.AddInterceptors(interceptor);
|
||||
}
|
||||
});
|
||||
|
||||
if (databaseProvider == Provider.Sqlite.Name)
|
||||
@@ -509,6 +525,8 @@ public class Startup
|
||||
c.DefaultRequestHeaders.Add("User-Agent", $"ErsatzTV/{etvVersion}");
|
||||
});
|
||||
|
||||
services.AddHttpClient("RefitCustomClient").AddHttpMessageHandler<SlowApiHandler>();
|
||||
|
||||
services.Configure<TraktConfiguration>(Configuration.GetSection("Trakt"));
|
||||
|
||||
services.AddResponseCompression(options => { options.EnableForHttps = true; });
|
||||
@@ -851,6 +869,8 @@ public class Startup
|
||||
|
||||
// services.AddTransient(typeof(IRequestHandler<,>), typeof(GetRecentLogEntriesHandler<>));
|
||||
|
||||
services.AddTransient<SlowApiHandler>();
|
||||
|
||||
// run-once/blocking startup services
|
||||
services.AddHostedService<EndpointValidatorService>();
|
||||
services.AddHostedService<DatabaseMigratorService>();
|
||||
|
||||
Reference in New Issue
Block a user