-
Notifications
You must be signed in to change notification settings - Fork 1k
/
MetricsCollectorMock.cs
47 lines (42 loc) · 1.72 KB
/
MetricsCollectorMock.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//-----------------------------------------------------------------------
// <copyright file="MetricsCollectorMock.cs" company="Akka.NET Project">
// Copyright (C) 2009-2022 Lightbend Inc. <http://www.lightbend.com>
// Copyright (C) 2013-2022 .NET Foundation <https://github.com/akkadotnet/akka.net>
// </copyright>
//-----------------------------------------------------------------------
using System;
using Akka.Actor;
using Akka.Cluster.Metrics.Serialization;
using Google.Protobuf.WellKnownTypes;
using Address = Akka.Actor.Address;
namespace Akka.Cluster.Metrics.Tests.Helpers
{
/// <summary>
/// Metrics collector mock implementation
/// </summary>
public class MetricsCollectorMock : IMetricsCollector
{
private readonly ActorSystem _system;
private readonly Random _random;
public MetricsCollectorMock(ActorSystem system)
{
_system = system;
_random = new Random();
}
/// <inheritdoc />
public NodeMetrics Sample()
{
return new NodeMetrics(new Address("akka", _system.Name), DateTime.UtcNow.ToTimestamp(), new []
{
new NodeMetrics.Types.Metric("metric1", _random.Next(0, 100), new NodeMetrics.Types.EWMA(5, 0.5)),
new NodeMetrics.Types.Metric("metric2", _random.Next(0, 100), new NodeMetrics.Types.EWMA(5, 0.2)),
new NodeMetrics.Types.Metric("metric3", _random.Next(0, 100), new NodeMetrics.Types.EWMA(5, 0.3)),
new NodeMetrics.Types.Metric("metric4", _random.Next(0, 100), new NodeMetrics.Types.EWMA(5, 0.7))
});
}
/// <inheritdoc />
public void Dispose()
{
}
}
}