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

Bug: Sampling Include & Exclude #1166

Closed
TimothyMothra opened this issue Jul 10, 2019 · 0 comments
Closed

Bug: Sampling Include & Exclude #1166

TimothyMothra opened this issue Jul 10, 2019 · 0 comments
Milestone

Comments

@TimothyMothra
Copy link
Member

Problem

When configuring Sampling, we allow users to set both the Include and Exclude properties.
This is a logical fallacy because this is a binary decision. An item cannot be both included and excluded.

In our current implementation, the Excluded types will always win over the Included types.
(we actually have a test to guarantee this behavior).

Exclude:

set
{
this.excludedTypesString = value;
this.excludedTypesFlags = this.PopulateSamplingFlagsFromTheInput(value);
}

Include:

set
{
this.includedTypesString = value;
this.includedTypesFlags = this.PopulateSamplingFlagsFromTheInput(value);
}

Evaluation:

private bool IsSamplingApplicable(SamplingTelemetryItemTypes telemetryItemTypeFlag)
{
if (this.excludedTypesFlags.HasFlag(telemetryItemTypeFlag))
{
return false;
}
if (this.includedTypesFlags != SamplingTelemetryItemTypes.None && !this.includedTypesFlags.HasFlag(telemetryItemTypeFlag))
{
return false;
}
return true;
}
}

Test:

[TestMethod]
public void IncludedDoNotOverrideExcludedFromSampling()
{
TelemetryTypeDoesNotSupportSampling(
telemetryProcessors =>
{
telemetryProcessors.Process(new PageViewTelemetry());
telemetryProcessors.Process(new RequestTelemetry());
return 2;
},
"pageview;request",
"exception;request");
}

Proposal

I want to simplify our internal types and codify the assumptions we're making in our evaluation method.

  • Store only one list of includedTypes
  • If a user sets Include or Exclude, no change. (This is correct.)
  • If a user sets both Include and Exclude in their config (This is incorrect.)
    • Setting Exclude will always take priority over Include (no change to behavior).
    • New: emit a new event source warning: "Configuration Error: Exclude will take precedence over Include.".
@TimothyMothra TimothyMothra added this to the 2.11 milestone Jul 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant