Skip to content

Commit 255760d

Browse files
committed
Add process uptime to host status api
1 parent befbf86 commit 255760d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/WebJobs.Script.WebHost/Controllers/HostController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ public async Task<IActionResult> GetHostStatus([FromServices] IScriptHostManager
7575
State = scriptHostManager.State.ToString(),
7676
Version = ScriptHost.Version,
7777
VersionDetails = Utility.GetInformationalVersion(typeof(ScriptHost)),
78-
Id = await hostIdProvider.GetHostIdAsync(CancellationToken.None)
78+
Id = await hostIdProvider.GetHostIdAsync(CancellationToken.None),
79+
ProcessUptime = (long)(DateTime.UtcNow - Process.GetCurrentProcess().StartTime).TotalMilliseconds
7980
};
8081

8182
var lastError = scriptHostManager.LastError;

src/WebJobs.Script.WebHost/Models/HostStatus.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

4+
using System;
45
using System.Collections.ObjectModel;
56
using Newtonsoft.Json;
67

@@ -37,5 +38,11 @@ public class HostStatus
3738
/// </summary>
3839
[JsonProperty(PropertyName = "errors", DefaultValueHandling = DefaultValueHandling.Ignore)]
3940
public Collection<string> Errors { get; set; }
41+
42+
/// <summary>
43+
/// Gets or sets the uptime of the process
44+
/// </summary>
45+
[JsonProperty(PropertyName = "processUptime", DefaultValueHandling = DefaultValueHandling.Ignore)]
46+
public long ProcessUptime { get; set; }
4047
}
4148
}

0 commit comments

Comments
 (0)