forked from open-telemetry/opentelemetry-dotnet-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAspNetInstrumentationEventSource.cs
More file actions
68 lines (58 loc) · 2.25 KB
/
AspNetInstrumentationEventSource.cs
File metadata and controls
68 lines (58 loc) · 2.25 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
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
using System;
using System.Diagnostics.Tracing;
using OpenTelemetry.Internal;
namespace OpenTelemetry.Instrumentation.AspNet.Implementation;
/// <summary>
/// EventSource events emitted from the project.
/// </summary>
[EventSource(Name = "OpenTelemetry-Instrumentation-AspNet")]
internal sealed class AspNetInstrumentationEventSource : EventSource
{
public static AspNetInstrumentationEventSource Log = new();
[NonEvent]
public void RequestFilterException(string operationName, Exception ex)
{
if (this.IsEnabled(EventLevel.Error, EventKeywords.All))
{
this.RequestFilterException(operationName, ex.ToInvariantString());
}
}
[NonEvent]
public void EnrichmentException(string eventName, Exception ex)
{
if (this.IsEnabled(EventLevel.Error, EventKeywords.All))
{
this.EnrichmentException(eventName, ex.ToInvariantString());
}
}
[NonEvent]
public void FailedToReadEnvironmentVariable(string envVarName, Exception ex)
{
if (this.IsEnabled(EventLevel.Error, EventKeywords.All))
{
this.EnrichmentException(envVarName, ex.ToInvariantString());
}
}
[Event(1, Message = "Request is filtered out and will not be collected. Operation='{0}'", Level = EventLevel.Verbose)]
public void RequestIsFilteredOut(string operationName)
{
this.WriteEvent(1, operationName);
}
[Event(2, Message = "Filter callback threw an exception. Request will not be collected. Operation='{0}': {1}", Level = EventLevel.Error)]
public void RequestFilterException(string operationName, string exception)
{
this.WriteEvent(2, operationName, exception);
}
[Event(3, Message = "Enrich callback threw an exception. Event='{0}': {1}", Level = EventLevel.Error)]
public void EnrichmentException(string eventName, string exception)
{
this.WriteEvent(3, eventName, exception);
}
[Event(4, Message = "Failed to read environment variable='{0}': {1}", Level = EventLevel.Error)]
public void FailedToReadEnvironmentVariable(string envVarName, string exception)
{
this.WriteEvent(4, envVarName, exception);
}
}