Code review comments
This commit is contained in:
Родитель
f470eeeb94
Коммит
d1ae74795f
|
@ -1,2 +1,3 @@
|
|||
Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryExtensions
|
||||
static Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryExtensions.GetEnvelopeName(this Microsoft.ApplicationInsights.Channel.ITelemetry telemetry) -> string
|
||||
static Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryExtensions.SetEnvelopeName(this Microsoft.ApplicationInsights.Channel.ITelemetry telemetry, string envelopeName) -> void
|
|
@ -1,2 +1,3 @@
|
|||
Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryExtensions
|
||||
static Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryExtensions.GetEnvelopeName(this Microsoft.ApplicationInsights.Channel.ITelemetry telemetry) -> string
|
||||
static Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryExtensions.SetEnvelopeName(this Microsoft.ApplicationInsights.Channel.ITelemetry telemetry, string envelopeName) -> void
|
|
@ -1,2 +1,3 @@
|
|||
Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryExtensions
|
||||
static Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryExtensions.GetEnvelopeName(this Microsoft.ApplicationInsights.Channel.ITelemetry telemetry) -> string
|
||||
static Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryExtensions.SetEnvelopeName(this Microsoft.ApplicationInsights.Channel.ITelemetry telemetry, string envelopeName) -> void
|
|
@ -1,2 +1,3 @@
|
|||
Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryExtensions
|
||||
static Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryExtensions.GetEnvelopeName(this Microsoft.ApplicationInsights.Channel.ITelemetry telemetry) -> string
|
||||
static Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryExtensions.SetEnvelopeName(this Microsoft.ApplicationInsights.Channel.ITelemetry telemetry, string envelopeName) -> void
|
|
@ -222,7 +222,7 @@
|
|||
.SerializeDeserializeTelemetryItem<TEndpointData>(expected);
|
||||
|
||||
Assert.AreEqual(
|
||||
Constants.TelemetryNamePrefix + this.ExtractTelemetryNameFromType(typeof(TTelemetry)),
|
||||
this.ExtractTelemetryNameFromType(typeof(TTelemetry)),
|
||||
actual.name);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
}
|
||||
|
||||
[TestMethod]
|
||||
public static void CanSetEnvelopeNameForSupportedTypes()
|
||||
public void CanSetEnvelopeNameForSupportedTypes()
|
||||
{
|
||||
string testEnvelopeName = "Non_Standard*Envelope.Name";
|
||||
|
||||
|
@ -59,24 +59,31 @@
|
|||
pct.SetEnvelopeName(testEnvelopeName);
|
||||
sst.SetEnvelopeName(testEnvelopeName);
|
||||
|
||||
Assert.AreEqual(testEnvelopeName, at.EnvelopeName);
|
||||
Assert.AreEqual(testEnvelopeName, dt.EnvelopeName);
|
||||
Assert.AreEqual(testEnvelopeName, et.EnvelopeName);
|
||||
Assert.AreEqual(testEnvelopeName, ext.EnvelopeName);
|
||||
Assert.AreEqual(testEnvelopeName, mt.EnvelopeName);
|
||||
Assert.AreEqual(testEnvelopeName, pvpt.EnvelopeName);
|
||||
Assert.AreEqual(testEnvelopeName, pvt.EnvelopeName);
|
||||
Assert.AreEqual(testEnvelopeName, rt.EnvelopeName);
|
||||
Assert.AreEqual(testEnvelopeName, pct.Data.EnvelopeName);
|
||||
Assert.AreEqual(testEnvelopeName, sst.Data.EnvelopeName);
|
||||
Assert.AreEqual(testEnvelopeName, at.GetEnvelopeName());
|
||||
Assert.AreEqual(testEnvelopeName, dt.GetEnvelopeName());
|
||||
Assert.AreEqual(testEnvelopeName, et.GetEnvelopeName());
|
||||
Assert.AreEqual(testEnvelopeName, ext.GetEnvelopeName());
|
||||
Assert.AreEqual(testEnvelopeName, mt.GetEnvelopeName());
|
||||
Assert.AreEqual(testEnvelopeName, pvpt.GetEnvelopeName());
|
||||
Assert.AreEqual(testEnvelopeName, pvt.GetEnvelopeName());
|
||||
Assert.AreEqual(testEnvelopeName, rt.GetEnvelopeName());
|
||||
Assert.AreEqual(testEnvelopeName, pct.Data.GetEnvelopeName());
|
||||
Assert.AreEqual(testEnvelopeName, sst.Data.GetEnvelopeName());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public static void SetEnvelopeNameThrowsForUnsupportedTypes()
|
||||
public void SetEnvelopeNameThrowsForUnsupportedTypes()
|
||||
{
|
||||
var nst = new NonSerializableTelemetry();
|
||||
nst.SetEnvelopeName("Any"); // Throws, NonSerializableTelemetry does not implement IAiSerializableTelemetry
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetEnvelopeNameReturnsDefaultForUnsupportedTypes()
|
||||
{
|
||||
var nst = new NonSerializableTelemetry();
|
||||
Assert.AreEqual("Event", nst.GetEnvelopeName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
{
|
||||
internal const string ProfileQueryEndpoint = "https://dc.services.visualstudio.com/api/profiles/{0}/appId";
|
||||
|
||||
internal const string TelemetryNamePrefix = "";
|
||||
|
||||
internal const string DevModeTelemetryNamePrefix = "Dev.";
|
||||
|
||||
internal const string EventNameForUnknownTelemetry = "ConvertedTelemetry";
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
var eventName = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0}{1}",
|
||||
telemetry.IsDeveloperMode() ? Constants.DevModeTelemetryNamePrefix : Constants.TelemetryNamePrefix,
|
||||
telemetry.IsDeveloperMode() ? Constants.DevModeTelemetryNamePrefix : string.Empty,
|
||||
telemetryName);
|
||||
|
||||
return eventName;
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
/// </summary>
|
||||
public static class TelemetryExtensions
|
||||
{
|
||||
private const string DefaultEnvelopeName = "Event";
|
||||
|
||||
/// <summary>
|
||||
/// Sets envelope name for ITelemetry object.
|
||||
/// </summary>
|
||||
|
@ -25,5 +27,22 @@
|
|||
throw new ArgumentException("Provided telemetry object does not support envelope name.", nameof(telemetry));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets envelope name for ITelemetry object.
|
||||
/// </summary>
|
||||
/// <param name="telemetry">ITelemetry object to set envelope name for.</param>
|
||||
/// <exception cref="ArgumentException">Concrete implementation of ITelemetry object does not expose envelope name.</exception>
|
||||
public static string GetEnvelopeName(this ITelemetry telemetry)
|
||||
{
|
||||
if (telemetry is IAiSerializableTelemetry aiSerializableTelemetry)
|
||||
{
|
||||
return aiSerializableTelemetry.TelemetryName;
|
||||
}
|
||||
else
|
||||
{
|
||||
return DefaultEnvelopeName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче