feat: add EnableMetrics override with asp.net config framework/environment vars

pull/10503/head
Yohan Belval 7 months ago
parent 4962640b3a
commit 58facaad4f

@ -263,6 +263,8 @@ namespace Emby.Server.Implementations
/// <inheritdoc/>
public bool ListenWithHttps => Certificate is not null && ConfigurationManager.GetNetworkConfiguration().EnableHttps;
public bool EnableMetrics => ConfigurationManager.Configuration.EnableMetrics || this._startupConfig.GetValue<bool>(EnableMetricsKey);
public string FriendlyName =>
string.IsNullOrEmpty(ConfigurationManager.Configuration.ServerName)
? Environment.MachineName
@ -449,7 +451,7 @@ namespace Emby.Server.Implementations
NetManager = new NetworkManager(ConfigurationManager, _startupConfig, LoggerFactory.CreateLogger<NetworkManager>());
// Initialize runtime stat collection
if (ConfigurationManager.Configuration.EnableMetrics)
if (this.EnableMetrics)
{
DotNetRuntimeStatsBuilder.Default().StartCollecting();
}

@ -19,7 +19,8 @@ namespace Emby.Server.Implementations
{ FfmpegAnalyzeDurationKey, "200M" },
{ PlaylistsAllowDuplicatesKey, bool.FalseString },
{ BindToUnixSocketKey, bool.FalseString },
{ SqliteCacheSizeKey, "20000" }
{ SqliteCacheSizeKey, "20000" },
{ EnableMetricsKey, bool.FalseString }
};
}
}

@ -201,7 +201,7 @@ namespace Jellyfin.Server
mainApp.UseWebSocketHandler();
mainApp.UseServerStartupMessage();
if (_serverConfigurationManager.Configuration.EnableMetrics)
if (_serverApplicationHost.EnableMetrics)
{
// Must be registered after any middleware that could change HTTP response codes or the data will be bad
mainApp.UseHttpMetrics();
@ -210,7 +210,7 @@ namespace Jellyfin.Server
mainApp.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
if (_serverConfigurationManager.Configuration.EnableMetrics)
if (_serverApplicationHost.EnableMetrics)
{
endpoints.MapMetrics();
}

@ -64,6 +64,11 @@ namespace MediaBrowser.Controller.Extensions
/// </summary>
public const string SqliteCacheSizeKey = "sqlite:cacheSize";
/// <summary>
/// The key for enabling the metrics endpoint.
/// </summary>
public const string EnableMetricsKey = "EnableMetrics";
/// <summary>
/// Gets a value indicating whether the application should host static web content from the <see cref="IConfiguration"/>.
/// </summary>

@ -38,6 +38,11 @@ namespace MediaBrowser.Controller
/// <value>The name of the friendly.</value>
string FriendlyName { get; }
/// <summary>
/// Gets a value indicating whether if the server should enable the metrics endpoint.
/// </summary>
bool EnableMetrics { get; }
/// <summary>
/// Gets a URL specific for the request.
/// </summary>

Loading…
Cancel
Save