Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove sampling score on telemetry items related to Context.User.Id #651

Merged
merged 3 commits into from
Nov 17, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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/).

## Version 2.5.0-beta2

- Remove calculation of sampling-score based on Context.User.Id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add link to the issue as well? So that it's easier for someone reading change log to understand more about the change.
#625

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


## Version 2.5.0-beta1
- Method `Sanitize` on classes implementing `ITelemetry` no longer modifies the `TelemetryContext` fields. Serialized event json and ETW event will still have context tags sanitized.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,30 @@ public class SamplingScoreGeneratorTest
private static readonly Random Rand = new Random();

[TestMethod]
public void SamplingScoreGeneratedUsingUserIdIfPresent()
public void SamplingScoreIsntChangedByUserId()
{
string userId = GenerateRandomUserId();
string opId = GenerateRandomOperaitonId();

var eventTelemetry = new EventTelemetry();
eventTelemetry.Context.User.Id = userId;
eventTelemetry.Context.Operation.Id = GenerateRandomOperaitonId();
eventTelemetry.Context.Operation.Id = opId;
eventTelemetry.Context.User.Id = GenerateRandomUserId();

var requestTelemetry = new RequestTelemetry();
requestTelemetry.Context.User.Id = userId;
requestTelemetry.Context.Operation.Id = GenerateRandomOperaitonId();
requestTelemetry.Context.Operation.Id = opId;
requestTelemetry.Context.User.Id = GenerateRandomUserId();

var eventTelemetrySamplingScore = SamplingScoreGenerator.GetSamplingScore(eventTelemetry);
var requestTelemetrySamplingScore = SamplingScoreGenerator.GetSamplingScore(requestTelemetry);
var eventTelemetrySamplingScoreNoUserId = SamplingScoreGenerator.GetSamplingScore(eventTelemetry);
var requestTelemetrySamplingScoreNoUserId = SamplingScoreGenerator.GetSamplingScore(requestTelemetry);

Assert.AreEqual(eventTelemetrySamplingScore, requestTelemetrySamplingScore, 12);
Assert.AreEqual(eventTelemetrySamplingScoreNoUserId, requestTelemetrySamplingScoreNoUserId, 12);

eventTelemetry.Context.User.Id = string.Empty;
requestTelemetry.Context.User.Id = string.Empty;
var eventTelemetrySamplingScoreWithUserId = SamplingScoreGenerator.GetSamplingScore(eventTelemetry);
var requestTelemetrySamplingScoreWithUserId = SamplingScoreGenerator.GetSamplingScore(requestTelemetry);

Assert.AreEqual(eventTelemetrySamplingScoreNoUserId, eventTelemetrySamplingScoreWithUserId);
Assert.AreEqual(requestTelemetrySamplingScoreNoUserId, requestTelemetrySamplingScoreWithUserId);
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ public static double GetSamplingScore(ITelemetry telemetry)
{
double samplingScore = 0;

if (telemetry.Context.User.Id != null)
{
samplingScore = (double)telemetry.Context.User.Id.GetSamplingHashCode() / int.MaxValue;
}
else if (telemetry.Context.Operation.Id != null)
if (telemetry.Context.Operation.Id != null)
{
samplingScore = (double)telemetry.Context.Operation.Id.GetSamplingHashCode() / int.MaxValue;
}
Expand Down