feat: adapt to enabled observability features.
This commit is contained in:
@@ -1,18 +1,29 @@
|
||||
using System;
|
||||
using System.Diagnostics.Metrics;
|
||||
using GodotHostTest.Interfaces;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using OwofGames.GodotHost;
|
||||
using OwofGames.GodotHost.Observability;
|
||||
using OwofGames.GodotLume;
|
||||
using R3;
|
||||
|
||||
namespace GodotHostTest.Game.Metrics;
|
||||
|
||||
public class MetricsHandler(IMeterFactory meterFactory, ITargetEventBus targetEventBus) : IHostLifetime
|
||||
public class MetricsHandler(
|
||||
ILogger<MetricsHandler> logger,
|
||||
IOptional<IMeterFactory> meterFactoryWrapper,
|
||||
ITargetEventBus targetEventBus) : IHostLifetime
|
||||
{
|
||||
private IDisposable? _disposables;
|
||||
|
||||
public void Startup()
|
||||
{
|
||||
if (!meterFactoryWrapper.TryGet(out var meterFactory))
|
||||
{
|
||||
logger.LogWarning("Metrics not enabled, cannot start local metrics");
|
||||
return;
|
||||
}
|
||||
|
||||
// create meter
|
||||
var meter = meterFactory.Create();
|
||||
|
||||
@@ -33,6 +44,5 @@ public class MetricsHandler(IMeterFactory meterFactory, ITargetEventBus targetEv
|
||||
public void Shutdown()
|
||||
{
|
||||
_disposables?.Dispose();
|
||||
meterFactory.Create("godot-host-test")?.Dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user