Skip to content

Commit 794e2d0

Browse files
authored
Merge pull request #422 from Microsoft/develop
Merge develop to master with changes for 2.3 beta 2
2 parents 22c9295 + a561e02 commit 794e2d0

39 files changed

+734
-174
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
This changelog will be used to generate documentation on [release notes page](http://azure.microsoft.com/en-us/documentation/articles/app-insights-release-notes-dotnet/).
44

5+
## Version 2.3.0-beta2
6+
- Added constructor overloads for TelemetryConfiguration and added creation of a default InMemoryChannel when no channel is specified for a new instance.
7+
TelemetryClient will no longer create an InMemoryChannel on the configuration instance if TelemetryChannel is null, instead the configuration instances will always have a channel when created.
8+
- TelemetryConfiguration will no longer dispose of user provided ITelemetryChannel instances. Users must properly dispose of any channel instances which they create, the configuration will only auto-dispose of default channel instances it creates when none are specified by the user.
9+
510
## Version 2.3.0-beta1
611
- Added metric aggregation functionality via MetricManager and Metric classes.
712
- Exposed a source field on RequestTelemetry. This can be used to store a representation of the component that issued the incoming http request.

GlobalStaticVersion.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<SemanticVersionMajor>2</SemanticVersionMajor>
99
<SemanticVersionMinor>3</SemanticVersionMinor>
1010
<SemanticVersionPatch>0</SemanticVersionPatch>
11-
<PreReleaseMilestone>beta1</PreReleaseMilestone>
11+
<PreReleaseMilestone>beta2</PreReleaseMilestone>
1212
<!--
1313
Date when Semantic Version was changed.
1414
Update for every public release.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ We recommend consuming the library as a NuGet package. Make sure to look for the
2020

2121
### Initialize a TelemetryClient
2222

23-
The `TelemetryClient` object is the primary root object for the library. Almost all functionality around telemetry sending is located on this object. You must intiialize an instance of this object and populate it with your Instrumentation Key to identify your data.
23+
The `TelemetryClient` object is the primary root object for the library. Almost all functionality around telemetry sending is located on this object. You must initialize an instance of this object and populate it with your Instrumentation Key to identify your data.
2424

2525
```C#
2626
using Microsoft.ApplicationInsights;
@@ -62,7 +62,7 @@ Read about [how to use the API and see the results in the portal][api-overview].
6262
## Branches
6363

6464
- [master][master] contains the *latest* published release located on [NuGet][NuGetCore].
65-
- [development][develop] contains the code for the *next* release.
65+
- [develop][develop] contains the code for the *next* release.
6666

6767
## Contributing
6868

Test/CoreSDK.Test/Shared/Channel/TelemetryBufferTest.cs

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,54 @@ public void DefaultValueIsAppropriateForProductionEnvironmentAndUnitTests()
2626
{
2727
var buffer = new TelemetryBuffer();
2828
Assert.Equal(500, buffer.Capacity);
29+
Assert.Equal(1000000, buffer.BacklogSize);
2930
}
3031

3132
[TestMethod]
3233
public void CanBeSetByChannelToTunePerformance()
3334
{
3435
var buffer = new TelemetryBuffer();
3536
buffer.Capacity = 42;
37+
buffer.BacklogSize = 9999;
3638
Assert.Equal(42, buffer.Capacity);
39+
Assert.Equal(9999, buffer.BacklogSize);
3740
}
3841

3942
[TestMethod]
40-
public void WhenNewValueIsLessThanOneSetToDefault()
43+
public void WhenNewValueIsLessThanMinimumSetToDefault()
4144
{
4245
var buffer = new TelemetryBuffer();
4346
buffer.Capacity = 0;
47+
buffer.BacklogSize = 1000; //1001 is the minimum, setting to anything low should be overruled with minimum allowed.
4448

45-
Assert.Equal(buffer.Capacity, 500);
49+
Assert.Equal(500,buffer.Capacity);
50+
Assert.Equal(1001, buffer.BacklogSize);
51+
}
52+
53+
[TestMethod]
54+
public void MaxBacklogCannotBeBelowCapacity()
55+
{
56+
var buffer = new TelemetryBuffer();
57+
buffer.Capacity = 9999; // a value greater than the minimum allowed for MaxBacklogSize
58+
59+
//Attempt to set MaxBacklogSize below Capacity
60+
buffer.BacklogSize = buffer.Capacity - 1;
61+
62+
// Validate that MaximumBacklogSize will be set to Capacity
63+
Assert.Equal(buffer.Capacity, buffer.BacklogSize);
64+
}
65+
66+
[TestMethod]
67+
public void CapacityCannotBeAboveBacklogSize()
68+
{
69+
70+
var buffer = new TelemetryBuffer();
71+
72+
//Attempt to set Capacity above MaxBacklogSize
73+
buffer.Capacity = buffer.BacklogSize + 1;
74+
75+
// Validate that Capacity will be set to MaxBacklogSize
76+
Assert.Equal(buffer.Capacity, buffer.BacklogSize);
4677
}
4778

4879
[TestMethod]
@@ -58,5 +89,28 @@ public void TelemetryBufferCallingOnFullActionWhenBufferCapacityReached()
5889
Assert.NotNull(items);
5990
Assert.Equal(2, items.Count());
6091
}
92+
93+
[TestMethod]
94+
public void TelemetryBufferDoesNotGrowBeyondMaxBacklogSize()
95+
{
96+
TelemetryBuffer buffer = new TelemetryBuffer { Capacity = 2, BacklogSize = 1002};
97+
buffer.OnFull = () => { //intentionaly blank to simulate situation where buffer
98+
//is not emptied.
99+
};
100+
101+
// Add more items to buffer than the max backlog size
102+
for(int i = 0; i < 1005; i++)
103+
{
104+
buffer.Enqueue(new EventTelemetry("Event" + i));
105+
}
106+
107+
108+
109+
// validate that items are not added after maxunsentbacklogsize is reached.
110+
// this also validate that items can still be added after Capacity is reached as it is only a soft limit.
111+
int bufferItemCount = buffer.Dequeue().Count();
112+
Assert.Equal(1002, bufferItemCount);
113+
114+
}
61115
}
62116
}

Test/CoreSDK.Test/Shared/Extensibility/Implementation/Platform/PlatformImplementationTest.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{
33
using System;
44
using System.IO;
5+
using System.Security.Permissions;
56
using System.Text;
67
using Microsoft.VisualStudio.TestTools.UnitTesting;
78

@@ -45,6 +46,23 @@ public void ReadConfigurationXmlIgnoresMissingApplicationInsightsConfigurationFi
4546
Assert.AreEqual(0, configuration.Length);
4647
}
4748

49+
[TestMethod]
50+
public void FailureToReadEnvironmentVariablesDoesNotThrowExceptions()
51+
{
52+
EnvironmentPermission permission = new EnvironmentPermission(EnvironmentPermissionAccess.NoAccess, "PATH");
53+
try
54+
{
55+
permission.PermitOnly();
56+
PlatformImplementation platform = new PlatformImplementation();
57+
Assert.IsNull(platform.GetEnvironmentVariable("PATH"));
58+
permission = null;
59+
}
60+
finally
61+
{
62+
EnvironmentPermission.RevertAll();
63+
}
64+
}
65+
4866
protected virtual void Dispose(bool disposing)
4967
{
5068
if (disposing == true)

Test/CoreSDK.Test/Shared/Extensibility/Implementation/TaskTimerTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public void CancelsPreviousActionWhenStartIsCalledMultipleTimes()
153153
}
154154

155155
[TestMethod]
156-
[Timeout(1000)]
156+
[Timeout(1500)]
157157
public void HandlesAsyncExceptionThrownByTheDelegate()
158158
{
159159
TaskTimer timer = new TaskTimer { Delay = TimeSpan.FromMilliseconds(1) };
@@ -169,7 +169,7 @@ public void HandlesAsyncExceptionThrownByTheDelegate()
169169
}
170170

171171
[TestMethod]
172-
[Timeout(1000)]
172+
[Timeout(1500)]
173173
public void HandlesSyncExceptionThrownByTheDelegate()
174174
{
175175
TaskTimer timer = new TaskTimer { Delay = TimeSpan.FromMilliseconds(1) };

Test/CoreSDK.Test/Shared/Extensibility/Implementation/TelemetryProcessorChainBuilderTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public void BuildUsesTelemetryProcesorFactoryOnEachCall()
8484
[TestMethod]
8585
public void BuildOrdersTelemetryChannelsInOrderOfUseCalls()
8686
{
87-
var config = new TelemetryConfiguration() {TelemetryChannel = new StubTelemetryChannel()};
87+
var config = new TelemetryConfiguration(string.Empty, new StubTelemetryChannel());
8888
StringBuilder outputCollector = new StringBuilder();
8989
var builder = new TelemetryProcessorChainBuilder(config);
9090
builder.Use((next) => new StubTelemetryProcessor(next) { OnProcess = (item) => { outputCollector.Append("processor1"); } });

Test/CoreSDK.Test/Shared/Extensibility/Implementation/Tracing/PortalDiagnosticsSenderTest.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@ private readonly IDiagnoisticsEventThrottlingManager dontThrottleManager
3131
public PortalDiagnosticsSenderTest()
3232
{
3333
var configuration =
34-
new TelemetryConfiguration
35-
{
36-
TelemetryChannel = new StubTelemetryChannel { OnSend = item => this.sendItems.Add(item) },
37-
InstrumentationKey = Guid.NewGuid().ToString()
38-
};
34+
new TelemetryConfiguration(Guid.NewGuid().ToString(), new StubTelemetryChannel { OnSend = item => this.sendItems.Add(item) });
3935

4036
this.nonThrottlingPortalSender = new PortalDiagnosticsSender(
4137
configuration,

Test/CoreSDK.Test/Shared/Extensibility/MetricManagerTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ public void DisposingManagerCreatesAggregatedMetricTelemetry()
261261
private TelemetryClient InitializeTelemetryClient(List<ITelemetry> sentTelemetry)
262262
{
263263
var channel = new StubTelemetryChannel { OnSend = t => sentTelemetry.Add(t) };
264-
var telemetryConfiguration = new TelemetryConfiguration { InstrumentationKey = Guid.NewGuid().ToString(), TelemetryChannel = channel };
264+
var telemetryConfiguration = new TelemetryConfiguration(Guid.NewGuid().ToString(), channel);
265265

266266
var client = new TelemetryClient(telemetryConfiguration);
267267

Test/CoreSDK.Test/Shared/Extensibility/MetricTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ private TelemetryClient InitializeTelemetryClient(List<ITelemetry> sentTelemetry
409409
{
410410
var channel = new StubTelemetryChannel { OnSend = t => sentTelemetry.Add(t) };
411411

412-
var telemetryConfiguration = new TelemetryConfiguration { InstrumentationKey = Guid.NewGuid().ToString(), TelemetryChannel = channel };
412+
var telemetryConfiguration = new TelemetryConfiguration(Guid.NewGuid().ToString(), channel);
413413
telemetryConfiguration.MetricProcessors.Add(new StubMetricProcessor(sentSamples));
414414

415415
var client = new TelemetryClient(telemetryConfiguration);

0 commit comments

Comments
 (0)