-
Notifications
You must be signed in to change notification settings - Fork 287
/
TraceSeverityLevelDimensionExtractor.cs
33 lines (29 loc) · 1.25 KB
/
TraceSeverityLevelDimensionExtractor.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
namespace Microsoft.ApplicationInsights.Extensibility.Implementation.Metrics
{
using System;
using System.Globalization;
using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.DataContracts;
internal class TraceSeverityLevelDimensionExtractor : IDimensionExtractor
{
// There are 5 enumeration values to identify severity level.
// Plus 1 for trace called without severity level specified.
// https://docs.microsoft.com/en-us/dotnet/api/microsoft.applicationinsights.datacontracts.severitylevel?view=azure-dotnet
public int MaxValues { get; set; } = 6;
public string DefaultValue { get; set; } = MetricTerms.Autocollection.Common.PropertyValues.Unspecified;
public string Name { get; set; } = MetricTerms.Autocollection.TraceCount.PropertyNames.SeverityLevel;
public string ExtractDimension(ITelemetry item)
{
var trace = item as TraceTelemetry;
if (trace?.SeverityLevel != null)
{
var sevLevel = (int)trace.SeverityLevel;
return sevLevel.ToString(CultureInfo.InvariantCulture);
}
else
{
return string.Empty;
}
}
}
}