forked from BlueMountainCapital/riemann-csharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Event.cs
88 lines (76 loc) · 3.59 KB
/
Event.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using System;
using System.Collections.Generic;
namespace Riemann {
///
/// <summary>Represents a single event ready to send to Riemann.</summary>
///
public struct Event {
///
/// <summary>This is the service we are reporting events about.</summary>
///
public readonly string Service;
///
/// <summary>This is the host generating the event.</summary>
///
public readonly string Host;
///
/// <summary>This is the current state of the service.</summary>
///
public readonly string State;
///
/// <summary>Additional details regarding the state of the service.</summary>
///
public readonly string Description;
///
/// <summary>A value which represents the state of the service.</summary>
///
public readonly float Metric;
///
/// <summary>Amount of time this metric should be considered valid.</summary>
///
public readonly int TTL;
///
/// <summary>Freeform list of strings, will override the tags set from the Client</summary>
///
public readonly IList<string> Tags;
/// <summary> Custom name/value pairs of attributes </summary>
public readonly Dictionary<string, string> Attributes;
/// <summary>Constructs an event</summary>
/// <param name="service">Service name</param>
/// <param name="state">Current status of the service.</param>
/// <param name="description">Additional details regarding the state of the service.</param>
/// <param name="metric">A value which represents the state of the service.</param>
/// <param name="ttl">Amount of time the value will stay valid for a service.</param>
/// <param name="tags">List of tags to associate with this event</param>
/// <param name="attributes">Any custom data for the event, as name/value pairs</param>
/// <exception cref="ArgumentException">Length of state is more than 255 characters.</exception>
public Event(string service, string state, string description, float metric, int ttl = 0,
List<string> tags = null, Dictionary<string, string> attributes = null) :
this(null, service, state, description, metric, ttl, tags, attributes) {
}
/// <summary>Constructs an event</summary>
/// <param name="host">Originiating server</param>
/// <param name="service">Service name</param>
/// <param name="state">Current status of the service.</param>
/// <param name="description">Additional details regarding the state of the service.</param>
/// <param name="metric">A value which represents the state of the service.</param>
/// <param name="ttl">Amount of time the value will stay valid for a service.</param>
/// <param name="tags">List of tags to associate with this event</param>
/// <param name="attributes">Any custom data for the event, as name/value pairs</param>
/// <exception cref="ArgumentException">Length of state is more than 255 characters.</exception>
public Event(string host, string service, string state, string description, float metric, int ttl = 0,
List<string> tags = null, Dictionary<string, string> attributes = null) {
if (!string.IsNullOrEmpty(state) && state.Length > 255) {
throw new ArgumentException("State parameter is too long, must be 255 characters or less", "state");
}
Host = host;
Service = service;
State = state;
Description = description;
Metric = metric;
TTL = ttl;
Tags = tags ?? new List<string>();
Attributes = attributes ?? new Dictionary<string, string>();
}
}
}