Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Removed SentryOptins.EnableTracing
  • Loading branch information
jamescrosswell committed Aug 27, 2024
commit efccab4ebe4bf18ca4d1b62eefb4183235c3424c
3 changes: 0 additions & 3 deletions src/Sentry/BindableSentryOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ public void ApplyTo(SentryOptions options)
options.FailedRequestTargets = FailedRequestTargets?.Select(s => new SubstringOrRegexPattern(s)).ToList() ?? options.FailedRequestTargets;
options.InitCacheFlushTimeout = InitCacheFlushTimeout ?? options.InitCacheFlushTimeout;
options.DefaultTags = DefaultTags ?? options.DefaultTags;
#pragma warning disable CS0618 // Type or member is obsolete
options.EnableTracing = EnableTracing ?? options.EnableTracing;
#pragma warning restore CS0618 // Type or member is obsolete
options.TracesSampleRate = TracesSampleRate ?? options.TracesSampleRate;
options.ProfilesSampleRate = ProfilesSampleRate ?? options.ProfilesSampleRate;
options.TracePropagationTargets = TracePropagationTargets?.Select(s => new SubstringOrRegexPattern(s)).ToList() ?? options.TracePropagationTargets;
Expand Down
8 changes: 2 additions & 6 deletions src/Sentry/Internal/Hub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,7 @@ internal ITransactionTracer StartTransaction(
// Additionally, we will always sample out if tracing is explicitly disabled.
// Do not invoke the TracesSampler, evaluate the TracesSampleRate, and override any sampling decision
// that may have been already set (i.e.: from a sentry-trace header).
#pragma warning disable CS0618 // Type or member is obsolete
if (!IsEnabled || _options.EnableTracing is false)
#pragma warning restore CS0618 // Type or member is obsolete
if (!IsEnabled)
{
transaction.IsSampled = false;
transaction.SampleRate = 0.0;
Expand All @@ -156,9 +154,7 @@ internal ITransactionTracer StartTransaction(
// Random sampling runs only if the sampling decision hasn't been made already.
if (transaction.IsSampled == null)
{
#pragma warning disable CS0618 // Type or member is obsolete
var sampleRate = _options.TracesSampleRate ?? (_options.EnableTracing is true ? 1.0 : 0.0);
#pragma warning restore CS0618 // Type or member is obsolete
var sampleRate = _options.TracesSampleRate ?? 0.0;
transaction.IsSampled = _randomValuesFactory.NextBool(sampleRate);
transaction.SampleRate = sampleRate;
}
Expand Down
4 changes: 1 addition & 3 deletions src/Sentry/Platforms/Android/SentrySdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ private static void InitSentryAndroidSdk(SentryOptions options)
// These options we have behind feature flags
if (options is { IsPerformanceMonitoringEnabled: true, Native.EnableTracing: true })
{
#pragma warning disable CS0618 // Type or member is obsolete
o.EnableTracing = (JavaBoolean?)options.EnableTracing;
#pragma warning restore CS0618 // Type or member is obsolete
o.EnableTracing = null;
o.TracesSampleRate = (JavaDouble?)options.TracesSampleRate;

if (options.TracesSampler is { } tracesSampler)
Expand Down
7 changes: 0 additions & 7 deletions src/Sentry/Platforms/Cocoa/SentrySdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,6 @@ private static void InitSentryCocoaSdk(SentryOptions options)
// These options we have behind feature flags
if (options is { IsPerformanceMonitoringEnabled: true, Native.EnableTracing: true })
{
#pragma warning disable CS0618 // Type or member is obsolete
if (options.EnableTracing != null)
{
nativeOptions.EnableTracing = options.EnableTracing.Value;
}
#pragma warning restore CS0618 // Type or member is obsolete

nativeOptions.TracesSampleRate = options.TracesSampleRate;

if (options.TracesSampler is { } tracesSampler)
Expand Down
54 changes: 6 additions & 48 deletions src/Sentry/SentryOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -753,56 +753,16 @@ public Dictionary<string, string> DefaultTags
}

/// <summary>
/// Indicates whether the performance feature is enabled, via any combination of
/// <see cref="EnableTracing"/>, <see cref="TracesSampleRate"/>, or <see cref="TracesSampler"/>.
/// Indicates whether the performance feature is enabled, via either <see cref="TracesSampleRate"/>
/// or <see cref="TracesSampler"/>.
/// </summary>
#pragma warning disable CS0618 // Type or member is obsolete
internal bool IsPerformanceMonitoringEnabled => EnableTracing switch
{
false => false,
null => TracesSampler is not null || TracesSampleRate is > 0.0,
true => TracesSampler is not null || TracesSampleRate is > 0.0 or null
};
#pragma warning restore CS0618 // Type or member is obsolete
internal bool IsPerformanceMonitoringEnabled => TracesSampler is not null || TracesSampleRate is > 0.0;

/// <summary>
/// Indicates whether profiling is enabled, via any combination of
/// <see cref="EnableTracing"/>, <see cref="TracesSampleRate"/>, or <see cref="TracesSampler"/>.
/// Indicates whether profiling is enabled, via <see cref="TracesSampleRate"/>, or <see cref="TracesSampler"/>
/// </summary>
internal bool IsProfilingEnabled => IsPerformanceMonitoringEnabled && ProfilesSampleRate > 0.0;

/// <summary>
/// Simplified option for enabling or disabling tracing.
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <description>Effect</description>
/// </listheader>
/// <item>
/// <term><c>true</c></term>
/// <description>
/// Tracing is enabled. <see cref="TracesSampleRate"/> or <see cref="TracesSampler"/> will be used if set,
/// or 100% sample rate will be used otherwise.
/// </description>
/// </item>
/// <item>
/// <term><c>false</c></term>
/// <description>
/// Tracing is disabled, regardless of <see cref="TracesSampleRate"/> or <see cref="TracesSampler"/>.
/// </description>
/// </item>
/// <item>
/// <term><c>null</c></term>
/// <description>
/// <b>The default setting.</b>
/// Tracing is enabled only if <see cref="TracesSampleRate"/> or <see cref="TracesSampler"/> are set.
/// </description>
/// </item>
/// </list>
/// </summary>
[Obsolete("Use TracesSampleRate or TracesSampler instead")]
public bool? EnableTracing { get; set; }

private double? _tracesSampleRate;

/// <summary>
Expand All @@ -815,17 +775,15 @@ public Dictionary<string, string> DefaultTags
/// <item>
/// <term><c>&gt;= 0.0 and &lt;=1.0</c></term>
/// <description>
/// A custom sample rate is used unless <see cref="EnableTracing"/> is <c>false</c>,
/// or unless overriden by a <see cref="TracesSampler"/> function.
/// A custom sample rate is used unless overriden by a <see cref="TracesSampler"/> function.
/// Values outside of this range are invalid.
/// </description>
/// </item>
/// <item>
/// <term><c>null</c></term>
/// <description>
/// <b>The default setting.</b>
/// The tracing sample rate is determined by the <see cref="EnableTracing"/> property,
/// unless overriden by a <see cref="TracesSampler"/> function.
/// The tracing sample rate is determined by the <see cref="TracesSampler"/> function.
/// </description>
/// </item>
/// </list>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ public void Configure_BindsConfigurationToOptions()
FailedRequestTargets = new List<SubstringOrRegexPattern> { "target1", "target2" },
InitCacheFlushTimeout = TimeSpan.FromSeconds(27),
// DefaultTags = Dictionary<string,string>,
#pragma warning disable CS0618 // Type or member is obsolete
EnableTracing = true,
#pragma warning restore CS0618 // Type or member is obsolete
TracesSampleRate = 0.8f,
TracePropagationTargets = new List<SubstringOrRegexPattern> { "target3", "target4" },
StackTraceMode = StackTraceMode.Enhanced,
Expand Down Expand Up @@ -96,9 +93,6 @@ public void Configure_BindsConfigurationToOptions()
["FailedRequestTargets:1"] = expected.FailedRequestTargets.Last().ToString(),
["InitCacheFlushTimeout"] = expected.InitCacheFlushTimeout.ToString(),
["DefaultTags"] = expected.DefaultTags.ToString(),
#pragma warning disable CS0618 // Type or member is obsolete
["EnableTracing"] = expected.EnableTracing.ToString(),
#pragma warning restore CS0618 // Type or member is obsolete
["TracesSampleRate"] = expected.TracesSampleRate.Value.ToString(CultureInfo.InvariantCulture),
["TracePropagationTargets:0"] = expected.TracePropagationTargets.First().ToString(),
["TracePropagationTargets:1"] = expected.TracePropagationTargets.Last().ToString(),
Expand Down Expand Up @@ -156,9 +150,6 @@ public void Configure_BindsConfigurationToOptions()
actual.CaptureFailedRequests.Should().Be(expected.CaptureFailedRequests);
actual.FailedRequestTargets.Should().BeEquivalentTo(expected.FailedRequestTargets);
actual.InitCacheFlushTimeout.Should().Be(expected.InitCacheFlushTimeout);
#pragma warning disable CS0618 // Type or member is obsolete
actual.EnableTracing.Should().Be(expected.EnableTracing);
#pragma warning restore CS0618 // Type or member is obsolete
actual.TracesSampleRate.Should().Be(expected.TracesSampleRate);
actual.TracePropagationTargets.Should().BeEquivalentTo(expected.TracePropagationTargets);
actual.StackTraceMode.Should().Be(expected.StackTraceMode);
Expand Down
2 changes: 0 additions & 2 deletions test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,6 @@ namespace Sentry
public string? Dsn { get; set; }
public bool EnableScopeSync { get; set; }
public bool EnableSpotlight { get; set; }
[System.Obsolete("Use TracesSampleRate or TracesSampler instead")]
public bool? EnableTracing { get; set; }
public string? Environment { get; set; }
public Sentry.ExperimentalMetricsOptions? ExperimentalMetrics { get; set; }
public System.Collections.Generic.IList<Sentry.HttpStatusCodeRange> FailedRequestStatusCodes { get; set; }
Expand Down
2 changes: 0 additions & 2 deletions test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,6 @@ namespace Sentry
public string? Dsn { get; set; }
public bool EnableScopeSync { get; set; }
public bool EnableSpotlight { get; set; }
[System.Obsolete("Use TracesSampleRate or TracesSampler instead")]
public bool? EnableTracing { get; set; }
public string? Environment { get; set; }
public Sentry.ExperimentalMetricsOptions? ExperimentalMetrics { get; set; }
public System.Collections.Generic.IList<Sentry.HttpStatusCodeRange> FailedRequestStatusCodes { get; set; }
Expand Down
2 changes: 0 additions & 2 deletions test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -669,8 +669,6 @@ namespace Sentry
public string? Dsn { get; set; }
public bool EnableScopeSync { get; set; }
public bool EnableSpotlight { get; set; }
[System.Obsolete("Use TracesSampleRate or TracesSampler instead")]
public bool? EnableTracing { get; set; }
public string? Environment { get; set; }
public Sentry.ExperimentalMetricsOptions? ExperimentalMetrics { get; set; }
public System.Collections.Generic.IList<Sentry.HttpStatusCodeRange> FailedRequestStatusCodes { get; set; }
Expand Down
2 changes: 0 additions & 2 deletions test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,6 @@ namespace Sentry
public string? Dsn { get; set; }
public bool EnableScopeSync { get; set; }
public bool EnableSpotlight { get; set; }
[System.Obsolete("Use TracesSampleRate or TracesSampler instead")]
public bool? EnableTracing { get; set; }
public string? Environment { get; set; }
public Sentry.ExperimentalMetricsOptions? ExperimentalMetrics { get; set; }
public System.Collections.Generic.IList<Sentry.HttpStatusCodeRange> FailedRequestStatusCodes { get; set; }
Expand Down
34 changes: 0 additions & 34 deletions test/Sentry.Tests/HubTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -601,23 +601,6 @@ public void StartTransaction_EnableTracing_SampledIn()
transaction.IsSampled.Should().BeTrue();
}

[Fact]
public void StartTransaction_DisableTracing_SampledOut()
{
// Arrange
_fixture.Options.TracesSampleRate = 1.0;
#pragma warning disable CS0618 // Type or member is obsolete
_fixture.Options.EnableTracing = false;
#pragma warning restore CS0618 // Type or member is obsolete
var hub = _fixture.GetSut();

// Act
var transaction = hub.StartTransaction("name", "operation");

// Assert
transaction.IsSampled.Should().BeFalse();
}

[Fact]
public void StartTransaction_SameInstrumenter_SampledIn()
{
Expand Down Expand Up @@ -673,23 +656,6 @@ public void StartTransaction_EnableTracing_Sampler_SampledIn()
transaction.IsSampled.Should().BeTrue();
}

[Fact]
public void StartTransaction_DisableTracing_Sampler_SampledOut()
{
// Arrange
_fixture.Options.TracesSampler = _ => 1.0;
#pragma warning disable CS0618 // Type or member is obsolete
_fixture.Options.EnableTracing = false;
#pragma warning restore CS0618 // Type or member is obsolete
var hub = _fixture.GetSut();

// Act
var transaction = hub.StartTransaction("name", "operation");

// Assert
transaction.IsSampled.Should().BeFalse();
}

[Theory]
[InlineData(0.25f)]
[InlineData(0.50f)]
Expand Down
114 changes: 0 additions & 114 deletions test/Sentry.Tests/SentryOptionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,6 @@ public void AttachStackTrace_ByDefault_True()
Assert.True(sut.AttachStacktrace);
}

[Fact]
public void EnableTracing_Default_Null()
{
var sut = new SentryOptions();
#pragma warning disable CS0618 // Type or member is obsolete
Assert.Null(sut.EnableTracing);
#pragma warning restore CS0618 // Type or member is obsolete
}

[Fact]
public void TracesSampleRate_Default_Null()
{
Expand All @@ -62,32 +53,6 @@ public void IsPerformanceMonitoringEnabled_Default_False()
Assert.False(sut.IsPerformanceMonitoringEnabled);
}

[Fact]
public void IsPerformanceMonitoringEnabled_EnableTracing_True()
{
var sut = new SentryOptions
{
#pragma warning disable CS0618 // Type or member is obsolete
EnableTracing = true
#pragma warning restore CS0618 // Type or member is obsolete
};

Assert.True(sut.IsPerformanceMonitoringEnabled);
}

[Fact]
public void IsPerformanceMonitoringEnabled_EnableTracing_False()
{
var sut = new SentryOptions
{
#pragma warning disable CS0618 // Type or member is obsolete
EnableTracing = false
#pragma warning restore CS0618 // Type or member is obsolete
};

Assert.False(sut.IsPerformanceMonitoringEnabled);
}

[Fact]
public void IsPerformanceMonitoringEnabled_TracesSampleRate_Zero()
{
Expand Down Expand Up @@ -137,57 +102,6 @@ public void IsPerformanceMonitoringEnabled_TracesSampler_Provided()
Assert.True(sut.IsPerformanceMonitoringEnabled);
}

[Fact]
public void IsPerformanceMonitoringEnabled_EnableTracing_True_TracesSampleRate_Zero()
{
// Edge Case:
// Tracing enabled, but sample rate set to zero, and no sampler function, should be treated as disabled.

var sut = new SentryOptions
{
#pragma warning disable CS0618 // Type or member is obsolete
EnableTracing = true,
#pragma warning restore CS0618 // Type or member is obsolete
TracesSampleRate = 0.0
};

Assert.False(sut.IsPerformanceMonitoringEnabled);
}

[Fact]
public void IsPerformanceMonitoringEnabled_EnableTracing_False_TracesSampleRate_One()
{
// Edge Case:
// Tracing disabled should be treated as disabled regardless of sample rate set.

var sut = new SentryOptions
{
#pragma warning disable CS0618 // Type or member is obsolete
EnableTracing = false,
#pragma warning restore CS0618 // Type or member is obsolete
TracesSampleRate = 1.0
};

Assert.False(sut.IsPerformanceMonitoringEnabled);
}

[Fact]
public void IsPerformanceMonitoringEnabled_EnableTracing_False_TracesSampler_Provided()
{
// Edge Case:
// Tracing disabled should be treated as disabled regardless of sampler function set.

var sut = new SentryOptions
{
#pragma warning disable CS0618 // Type or member is obsolete
EnableTracing = false,
#pragma warning restore CS0618 // Type or member is obsolete
TracesSampler = _ => null
};

Assert.False(sut.IsPerformanceMonitoringEnabled);
}

[Fact]
public void ProfilesSampleRate_Default_Null()
{
Expand All @@ -202,34 +116,6 @@ public void IsProfilingEnabled_Default_False()
Assert.False(sut.IsProfilingEnabled);
}

[Fact]
public void IsProfilingEnabled_EnableTracing_True()
{
var sut = new SentryOptions
{
#pragma warning disable CS0618 // Type or member is obsolete
EnableTracing = true,
#pragma warning restore CS0618 // Type or member is obsolete
ProfilesSampleRate = double.Epsilon
};

Assert.True(sut.IsProfilingEnabled);
}

[Fact]
public void IsProfilingEnabled_EnableTracing_False()
{
var sut = new SentryOptions
{
#pragma warning disable CS0618 // Type or member is obsolete
EnableTracing = false,
#pragma warning restore CS0618 // Type or member is obsolete
ProfilesSampleRate = double.Epsilon
};

Assert.False(sut.IsProfilingEnabled);
}

[Fact]
public void IsProfilingEnabled_TracesSampleRate_Zero()
{
Expand Down