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

[AzureMonitor] Change drop sampling result to recordOnly #933

Merged
Show file tree
Hide file tree
Changes from 6 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
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace OpenTelemetry.Extensions.AzureMonitor;
/// </summary>
public class ApplicationInsightsSampler : Sampler
{
private static readonly SamplingResult DropSamplingResult = new(false);
private static readonly SamplingResult RecordOnlySamplingResult = new(SamplingDecision.RecordOnly);
private readonly SamplingResult recordAndSampleSamplingResult;
private readonly float samplingRatio;

Expand Down Expand Up @@ -63,7 +63,7 @@ public override SamplingResult ShouldSample(in SamplingParameters samplingParame
{
if (this.samplingRatio == 0)
{
return DropSamplingResult;
return RecordOnlySamplingResult;
}

if (this.samplingRatio == 1)
Expand All @@ -79,7 +79,7 @@ public override SamplingResult ShouldSample(in SamplingParameters samplingParame
}
else
{
return DropSamplingResult;
return RecordOnlySamplingResult;
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/OpenTelemetry.Extensions.AzureMonitor/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

* Sampler will now return `RecordOnly` SamplingResult when the telemetry is
sampled out.
([#933](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/933))

## 1.0.0-beta.2

Released 2022-Sept-12
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public void VerifyHashAlgorithmCorrectness()

// Verify sample ratio: 0
ApplicationInsightsSampler zeroSampler = new ApplicationInsightsSampler(samplingRatio: 0);
Assert.Equal(SamplingDecision.Drop, zeroSampler.ShouldSample(testParams1).Decision);
Assert.Equal(SamplingDecision.Drop, zeroSampler.ShouldSample(testParams2).Decision);
Assert.Equal(SamplingDecision.RecordOnly, zeroSampler.ShouldSample(testParams1).Decision);
Assert.Equal(SamplingDecision.RecordOnly, zeroSampler.ShouldSample(testParams2).Decision);

// Verify sample ratio: 1
ApplicationInsightsSampler oneSampler = new ApplicationInsightsSampler(samplingRatio: 1);
Expand All @@ -61,7 +61,7 @@ public void VerifyHashAlgorithmCorrectness()
// Verify sample ratio: 0.5.
// This is below the sample score for testId2, but strict enough to drop testId1
ApplicationInsightsSampler ratioSampler = new ApplicationInsightsSampler(samplingRatio: 0.5f);
Assert.Equal(SamplingDecision.Drop, ratioSampler.ShouldSample(testParams1).Decision);
Assert.Equal(SamplingDecision.RecordOnly, ratioSampler.ShouldSample(testParams1).Decision);
Assert.Equal(SamplingDecision.RecordAndSample, ratioSampler.ShouldSample(testParams2).Decision);
}

Expand Down