mirror of https://github.com/jellyfin/jellyfin.git
refactor metrics
This commit is contained in:
parent
f963ce1d58
commit
20d85066cc
|
@ -466,7 +466,7 @@ namespace Emby.Server.Implementations
|
|||
|
||||
ConfigurationManager.AddParts(GetExports<IConfigurationFactory>());
|
||||
|
||||
NetManager = new NetworkManager(ConfigurationManager, LoggerFactory.CreateLogger<NetworkManager>());
|
||||
NetManager = new NetworkManager(ConfigurationManager, LoggerFactory.CreateLogger<NetworkManager>());
|
||||
|
||||
var networkConfiguration = ConfigurationManager.GetNetworkConfiguration();
|
||||
HttpPort = networkConfiguration.HttpServerPortNumber;
|
||||
|
@ -600,6 +600,7 @@ namespace Emby.Server.Implementations
|
|||
serviceCollection.AddScoped<DynamicHlsHelper>();
|
||||
serviceCollection.AddScoped<IClientEventLogger, ClientEventLogger>();
|
||||
serviceCollection.AddSingleton<IDirectoryService, DirectoryService>();
|
||||
serviceCollection.AddSingleton<IMetricsCollector, PrometheusMetricsCollector>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Data.Enums;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
|
@ -34,7 +35,7 @@ namespace Emby.Server.Implementations.Metrics
|
|||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PrometheusMetricsCollector" /> class.
|
||||
/// </summary>
|
||||
/// <param name="libraryManager">The library manager</param>
|
||||
/// <param name="libraryManager">The library manager. </param>
|
||||
public PrometheusMetricsCollector(ILibraryManager libraryManager)
|
||||
{
|
||||
_libraryManager = libraryManager;
|
||||
|
@ -53,9 +54,11 @@ namespace Emby.Server.Implementations.Metrics
|
|||
{
|
||||
foreach (var type in _metricTypes)
|
||||
{
|
||||
BaseItemKind item;
|
||||
Enum.TryParse(type, out item);
|
||||
var query = new InternalItemsQuery
|
||||
{
|
||||
IncludeItemTypes = new[] { type }
|
||||
IncludeItemTypes = new[] { item }
|
||||
};
|
||||
int count = _libraryManager.GetCount(query);
|
||||
_itemCountGauge.WithLabels(type).Set(count);
|
||||
|
|
Loading…
Reference in New Issue