Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ public NodeMetrics Sample()
{
using (var process = Process.GetCurrentProcess())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this is wrong - shouldn't we just cache this value somewhere?

{
process.Refresh();
var metrics = new List<NodeMetrics.Types.Metric>()
{
// Memory
// Forcing garbage collection to keep metrics more resilent to occasional allocations
NodeMetrics.Types.Metric.Create(StandardMetrics.MemoryUsed, GC.GetTotalMemory(true)).Value,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be GC

// VirtualMemorySize64 is not best idea here...
NodeMetrics.Types.Metric.Create(StandardMetrics.MemoryUsed, process.WorkingSet64).Value,
NodeMetrics.Types.Metric.Create(StandardMetrics.MemoryAvailable, process.VirtualMemorySize64).Value,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be working set

// CPU Processors
NodeMetrics.Types.Metric.Create(StandardMetrics.Processors, Environment.ProcessorCount).Value,
Expand Down
4 changes: 2 additions & 2 deletions src/contrib/cluster/Akka.Cluster.Metrics/StandardMetrics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Akka.Cluster.Metrics
public static class StandardMetrics
{
/// <summary>
/// Total memory allocated to the currently running process (<see cref="GC.GetTotalMemory"/>)
/// Total memory allocated to the currently running process (<see cref="Process.WorkingSet64"/>)
/// </summary>
public const string MemoryUsed = "MemoryUsed";
/// <summary>
Expand Down Expand Up @@ -84,7 +84,7 @@ public sealed class Memory
/// </summary>
public long Timestamp { get; }
/// <summary>
/// The current process allocated memory (in bytes) (<see cref="GC.GetTotalMemory"/>)
/// The current process allocated memory (in bytes) (<see cref="Process.WorkingSet64"/>)
/// </summary>
public double Used { get; }
/// <summary>
Expand Down
4 changes: 3 additions & 1 deletion src/core/Akka/Util/Extensions/DateTimeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ namespace Akka.Util.Extensions
/// </summary>
public static class DateTimeExtensions
{
private static readonly DateTime UnixOffset = new DateTime(1970, 1, 1);

/// <summary>
/// Converts given date and time to UNIX Timestamp - number of milliseconds elapsed since 1 Jan 1970
/// </summary>
public static long ToTimestamp(this DateTime dateTime)
{
return (long)(dateTime - new DateTime(1970, 1, 1)).TotalMilliseconds;
return (long)(dateTime - UnixOffset).TotalMilliseconds;
}
}
}