Skip to content

Commit

Permalink
Merge pull request #828 from Microsoft/develop
Browse files Browse the repository at this point in the history
merge develop to master (prep 2.7-beta1)
  • Loading branch information
TimothyMothra authored Jun 4, 2018
2 parents f9b6b15 + b4495b3 commit dce06e7
Show file tree
Hide file tree
Showing 63 changed files with 1,926 additions and 295 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ AppPackages/

# Others
sql/
[Vv]swhere/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
Expand Down
8 changes: 4 additions & 4 deletions GlobalStaticVersion.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
Update for every public release.
-->
<SemanticVersionMajor>2</SemanticVersionMajor>
<SemanticVersionMinor>6</SemanticVersionMinor>
<SemanticVersionPatch>4</SemanticVersionPatch>
<SemanticVersionMinor>7</SemanticVersionMinor>
<SemanticVersionPatch>0</SemanticVersionPatch>
<!--Valid values: beta1, beta2, EMPTY for stable -->
<PreReleaseMilestone></PreReleaseMilestone>
<PreReleaseMilestone>beta1</PreReleaseMilestone>
<!--
Date when Semantic Version was changed.
Update for every public release.
NOTE!!!!!! Do not update when updating PreReleaseMilestone update
as it will restart file versions so 2.4.0-beta1 may have higher
file version (like 2.4.0.2222) than 2.4.0-beta2 (like 2.4.0.1111)
-->
<SemanticVersionDate>2018-02-12</SemanticVersionDate>
<SemanticVersionDate>2018-05-21</SemanticVersionDate>

