-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPayload.cs
54 lines (44 loc) · 1.42 KB
/
Payload.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
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json.Serialization;
namespace NewRelic.Azure
{
public class Payload
{
[JsonPropertyName("common")]
public CommonAttributes Common { get; set; } = new CommonAttributes();
[JsonPropertyName("logs")]
public List<LogItem> Logs { get; } = new List<LogItem>();
public void AddCommonAttribute(string key, string value)
{
Common.AddAttribute(key, value);
}
public void AddLogItem(LogItem logItem)
{
Logs.Add(logItem);
}
}
public class CommonAttributes
{
[JsonPropertyName("attributes")]
public Dictionary<string, string> attributes { get; } = new Dictionary<string, string>();
public void AddAttribute(string key, string value)
{
attributes.Add(key, value);
}
}
public class LogItem
{
[JsonPropertyName("timestamp")]
public long timestamp { get; set; }
[JsonPropertyName("message")]
public string message { get; set; }
[JsonPropertyName("attributes")]
public Dictionary<string, string> attributes { get; } = new Dictionary<string, string>();
public void AddAttribute(string key, string value)
{
attributes.Add(key, value);
}
}
}