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