Renaming ParentOrElse to ParentBased (#1173)

* Renaming ParentOrElse to ParentBased

* updating changelog

* updating changelog
This commit is contained in:
Eddy Nakamura 2020-08-26 14:52:35 -03:00 committed by GitHub
parent 12596ce7c2
commit 32fb7c12f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 18 deletions

View File

@ -34,6 +34,8 @@
[#1127](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1127)
[#1129](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1129)
[#1135](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1135))
* Renamed `ParentOrElseSampler` to `ParentBasedSampler`
([#1173](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1173))
## 0.4.0-beta.2

View File

@ -1,4 +1,4 @@
// <copyright file="ParentOrElseSampler.cs" company="OpenTelemetry Authors">
// <copyright file="ParentBasedSampler.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
@ -22,19 +22,19 @@ namespace OpenTelemetry.Trace
/// Sampler implementation which will take a sample if parent Activity or any linked Activity is sampled.
/// Otherwise, samples root traces according to the specified delegate sampler.
/// </summary>
public sealed class ParentOrElseSampler : Sampler
public sealed class ParentBasedSampler : Sampler
{
private readonly Sampler delegateSampler;
/// <summary>
/// Initializes a new instance of the <see cref="ParentOrElseSampler"/> class.
/// Initializes a new instance of the <see cref="ParentBasedSampler"/> class.
/// </summary>
/// <param name="delegateSampler">The <see cref="Sampler"/> to be called to decide whether or not to sample a root trace.</param>
public ParentOrElseSampler(Sampler delegateSampler)
public ParentBasedSampler(Sampler delegateSampler)
{
this.delegateSampler = delegateSampler ?? throw new ArgumentNullException(nameof(delegateSampler));
this.Description = $"ParentOrElse{{{delegateSampler.Description}}}";
this.Description = $"ParentBased{{{delegateSampler.Description}}}";
}
/// <inheritdoc />

View File

@ -28,7 +28,7 @@ namespace OpenTelemetry.Trace
private readonly List<ActivityProcessor> processors = new List<ActivityProcessor>();
private readonly List<string> sources = new List<string>();
private Resource resource = Resource.Empty;
private Sampler sampler = new ParentOrElseSampler(new AlwaysOnSampler());
private Sampler sampler = new ParentBasedSampler(new AlwaysOnSampler());
internal TracerProviderBuilder()
{

View File

@ -1,4 +1,4 @@
// <copyright file="ParentOrElseSamplerTests.cs" company="OpenTelemetry Authors">
// <copyright file="ParentBasedSamplerTests.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
@ -18,28 +18,28 @@ using Xunit;
namespace OpenTelemetry.Trace.Tests
{
public class ParentOrElseSamplerTests
public class ParentBasedSamplerTests
{
private readonly ParentOrElseSampler parentOrElseAlwaysOnSampler = new ParentOrElseSampler(new AlwaysOnSampler());
private readonly ParentOrElseSampler parentOrElseAlwaysOffSampler = new ParentOrElseSampler(new AlwaysOffSampler());
private readonly ParentBasedSampler parentBasedOnSampler = new ParentBasedSampler(new AlwaysOnSampler());
private readonly ParentBasedSampler parentBasedOffSampler = new ParentBasedSampler(new AlwaysOffSampler());
[Fact]
public void ParentOrElseSampler_SampledParent()
public void SampledParent()
{
// No parent, use delegate sampler.
Assert.Equal(
new SamplingResult(SamplingDecision.RecordAndSampled),
this.parentOrElseAlwaysOnSampler.ShouldSample(default));
this.parentBasedOnSampler.ShouldSample(default));
// No parent, use delegate sampler.
Assert.Equal(
new SamplingResult(SamplingDecision.NotRecord),
this.parentOrElseAlwaysOffSampler.ShouldSample(default));
this.parentBasedOffSampler.ShouldSample(default));
// Not sampled parent, don't sample.
Assert.Equal(
new SamplingResult(SamplingDecision.NotRecord),
this.parentOrElseAlwaysOnSampler.ShouldSample(
this.parentBasedOnSampler.ShouldSample(
new SamplingParameters(
parentContext: new ActivityContext(
ActivityTraceId.CreateRandom(),
@ -52,7 +52,7 @@ namespace OpenTelemetry.Trace.Tests
// Sampled parent, sample.
Assert.Equal(
new SamplingResult(SamplingDecision.RecordAndSampled),
this.parentOrElseAlwaysOffSampler.ShouldSample(
this.parentBasedOffSampler.ShouldSample(
new SamplingParameters(
parentContext: new ActivityContext(
ActivityTraceId.CreateRandom(),
@ -64,7 +64,7 @@ namespace OpenTelemetry.Trace.Tests
}
[Fact]
public void ParentOrElseSampler_SampledParentLink()
public void SampledParentLink()
{
var notSampledLink = new ActivityLink[]
{
@ -92,7 +92,7 @@ namespace OpenTelemetry.Trace.Tests
// Not sampled link, don't sample.
Assert.Equal(
new SamplingResult(SamplingDecision.NotRecord),
this.parentOrElseAlwaysOnSampler.ShouldSample(
this.parentBasedOnSampler.ShouldSample(
new SamplingParameters(
parentContext: notSampledParent,
traceId: default,
@ -103,7 +103,7 @@ namespace OpenTelemetry.Trace.Tests
// Sampled link, sample.
Assert.Equal(
new SamplingResult(SamplingDecision.RecordAndSampled),
this.parentOrElseAlwaysOffSampler.ShouldSample(
this.parentBasedOffSampler.ShouldSample(
new SamplingParameters(
parentContext: notSampledParent,
traceId: default,