<PreReleaseVersion Condition="'$(PreReleaseVersion)'==''">$([MSBuild]::Divide($([System.DateTime]::Now.Subtract($([System.DateTime]::Parse($(SemanticVersionDate)))).TotalMinutes), 5).ToString('F0'))</PreReleaseVersion>
</PropertyGroup>
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions Schema/PublicSchema/DataPoint.bond
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ namespace AI
[Description("Metric data single measurement.")]
struct DataPoint
{
[Description("Namespace of the metric.")]
[MaxStringLength("256")]
5: string ns;

[Description("Name of the metric.")]
[MaxStringLength("1024")]
10: required string name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
<Compile Include="TelemetryItemType.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="MicroBuild.Core" Version="0.3.0">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="Bond.CSharp" Version="7.0.1">
<PrivateAssets>build</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ namespace AI
[System.CodeDom.Compiler.GeneratedCode("gbc", "0.10.1.0")]
public partial class DataPoint
{
[global::Bond.Attribute("Description", "Namespace of the metric.")]
[global::Bond.Attribute("MaxStringLength", "256")]
[global::Bond.Id(5)]
public string ns { get; set; }

[global::Bond.Attribute("Description", "Name of the metric.")]
[global::Bond.Attribute("MaxStringLength", "1024")]
[global::Bond.Id(10), global::Bond.Required]
Expand Down Expand Up @@ -68,6 +73,7 @@ public DataPoint()

protected DataPoint(string fullName, string name)
{
ns = "";
this.name = "";
kind = DataPointType.Measurement;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
<PackageReference Include="CompareNETObjects" Version="3.12.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.4.0" />
<PackageReference Include="MicroBuild.Core" Version="0.3.0">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="Moq" Version="4.8.2" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,36 @@ public void DependencyTelemetryHasCorrectValueOfSamplingPercentageAfterSerializa
Assert.AreEqual(10, item.sampleRate);
}

[TestMethod]
public void DependencyTelemetrySetGetOperationDetail()
{
const string key = "foo";
const string detail = "bar";

var telemetry = this.CreateRemoteDependencyTelemetry("mycommand");
telemetry.SetOperationDetail(key, detail);
Assert.IsTrue(telemetry.TryGetOperationDetail(key, out object retrievedValue));
Assert.IsNotNull(retrievedValue);
Assert.AreEqual(detail, retrievedValue.ToString());

// Clear and verify the detail is no longer present
telemetry.ClearOperationDetails();
Assert.IsFalse(telemetry.TryGetOperationDetail(key, out retrievedValue));
}

[TestMethod]
public void DependencyTelemetryGetUnsetOperationDetail()
{
const string key = "foo";

var telemetry = this.CreateRemoteDependencyTelemetry("mycommand");
Assert.IsFalse(telemetry.TryGetOperationDetail(key, out object retrievedValue));
Assert.IsNull(retrievedValue);

// should not throw
telemetry.ClearOperationDetails();
}

#if !NETCOREAPP1_1
[TestMethod]
public void DependencyTelemetryDeepCloneCopiesAllProperties()
Expand All @@ -185,7 +215,7 @@ public void DependencyTelemetryDeepCloneCopiesAllProperties()
private DependencyTelemetry CreateRemoteDependencyTelemetry()
{
DependencyTelemetry item = new DependencyTelemetry
{
{
Timestamp = DateTimeOffset.Now,
Sequence = "4:2",
Name = "MyWebServer.cloudapp.net",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ public void MetricTelemetrySuppliesPropertiesForCustomerToSendAggregatedMetric()
}

[TestMethod]
public void AggregateMetricTelemetrySerializesToJsonCorrectly()
public void AggregateMetricTelemetrySerializesToJsonCorrectlyWithNamespace()
{
var expected = new MetricTelemetry();

expected.MetricNamespace = "My Namespace";
expected.Name = "My Page";
#pragma warning disable CS0618
expected.Value = 42;
Expand All @@ -82,6 +83,42 @@ public void AggregateMetricTelemetrySerializesToJsonCorrectly()

Assert.AreEqual(2, item.data.baseData.ver);
Assert.AreEqual(1, item.data.baseData.metrics.Count);
Assert.AreEqual(expected.MetricNamespace, item.data.baseData.metrics[0].ns);
Assert.AreEqual(expected.Name, item.data.baseData.metrics[0].name);
Assert.AreEqual(AI.DataPointType.Aggregation, item.data.baseData.metrics[0].kind);
#pragma warning disable CS0618
Assert.AreEqual(expected.Value, item.data.baseData.metrics[0].value);
#pragma warning restore CS0618
Assert.AreEqual(expected.Count.Value, item.data.baseData.metrics[0].count.Value);
Assert.AreEqual(expected.Min.Value, item.data.baseData.metrics[0].min.Value);
Assert.AreEqual(expected.Max.Value, item.data.baseData.metrics[0].max.Value);
Assert.AreEqual(expected.StandardDeviation.Value, item.data.baseData.metrics[0].stdDev.Value);

AssertEx.AreEqual(expected.Properties.ToArray(), item.data.baseData.properties.ToArray());
}

[TestMethod]
public void AggregateMetricTelemetrySerializesToJsonCorrectlyWithoutNamespace()
{
var expected = new MetricTelemetry();

expected.Name = "My Page";
#pragma warning disable CS0618
expected.Value = 42;
#pragma warning restore CS0618
expected.Count = 5;
expected.Min = 1.2;
expected.Max = 6.4;
expected.StandardDeviation = 0.5;
expected.Properties.Add("Property1", "Value1");

var item = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem<MetricTelemetry, AI.MetricData>(expected);

Assert.AreEqual(typeof(AI.MetricData).Name, item.data.baseType);

Assert.AreEqual(2, item.data.baseData.ver);
Assert.AreEqual(1, item.data.baseData.metrics.Count);
Assert.AreEqual(String.Empty, item.data.baseData.metrics[0].ns);
Assert.AreEqual(expected.Name, item.data.baseData.metrics[0].name);
Assert.AreEqual(AI.DataPointType.Aggregation, item.data.baseData.metrics[0].kind);
#pragma warning disable CS0618
Expand All @@ -99,13 +136,15 @@ public void AggregateMetricTelemetrySerializesToJsonCorrectly()
public void MetricTelemetrySuppliesConstructorThatAllowsToFullyPopulateAggregationData()
{
var instance = new MetricTelemetry(
metricNamespace: "Test MetricNamespace",
name: "Test Metric",
count: 4,
sum: 40,
min: 5,
max: 15,
standardDeviation: 4.2);

Assert.AreEqual("Test MetricNamespace", instance.MetricNamespace);
Assert.AreEqual("Test Metric", instance.Name);
Assert.AreEqual(4, instance.Count);
Assert.AreEqual(40, instance.Sum);
Expand All @@ -119,13 +158,15 @@ public void MetricTelemetrySuppliesPropertiesForCustomerToSendAggregionData()
{
var instance = new MetricTelemetry();

instance.MetricNamespace = "Test MetricNamespace";
instance.Name = "Test Metric";
instance.Count = 4;
instance.Sum = 40;
instance.Min = 5.0;
instance.Max = 15.0;
instance.StandardDeviation = 4.2;

Assert.AreEqual("Test MetricNamespace", instance.MetricNamespace);
Assert.AreEqual("Test Metric", instance.Name);
Assert.AreEqual(4, instance.Count);
Assert.AreEqual(40, instance.Sum);
Expand All @@ -150,12 +191,14 @@ public void MetricTelemetrySerializesStructuredIKeyCorrectlyPreservingCaseOfPref
public void SanitizeWillTrimAppropriateFields()
{
MetricTelemetry telemetry = new MetricTelemetry();
telemetry.MetricNamespace = new string('Q', Property.MaxNameLength + 1);
telemetry.Name = new string('Z', Property.MaxNameLength + 1);
telemetry.Properties.Add(new string('X', Property.MaxDictionaryNameLength) + 'X', new string('X', Property.MaxValueLength + 1));
telemetry.Properties.Add(new string('X', Property.MaxDictionaryNameLength) + 'Y', new string('X', Property.MaxValueLength + 1));

((ITelemetry)telemetry).Sanitize();

Assert.AreEqual(new string('Q', 256), telemetry.MetricNamespace);
Assert.AreEqual(new string('Z', Property.MaxNameLength), telemetry.Name);

Assert.AreEqual(2, telemetry.Properties.Count);
Expand Down Expand Up @@ -278,6 +321,7 @@ public void MetricTelemetryDeepCloneCopiesAllProperties()
{
var metric = new MetricTelemetry();

metric.MetricNamespace = "My Namespace";
metric.Name = "My Page";
#pragma warning disable CS0618
metric.Value = 42;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,9 @@ public void RichPayloadEventSourceMetricSentTest()
{
this.DoTracking(
RichPayloadEventSource.Keywords.Metrics,
#pragma warning disable CS0618
new MetricTelemetry("TestMetric", 1),
new MetricTelemetry("Test Metric Namespace", "Test Metric Name", 1, 42, 42, 42, 0),
typeof(External.MetricData),
(client, item) => { client.TrackMetric((MetricTelemetry)item); });
#pragma warning restore CS0618
}

/// <summary>
Expand Down
Loading

0 comments on commit dce06e7

Please sign in to comment.