-
Notifications
You must be signed in to change notification settings - Fork 1
/
FunctionExecutionTracesFilter.cs
51 lines (42 loc) · 1.36 KB
/
FunctionExecutionTracesFilter.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
namespace Gabo.AzureFunctionsTelemetry.ApplicationInsights;
internal class FunctionExecutionTracesFilter : ITelemetryProcessor
{
private readonly ITelemetryProcessor _next;
public FunctionExecutionTracesFilter(ITelemetryProcessor next)
{
_next = next;
}
public void Process(ITelemetry item)
{
if (item is TraceTelemetry trace)
{
if (TelemetryHelper.IsFunctionStartedTelemetry(trace))
{
return;
}
if (TelemetryHelper.IsFunctionCompletedTelemetry(trace))
{
return;
}
if (IsServiceBusBindingMessageErrorProcessingTrace(trace))
{
return;
}
}
_next.Process(item);
}
private static bool IsServiceBusBindingMessageErrorProcessingTrace(TraceTelemetry trace)
{
if (trace.SeverityLevel != SeverityLevel.Error)
{
return false;
}
if (!TelemetryHelper.TryGetCategory(trace, out var category) || category == null)
{
return false;
}
return StringHelper.IsSame(FunctionRuntimeCategory.ServiceBusListener, category) &&
!string.IsNullOrEmpty(trace.Message) &&
trace.Message.StartsWith("Message processing error", StringComparison.OrdinalIgnoreCase);
}
}