Skip to content

Commit fa23faa

Browse files
author
Sergey
committed
Version cnage, update readme, add nuget
double->float
1 parent ad71eef commit fa23faa

24 files changed

+125
-56
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
packages
2+
BuildNuget
23
/Perfon.WebApi/bin/Debug
34
/Perfon.WebApi/bin/Release
45
/Perfon.WebApi/obj/Debug

Perfon.Core/Notifications/IThresholdNotification.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace Perfon.Core.Notifications
1313
/// </summary>
1414
public interface IThresholdNotification
1515
{
16-
double ThresholdValue { get; }
16+
float ThresholdValue { get; }
1717

1818
bool IsThresholdViolated {get;}
1919

Perfon.Core/Notifications/ThresholdBaseNotification.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Perfon.Core.Notifications
99
{
1010
public abstract class ThresholdBaseNotification : IThresholdNotification
1111
{
12-
public ThresholdBaseNotification(double thresholdValue, string message = "")
12+
public ThresholdBaseNotification(float thresholdValue, string message = "")
1313
{
1414
ThresholdValue = thresholdValue;
1515
Message = message;
@@ -20,7 +20,7 @@ public ThresholdBaseNotification(double thresholdValue, string message = "")
2020
}
2121
}
2222

23-
public double ThresholdValue { get; private set; }
23+
public float ThresholdValue { get; private set; }
2424

2525
public bool IsThresholdViolated { get; protected set; }
2626

Perfon.Core/Notifications/ThresholdMaxNotification.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ namespace Perfon.Core.Notifications
99
{
1010
public class ThresholdMaxNotification : ThresholdBaseNotification
1111
{
12-
public ThresholdMaxNotification(double thresholdValue, string message = ""):base(thresholdValue, message)
12+
public ThresholdMaxNotification(float thresholdValue, string message = "")
13+
: base(thresholdValue, message)
1314
{
1415
if(string.IsNullOrEmpty(Message))
1516
{

Perfon.Core/PerfCounterStorages/PerfCounterCSVFileStorage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public Task<IEnumerable<PerfCounterValue>> QueryCounterValues(string counterName
9898
var values = lines.Current.ToString().Split(new string[] { ColumnDelimiter }, StringSplitOptions.RemoveEmptyEntries);
9999
if (columnIdx < values.Length)
100100
{
101-
var item = new PerfCounterValue(DateTime.Parse(values[0]), double.Parse(values[columnIdx]));
101+
var item = new PerfCounterValue(DateTime.Parse(values[0]), float.Parse(values[columnIdx]));
102102
if (item.Timestamp.Date == date.Value.Date)
103103
{
104104
list.Add(item);

Perfon.Core/PerfCounterStorages/PerfCounterInMemoryCacheStorage.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,26 @@ class DataRowPerTimeStamp
3434
public DataRowPerTimeStamp(DateTime timeStamp)
3535
{
3636
TimeStamp = timeStamp;
37-
CountersValue = new Dictionary<string, double>();
37+
CountersValue = new Dictionary<string, float>();
3838
}
3939

4040
public DateTime TimeStamp { get; private set; }
4141

42-
private Dictionary<string, double> CountersValue { get; set; }
42+
private Dictionary<string, float> CountersValue { get; set; }
4343

4444
/// <summary>
4545
/// Returns NaN if perf counter name is not found
4646
/// </summary>
4747
/// <param name="name"></param>
4848
/// <returns></returns>
49-
internal double TryGetCounterValue(string name)
49+
internal float TryGetCounterValue(string name)
5050
{
51-
double res = double.NaN;
51+
float res = float.NaN;
5252
CountersValue.TryGetValue(name, out res);
5353
return res;
5454
}
5555

56-
internal void AddCounterValue(string key, double value)
56+
internal void AddCounterValue(string key, float value)
5757
{
5858
CountersValue[key] = value;
5959
}

Perfon.Core/PerfCounterStorages/PerfCounterLiteDbStorage.cs

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,33 @@ public Task StorePerfCounters(IEnumerable<IPerfCounterData> counters)
4848
// Get customer collection
4949
foreach (var counter in counters)
5050
{
51-
var countersColl = db.GetCollection<PerfCounterValue>(counter.Name.GetHashCode().ToString());
52-
var names = db.GetCollection("CounterNames");
51+
try
52+
{
53+
var countersColl = db.GetCollection<PerfCounterValue>(counter.Name.GetHashCode().ToString());
54+
var names = db.GetCollection("CounterNames");
5355

54-
// Index document using a document property
55-
//countersColl.EnsureIndex("Timestamp", true);
56+
// Index document using a document property
57+
//countersColl.EnsureIndex("Timestamp", true);
5658

57-
var id = names.Find(Query.EQ("Name", counter.Name)).FirstOrDefault();
58-
if (id == null)
59-
{
60-
var doc = new BsonDocument();
61-
doc.Add("Name", counter.Name);
62-
names.Insert(doc);
63-
}
59+
var id = names.Find(Query.EQ("Name", counter.Name)).FirstOrDefault();
60+
if (id == null)
61+
{
62+
var doc = new BsonDocument();
63+
doc.Add("Name", counter.Name);
64+
names.Insert(doc);
65+
}
6466

65-
var item = new PerfCounterValue(now, counter.Value);
67+
var item = new PerfCounterValue(now, counter.Value);
6668

67-
countersColl.Insert(item);
69+
countersColl.Insert(item);
70+
}
71+
catch (Exception exc)
72+
{
73+
if (OnError != null)
74+
{
75+
OnError(new object(), new ErrorEventArgs(exc.ToString()));
76+
}
77+
}
6878
}
6979
}
7080
}

Perfon.Core/PerfCounterStorages/PerfCounterValue.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ public struct PerfCounterValue
1717

1818
//}
1919

20-
public PerfCounterValue(DateTime timestamp, double value):this()
20+
public PerfCounterValue(DateTime timestamp, float value):this()
2121
{
2222
Timestamp = timestamp;
2323
Value = value;
2424
}
2525

2626
public DateTime Timestamp { get; set; }
27-
public double Value { get; set; }
27+
public float Value { get; set; }
2828
}
2929
}

Perfon.Core/PerfCounters/IPerfCounterData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Perfon.Core.PerfCounters
1212
public interface IPerfCounterData
1313
{
1414
string Name { get; }
15-
double Value { get; }
15+
float Value { get; }
1616

1717
string FormattedValue { get; }
1818
//DateTime TimeStamp { get; }

Perfon.Core/PerfCounters/IPerformanceCounter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public interface IPerformanceCounter
3737
/// Thread safe
3838
/// </summary>
3939
/// <returns></returns>
40-
double GetValue();
40+
float GetValue();
4141

4242
/// <summary>
4343
/// Return value as formatted string, using FormatString
@@ -72,7 +72,7 @@ public interface IPerformanceCounter
7272
/// Reset counter value to 0
7373
/// Thread safe
7474
/// </summary>
75-
void Reset(long? newReversedPollingPeriod = null);
75+
void Reset(long? newPollingPeriod = null);
7676

7777
/// <summary>
7878
/// Get current counter value, for pass it to Counter Storage

0 commit comments

Comments
 (0)