public void GetTimeFromProcessStartIsNotInHours() { var context = new OperationContext(new Context(Logger)); var timeFromProcessStart = LifetimeTrackerTracer.GetTimeFromProcessStart(context); timeFromProcessStart.ShouldBeSuccess(); timeFromProcessStart.Value.Hours.Should().Be(0); }
private static void ReportServiceStarted( OperationContext context, IDistributedCacheServiceHost host, Result <ServiceOfflineDurationTracker> trackerResult, TimeSpan startupDuration) { var shutdownTimeUtc = trackerResult.Then(v => v.GetShutdownTime(context, logTimeStampToFile: true)); LifetimeTrackerTracer.ServiceStarted(context, startupDuration, shutdownTimeUtc); host.OnStartedService(); }
private static void ReportServiceStarted( Context context, IDistributedCacheServiceHost host, Result <ServiceOfflineDurationTracker> trackerResult, TimeSpan startupDuration) { var offlineTimeResult = trackerResult.Then(v => v.GetOfflineDuration(new OperationContext(context))); LifetimeTrackerTracer.ServiceStarted(context, offlineTimeResult, startupDuration); host.OnStartedService(); }
/// <summary> /// Request a graceful shutdown of a current service instance. /// </summary> /// <remarks> The operation will succeed only if <see cref="SetLifetimeManager"/> method was called.</remarks> public static void RequestTeardown(Context context, string reason) { var lifetimeManager = _lifetimeManager; if (lifetimeManager == null) { context.Warning("Can't teardown the instance because lifetime manager is not available."); } else { LifetimeTrackerTracer.TeardownRequested(context, reason); lifetimeManager.RequestTeardown(reason); } }
private static void ReportServiceStopped(Context context, IDistributedCacheServiceHost host, BoolResult result, TimeSpan shutdownDuration) { LifetimeTrackerTracer.ServiceStopped(context, result, shutdownDuration); host.OnTeardownCompleted(); }
private static void ReportShuttingDownService(Context context) { LifetimeTrackerTracer.ShuttingDownService(context); }
private static Task ReportStartingServiceAsync(Context context, IDistributedCacheServiceHost host) { LifetimeTrackerTracer.StartingService(context); return(host.OnStartingServiceAsync()); }
private static void ReportServiceStartupFailed(Context context, Exception exception, TimeSpan startupDuration) { LifetimeTrackerTracer.ServiceStartupFailed(context, exception, startupDuration); }