Skip to content

Commit

Permalink
Removing IMemoryCache totally
Browse files Browse the repository at this point in the history
  • Loading branch information
puneetg1983 committed Jun 9, 2021
1 parent 5785e2c commit 76caa1a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 28 deletions.
15 changes: 3 additions & 12 deletions Kudu.Services.Web/Pages/NewUI/ProcessExplorer.cshtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@page
<link href="~/Content/Styles/jsonTree.css" rel="stylesheet" />
<link href="~/Content/Styles/app.css" rel="stylesheet" />

<link href="https://fonts.googleapis.com/css?family=PT+Mono" rel="stylesheet">
<!-- Font Awesome CSS -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.1/css/all.css" integrity="sha384-5sAR7xN1Nv6T6+dT2mhtzEpVJvfS3NScPQTrOxhwjIuvcA67KV2R5Jz6kr4abQsz" crossorigin="anonymous">
Expand All @@ -14,22 +13,14 @@ Released under the MIT license (LICENSE.txt)
-->

<style>
a:link, a:visited {
color: white;
}
h2, h3, h4 {
font-size: initial;
}
.table > tbody > tr > td {
vertical-align: middle;
}
li {
list-style-type: none;
padding: 0;
margin: 0;
margin: 0;
}
</style>

Expand Down Expand Up @@ -125,9 +116,9 @@ Released under the MIT license (LICENSE.txt)
"<td>" + item.pid + "<a class='process-details' role='button' href='/api/processes/" + item.pid + "'><i class='ml-2 feather fas fa-info-circle fa-lg clr-icon-navbar'></i></a></td>" +
"<td>" + item.uid + "</td>" +
"<td><select class='heapType' name='heapType' id='heapType'><option value='WithHeap'>WithHeap</option><option value='Full'>Full</option><option value='Mini'>Mini</option><option value='Triage'>Triage</option></select></td>" +
"<td><a class='memory-dump btn btn-primary' role='button' href='/api/processes/" + item.pid + "/dump'>Collect Dump</a> </td>" +
"<td><a class='memory-dump btn btn-primary btn-sm' role='button' href='/api/processes/" + item.pid + "/dump'>Collect Dump</a> </td>" +
"<td><select class='profilingTimeout' name='profilingTimeout' id='profilingTimeout'><option value='30'>30s</option><option value='60' selected>60s</option><option value='90'>90s</option><option value='120'>120s</option></select></td>" +
"<td><a class='start-profiler btn btn-primary' role='button' href='/api/processes/" + item.pid + "/profile/start'> Start Profiling</a> </td > " +
"<td><a class='start-profiler btn btn-primary btn-sm' role='button' href='/api/processes/" + item.pid + "/profile/start'> Start Profiling</a> </td > " +
"</tr>";
$('#processTable').append(rows);
});
Expand Down
24 changes: 8 additions & 16 deletions Kudu.Services/Diagnostics/LinuxProcessController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,13 @@ namespace Kudu.Services.Performance

public class LinuxProcessController : Controller
{
const string dotnetMonitorPort = "50051";
const string DotNetMonitorAddressCacheKey = "DotNetMonitorAddressCacheKey";
const string DotnetMonitorPort = "50051";
const string AcceptEncodingHeader = "Accept-Encoding";

private readonly IMemoryCache _cache;
private readonly HttpProxyOptions _options;

public LinuxProcessController(IMemoryCache memoryCache)
public LinuxProcessController()
{
_cache = memoryCache;
_options = HttpProxyOptionsBuilder.Instance.WithHttpClientName("DotnetMonitorProxyClient")
.WithBeforeSend((context, request) =>
{
Expand Down Expand Up @@ -180,21 +177,16 @@ private string GetDotNetMonitorAddress()
{
if (OSDetector.IsOnWindows())
{
return "http://localhost:52323";
return "https://localhost:52323";
}

var dotnetMonitorAddress = _cache.GetOrCreate(DotNetMonitorAddressCacheKey, entry =>
var ipAddress = GetIpAddress();
if (!string.IsNullOrWhiteSpace(ipAddress))
{
entry.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(2);
var ipAddress = GetIpAddress();
if (!string.IsNullOrWhiteSpace(ipAddress))
{
return $"http://{ipAddress}:{dotnetMonitorPort}";
}
return string.Empty;
});
return $"http://{ipAddress}:{DotnetMonitorPort}";
}

return dotnetMonitorAddress;
return string.Empty;
}

private string GetIpAddress()
Expand Down

0 comments on commit 76caa1a

Please sign in to comment.