@@ -585,7 +585,12 @@ public IList<SubstringOrRegexPattern> FailedRequestTargets {
585585 /// Indicates whether tracing is enabled, via any combination of
586586 /// <see cref="EnableTracing"/>, <see cref="TracesSampleRate"/>, or <see cref="TracesSampler"/>.
587587 /// </summary>
588- internal bool IsTracingEnabled => EnableTracing ?? ( _tracesSampleRate > 0.0 || TracesSampler is not null ) ;
588+ internal bool IsTracingEnabled => EnableTracing switch
589+ {
590+ false => false ,
591+ null => TracesSampler is not null || TracesSampleRate is > 0.0 ,
592+ true => TracesSampler is not null || TracesSampleRate is > 0.0 or null
593+ } ;
589594
590595 /// <summary>
591596 /// Simplified option for enabling or disabling tracing.
@@ -622,25 +627,43 @@ public IList<SubstringOrRegexPattern> FailedRequestTargets {
622627
623628 /// <summary>
624629 /// Indicates the percentage of the tracing data that is collected.
625- /// Setting this to <c>0.0</c> discards all trace data.
626- /// Setting this to <c>1.0</c> collects all trace data.
627- /// Values outside of this range are invalid.
628- /// The default value is either <c>0.0</c> or <c>1.0</c>, depending on the <see cref="EnableTracing"/> property.
630+ /// <list type="table">
631+ /// <listheader>
632+ /// <term>Value</term>
633+ /// <description>Effect</description>
634+ /// </listheader>
635+ /// <item>
636+ /// <term><c>>= 0.0 and <=1.0</c></term>
637+ /// <description>
638+ /// A custom sample rate is used unless <see cref="EnableTracing"/> is <c>false</c>,
639+ /// or unless overriden by a <see cref="TracesSampler"/> function.
640+ /// Values outside of this range are invalid.
641+ /// </description>
642+ /// </item>
643+ /// <item>
644+ /// <term><c>null</c></term>
645+ /// <description>
646+ /// <b>The default setting.</b>
647+ /// The tracing sample rate is determined by the <see cref="EnableTracing"/> property,
648+ /// unless overriden by a <see cref="TracesSampler"/> function.
649+ /// </description>
650+ /// </item>
651+ /// </list>
629652 /// </summary>
630653 /// <remarks>
631654 /// Random sampling rate is only applied to transactions that don't already
632655 /// have a sampling decision set by other means, such as through <see cref="TracesSampler"/>,
633656 /// by inheriting it from an incoming trace header, or by copying it from <see cref="TransactionContext"/>.
634657 /// </remarks>
635- public double TracesSampleRate
658+ public double ? TracesSampleRate
636659 {
637- get => _tracesSampleRate ?? ( EnableTracing is true ? 1.0 : 0.0 ) ;
660+ get => _tracesSampleRate ;
638661 set
639662 {
640663 if ( value is < 0.0 or > 1.0 )
641664 {
642- throw new InvalidOperationException (
643- $ "The value { value } is not a valid tracing sample rate. Use values between 0.0 and 1.0.") ;
665+ throw new ArgumentOutOfRangeException ( nameof ( value ) , value ,
666+ "The traces sample rate must be between 0.0 and 1.0, inclusive ." ) ;
644667 }
645668
646669 _tracesSampleRate = value ;
0 commit comments