forked from microsoft/ApplicationInsights-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTelemetryProcessorChain.cs
More file actions
88 lines (79 loc) · 3.09 KB
/
TelemetryProcessorChain.cs
File metadata and controls
88 lines (79 loc) · 3.09 KB
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
namespace Microsoft.ApplicationInsights.Extensibility.Implementation
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.ApplicationInsights.Channel;
/// <summary>
/// Represents the TelemetryProcessor chain. Clients should use TelemetryProcessorChainBuilder to construct this object.
/// </summary>
public sealed class TelemetryProcessorChain : IDisposable
{
private readonly SnapshottingList<ITelemetryProcessor> telemetryProcessors = new SnapshottingList<ITelemetryProcessor>();
/// <summary>
/// Initializes a new instance of the <see cref="TelemetryProcessorChain" /> class.
/// Marked internal, as clients should use TelemetryProcessorChainBuilder to build the processing chain.
/// </summary>
internal TelemetryProcessorChain()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="TelemetryProcessorChain" /> class by using the given list elements.
/// Marked internal, as clients should use TelemetryProcessorChainBuilder to build the processing chain.
/// </summary>
internal TelemetryProcessorChain(IEnumerable<ITelemetryProcessor> telemetryProcessors)
{
foreach (var item in telemetryProcessors)
{
this.telemetryProcessors.Add(item);
}
}
/// <summary>
/// Gets the first telemetry processor from the chain of processors.
/// </summary>
internal ITelemetryProcessor FirstTelemetryProcessor
{
get { return this.telemetryProcessors.First(); }
}
/// <summary>
/// Gets the list of TelemetryProcessors making up this chain.
/// </summary>
internal SnapshottingList<ITelemetryProcessor> TelemetryProcessors
{
get { return this.telemetryProcessors; }
}
/// <summary>
/// Invokes the process method in the first telemetry processor.
/// </summary>
public void Process(ITelemetry item)
{
this.telemetryProcessors.First().Process(item);
}
/// <summary>
/// Releases resources used by the current instance of the <see cref="TelemetryProcessorChain"/> class.
/// </summary>
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
private void Dispose(bool disposing)
{
if (disposing)
{
SnapshottingList<ITelemetryProcessor> processors = this.telemetryProcessors;
if (processors != null)
{
foreach (ITelemetryProcessor processor in processors)
{
if (processor is IDisposable disposableProcessor)
{
disposableProcessor.Dispose();
}
}
}
}
}
}
}