-
Notifications
You must be signed in to change notification settings - Fork 147
/
Copy pathTracerSettings.cs
1460 lines (1215 loc) · 70.4 KB
/
TracerSettings.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// <copyright file="TracerSettings.cs" company="Datadog">
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc.
// </copyright>
#nullable enable
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Datadog.Trace.Ci;
using Datadog.Trace.Ci.CiEnvironment;
using Datadog.Trace.ClrProfiler;
using Datadog.Trace.ClrProfiler.ServerlessInstrumentation;
using Datadog.Trace.Configuration.ConfigurationSources.Telemetry;
using Datadog.Trace.Configuration.Telemetry;
using Datadog.Trace.Logging;
using Datadog.Trace.Logging.DirectSubmission;
using Datadog.Trace.Processors;
using Datadog.Trace.Propagators;
using Datadog.Trace.Sampling;
using Datadog.Trace.SourceGenerators;
using Datadog.Trace.Tagging;
using Datadog.Trace.Telemetry;
using Datadog.Trace.Telemetry.Metrics;
using Datadog.Trace.Util;
namespace Datadog.Trace.Configuration
{
/// <summary>
/// Contains Tracer settings.
/// </summary>
public record TracerSettings
{
private static readonly IDatadogLogger Log = DatadogLogging.GetLoggerFor<TracerSettings>();
private readonly IConfigurationTelemetry _telemetry;
// we cached the static instance here, because is being used in the hotpath
// by IsIntegrationEnabled method (called from all integrations)
private readonly DomainMetadata _domainMetadata = DomainMetadata.Instance;
// These values can all be overwritten by dynamic config
private readonly bool _traceEnabled;
private readonly bool _appsecStandaloneEnabled;
private readonly bool _isDataStreamsMonitoringEnabled;
private readonly ReadOnlyDictionary<string, string> _headerTags;
private readonly ReadOnlyDictionary<string, string> _serviceNameMappings;
private readonly ReadOnlyDictionary<string, string> _globalTags;
private readonly double? _globalSamplingRate;
private readonly bool _runtimeMetricsEnabled;
private readonly string? _customSamplingRules;
/// <summary>
/// Initializes a new instance of the <see cref="TracerSettings"/> class with default values.
/// </summary>
[PublicApi]
public TracerSettings()
: this(null, new ConfigurationTelemetry(), new OverrideErrorLog())
{
TelemetryFactory.Metrics.Record(PublicApiUsage.TracerSettings_Ctor);
}
/// <summary>
/// Initializes a new instance of the <see cref="TracerSettings"/> class
/// using the specified <see cref="IConfigurationSource"/> to initialize values.
/// </summary>
/// <param name="source">The <see cref="IConfigurationSource"/> to use when retrieving configuration values.</param>
/// <remarks>
/// We deliberately don't use the static <see cref="TelemetryFactory.Config"/> collector here
/// as we don't want to automatically record these values, only once they're "activated",
/// in <see cref="Tracer.Configure(TracerSettings)"/>
/// </remarks>
[PublicApi]
public TracerSettings(IConfigurationSource? source)
: this(source, new ConfigurationTelemetry(), new OverrideErrorLog())
{
TelemetryFactory.Metrics.Record(PublicApiUsage.TracerSettings_Ctor_Source);
}
/// <summary>
/// Initializes a new instance of the <see cref="TracerSettings"/> class.
/// The "main" constructor for <see cref="TracerSettings"/> that should be used internally in the library.
/// </summary>
/// <param name="source">The configuration source. If <c>null</c> is provided, uses <see cref="NullConfigurationSource"/> </param>
/// <param name="telemetry">The telemetry collection instance. Typically you should create a new <see cref="ConfigurationTelemetry"/> </param>
/// <param name="errorLog">Used to record cases where telemetry is overridden </param>
internal TracerSettings(IConfigurationSource? source, IConfigurationTelemetry telemetry, OverrideErrorLog errorLog)
{
var commaSeparator = new[] { ',' };
source ??= NullConfigurationSource.Instance;
_telemetry = telemetry;
ErrorLog = errorLog;
var config = new ConfigurationBuilder(source, _telemetry);
GCPFunctionSettings = new ImmutableGCPFunctionSettings(source, _telemetry);
IsRunningInGCPFunctions = GCPFunctionSettings.IsGCPFunction;
// We don't want/need to record this value, so explicitly use null telemetry
var isRunningInCiVisibility = new ConfigurationBuilder(source, NullConfigurationTelemetry.Instance)
.WithKeys(ConfigurationKeys.CIVisibility.IsRunningInCiVisMode)
.AsBool(false);
LambdaMetadata = LambdaMetadata.Create();
IsRunningInAzureAppService = ImmutableAzureAppServiceSettings.GetIsAzureAppService(source, telemetry);
IsRunningMiniAgentInAzureFunctions = ImmutableAzureAppServiceSettings.GetIsFunctionsAppUsingMiniAgent(source, telemetry);
if (IsRunningInAzureAppService)
{
AzureAppServiceMetadata = new ImmutableAzureAppServiceSettings(source, _telemetry);
}
// With SSI, beyond ContinuousProfiler.ConfigurationKeys.ProfilingEnabled (true or auto vs false),
// the profiler could be enabled via ContinuousProfiler.ConfigurationKeys.SsiDeployed:
// - if it contains "profiler", the profiler is enabled after 30 seconds + at least 1 span
// - if not, the profiler needed to be loaded by the CLR but no profiling will be done, only telemetry metrics will be sent
// So, for the Tracer, the profiler should be seen as enabled if ContinuousProfiler.ConfigurationKeys.SsiDeployed has a value
// (even without "profiler") so that spans will be sent to the profiler.
ProfilingEnabledInternal = config
.WithKeys(ContinuousProfiler.ConfigurationKeys.ProfilingEnabled)
.GetAs(
converter: x => x switch
{
"auto" => true,
_ when x.ToBoolean() is { } boolean => boolean,
_ => ParsingResult<bool>.Failure(),
},
getDefaultValue: () =>
{
var profilingSsiDeployed = config.WithKeys(ContinuousProfiler.ConfigurationKeys.SsiDeployed).AsString();
return (profilingSsiDeployed != null);
},
validator: null);
var otelTags = config
.WithKeys(ConfigurationKeys.OpenTelemetry.ResourceAttributes)
.AsDictionaryResult(separator: '=');
var globalTags = config
.WithKeys(ConfigurationKeys.GlobalTags, "DD_TRACE_GLOBAL_TAGS")
.AsDictionaryResult()
.OverrideWith(
RemapOtelTags(in otelTags),
ErrorLog,
() => new DefaultResult<IDictionary<string, string>>(new Dictionary<string, string>(), string.Empty))
// Filter out tags with empty keys or empty values, and trim whitespace
.Where(kvp => !string.IsNullOrWhiteSpace(kvp.Key) && !string.IsNullOrWhiteSpace(kvp.Value))
.ToDictionary(kvp => kvp.Key.Trim(), kvp => kvp.Value.Trim());
Environment = config
.WithKeys(ConfigurationKeys.Environment)
.AsString();
// DD_ENV has precedence over DD_TAGS
Environment = GetExplicitSettingOrTag(Environment, globalTags, Tags.Env, ConfigurationKeys.Environment);
var otelServiceName = config.WithKeys(ConfigurationKeys.OpenTelemetry.ServiceName).AsStringResult();
var serviceName = config
.WithKeys(ConfigurationKeys.ServiceName, "DD_SERVICE_NAME")
.AsStringResult()
.OverrideWith(in otelServiceName, ErrorLog);
// DD_SERVICE has precedence over DD_TAGS
serviceName = GetExplicitSettingOrTag(serviceName, globalTags, Tags.Service, ConfigurationKeys.ServiceName);
if (isRunningInCiVisibility)
{
// Set the service name if not set
var isUserProvidedTestServiceTag = true;
var ciVisServiceName = serviceName;
if (string.IsNullOrEmpty(serviceName))
{
// Extract repository name from the git url and use it as a default service name.
ciVisServiceName = CIVisibility.GetServiceNameFromRepository(CIEnvironmentValues.Instance.Repository);
isUserProvidedTestServiceTag = false;
}
globalTags[Ci.Tags.CommonTags.UserProvidedTestServiceTag] = isUserProvidedTestServiceTag ? "true" : "false";
// Normalize the service name
ciVisServiceName = NormalizerTraceProcessor.NormalizeService(ciVisServiceName);
if (ciVisServiceName != serviceName)
{
serviceName = ciVisServiceName;
telemetry.Record(ConfigurationKeys.ServiceName, serviceName, recordValue: true, ConfigurationOrigins.Calculated);
}
}
ServiceName = serviceName;
ServiceVersion = config
.WithKeys(ConfigurationKeys.ServiceVersion)
.AsString();
// DD_VERSION has precedence over DD_TAGS
ServiceVersion = GetExplicitSettingOrTag(ServiceVersion, globalTags, Tags.Version, ConfigurationKeys.ServiceVersion);
GitCommitSha = config
.WithKeys(ConfigurationKeys.GitCommitSha)
.AsString();
// DD_GIT_COMMIT_SHA has precedence over DD_TAGS
GitCommitSha = GetExplicitSettingOrTag(GitCommitSha, globalTags, Ci.Tags.CommonTags.GitCommit, ConfigurationKeys.GitCommitSha);
GitRepositoryUrl = config
.WithKeys(ConfigurationKeys.GitRepositoryUrl)
.AsString();
// DD_GIT_REPOSITORY_URL has precedence over DD_TAGS
GitRepositoryUrl = GetExplicitSettingOrTag(GitRepositoryUrl, globalTags, Ci.Tags.CommonTags.GitCommit, ConfigurationKeys.GitRepositoryUrl);
GitMetadataEnabled = config
.WithKeys(ConfigurationKeys.GitMetadataEnabled)
.AsBool(defaultValue: true);
var otelTraceEnabled = config
.WithKeys(ConfigurationKeys.OpenTelemetry.TracesExporter)
.AsBoolResult(
value => string.Equals(value, "none", StringComparison.OrdinalIgnoreCase)
? ParsingResult<bool>.Success(result: false)
: ParsingResult<bool>.Failure());
_traceEnabled = config
.WithKeys(ConfigurationKeys.TraceEnabled)
.AsBoolResult()
.OverrideWith(in otelTraceEnabled, ErrorLog, defaultValue: true);
_appsecStandaloneEnabled = config
.WithKeys(ConfigurationKeys.AppsecStandaloneEnabled)
.AsBool(defaultValue: false);
if (AzureAppServiceMetadata?.IsUnsafeToTrace == true)
{
telemetry.Record(ConfigurationKeys.TraceEnabled, false, ConfigurationOrigins.Calculated);
_traceEnabled = false;
}
var otelActivityListenerEnabled = config
.WithKeys(ConfigurationKeys.OpenTelemetry.SdkDisabled)
.AsBoolResult(
value => string.Equals(value, "true", StringComparison.OrdinalIgnoreCase)
? ParsingResult<bool>.Success(result: false)
: ParsingResult<bool>.Failure());
IsActivityListenerEnabled = config
.WithKeys(ConfigurationKeys.FeatureFlags.OpenTelemetryEnabled, "DD_TRACE_ACTIVITY_LISTENER_ENABLED")
.AsBoolResult()
.OverrideWith(in otelActivityListenerEnabled, ErrorLog, defaultValue: false);
var disabledIntegrationNames = config.WithKeys(ConfigurationKeys.DisabledIntegrations)
.AsString()
?.Split([';'], StringSplitOptions.RemoveEmptyEntries) ?? [];
// If Activity support is enabled, we shouldn't enable the OTel listener
DisabledIntegrationNames = IsActivityListenerEnabled
? new HashSet<string>(disabledIntegrationNames, StringComparer.OrdinalIgnoreCase)
: new HashSet<string>([..disabledIntegrationNames, nameof(IntegrationId.OpenTelemetry)], StringComparer.OrdinalIgnoreCase);
Integrations = new IntegrationSettingsCollection(source, DisabledIntegrationNames);
RecordDisabledIntegrationsTelemetry(Integrations, Telemetry);
Exporter = new ExporterSettings(source, _telemetry);
#pragma warning disable 618 // App analytics is deprecated, but still used
AnalyticsEnabled = config.WithKeys(ConfigurationKeys.GlobalAnalyticsEnabled)
.AsBool(defaultValue: false);
#pragma warning restore 618
#pragma warning disable 618 // this parameter has been replaced but may still be used
MaxTracesSubmittedPerSecond = config
.WithKeys(ConfigurationKeys.TraceRateLimit, ConfigurationKeys.MaxTracesSubmittedPerSecond)
#pragma warning restore 618
.AsInt32(defaultValue: 100);
// mutate dictionary to remove without "env", "version", "git.commit.sha" or "git.repository.url" tags
// these value are used for "Environment" and "ServiceVersion", "GitCommitSha" and "GitRepositoryUrl" properties
// or overriden with DD_ENV, DD_VERSION, DD_GIT_COMMIT_SHA and DD_GIT_REPOSITORY_URL respectively
globalTags.Remove(Tags.Service);
globalTags.Remove(Tags.Env);
globalTags.Remove(Tags.Version);
globalTags.Remove(Ci.Tags.CommonTags.GitCommit);
globalTags.Remove(Ci.Tags.CommonTags.GitRepository);
_globalTags = new(globalTags);
var headerTagsNormalizationFixEnabled = config
.WithKeys(ConfigurationKeys.FeatureFlags.HeaderTagsNormalizationFixEnabled)
.AsBool(defaultValue: true);
// Filter out tags with empty keys or empty values, and trim whitespaces
_headerTags = InitializeHeaderTags(config, ConfigurationKeys.HeaderTags, headerTagsNormalizationFixEnabled) ?? ReadOnlyDictionary.Empty;
PeerServiceTagsEnabled = config
.WithKeys(ConfigurationKeys.PeerServiceDefaultsEnabled)
.AsBool(defaultValue: false);
RemoveClientServiceNamesEnabled = config
.WithKeys(ConfigurationKeys.RemoveClientServiceNamesEnabled)
.AsBool(defaultValue: false);
PeerServiceNameMappings = InitializeServiceNameMappings(config, ConfigurationKeys.PeerServiceNameMappings);
MetadataSchemaVersion = config
.WithKeys(ConfigurationKeys.MetadataSchemaVersion)
.GetAs(
() => new DefaultResult<SchemaVersion>(SchemaVersion.V0, "V0"),
converter: x => x switch
{
"v1" or "V1" => SchemaVersion.V1,
"v0" or "V0" => SchemaVersion.V0,
_ => ParsingResult<SchemaVersion>.Failure(),
},
validator: null);
_serviceNameMappings = InitializeServiceNameMappings(config, ConfigurationKeys.ServiceNameMappings) ?? ReadOnlyDictionary.Empty;
TracerMetricsEnabled = config
.WithKeys(ConfigurationKeys.TracerMetricsEnabled)
.AsBool(defaultValue: false);
StatsComputationInterval = config.WithKeys(ConfigurationKeys.StatsComputationInterval).AsInt32(defaultValue: 10);
var otelRuntimeMetricsEnabled = config
.WithKeys(ConfigurationKeys.OpenTelemetry.MetricsExporter)
.AsBoolResult(
value => string.Equals(value, "none", StringComparison.OrdinalIgnoreCase)
? ParsingResult<bool>.Success(result: false)
: ParsingResult<bool>.Failure());
_runtimeMetricsEnabled = config
.WithKeys(ConfigurationKeys.RuntimeMetricsEnabled)
.AsBoolResult()
.OverrideWith(in otelRuntimeMetricsEnabled, ErrorLog, defaultValue: false);
// We should also be writing telemetry for OTEL_LOGS_EXPORTER similar to OTEL_METRICS_EXPORTER, but we don't have a corresponding Datadog config
// When we do, we can insert that here
_customSamplingRules = config.WithKeys(ConfigurationKeys.CustomSamplingRules).AsString();
CustomSamplingRulesFormat = config.WithKeys(ConfigurationKeys.CustomSamplingRulesFormat)
.GetAs(
getDefaultValue: () => new DefaultResult<string>(SamplingRulesFormat.Glob, "glob"),
converter: value =>
{
// We intentionally report invalid values as "valid" in the converter,
// because we don't want to automatically fall back to the
// default value.
if (!SamplingRulesFormat.IsValid(value, out var normalizedFormat))
{
Log.Warning(
"{ConfigurationKey} configuration of {ConfigurationValue} is invalid. Ignoring all trace sampling rules.",
ConfigurationKeys.CustomSamplingRulesFormat,
value);
}
return normalizedFormat;
},
validator: null);
// record final value of CustomSamplingRulesFormat in telemetry
_telemetry.Record(
key: ConfigurationKeys.CustomSamplingRulesFormat,
value: CustomSamplingRulesFormat,
recordValue: true,
origin: ConfigurationOrigins.Calculated);
SpanSamplingRules = config.WithKeys(ConfigurationKeys.SpanSamplingRules).AsString();
_globalSamplingRate = BuildSampleRate(ErrorLog, in config);
// We need to record a default value for configuration reporting
// However, we need to keep GlobalSamplingRateInternal null because it changes the behavior of the tracer in subtle ways
// (= we don't run the sampler at all if it's null, so it changes the tagging of the spans, and it's enforced by system tests)
if (GlobalSamplingRate is null)
{
_telemetry.Record(ConfigurationKeys.GlobalSamplingRate, 1.0, ConfigurationOrigins.Default);
}
StartupDiagnosticLogEnabled = config.WithKeys(ConfigurationKeys.StartupDiagnosticLogEnabled).AsBool(defaultValue: true);
var httpServerErrorStatusCodes = config
#pragma warning disable 618 // This config key has been replaced but may still be used
.WithKeys(ConfigurationKeys.HttpServerErrorStatusCodes, ConfigurationKeys.DeprecatedHttpServerErrorStatusCodes)
#pragma warning restore 618
.AsString(defaultValue: "500-599");
HttpServerErrorStatusCodes = ParseHttpCodesToArray(httpServerErrorStatusCodes);
var httpClientErrorStatusCodes = config
#pragma warning disable 618 // This config key has been replaced but may still be used
.WithKeys(ConfigurationKeys.HttpClientErrorStatusCodes, ConfigurationKeys.DeprecatedHttpClientErrorStatusCodes)
#pragma warning restore 618
.AsString(defaultValue: "400-499");
HttpClientErrorStatusCodes = ParseHttpCodesToArray(httpClientErrorStatusCodes);
TraceBufferSize = config
.WithKeys(ConfigurationKeys.BufferSize)
.AsInt32(defaultValue: 1024 * 1024 * 10); // 10MB
// If Lambda/GCP we don't want to have a flush interval. The serverless integration
// manually calls flush and waits for the result before ending execution.
// This can artificially increase the execution time of functions
var defaultTraceBatchInterval = LambdaMetadata.IsRunningInLambda || IsRunningInGCPFunctions || IsRunningMiniAgentInAzureFunctions ? 0 : 100;
TraceBatchInterval = config
.WithKeys(ConfigurationKeys.SerializationBatchInterval)
.AsInt32(defaultTraceBatchInterval);
RouteTemplateResourceNamesEnabled = config
.WithKeys(ConfigurationKeys.FeatureFlags.RouteTemplateResourceNamesEnabled)
.AsBool(defaultValue: true);
ExpandRouteTemplatesEnabled = config
.WithKeys(ConfigurationKeys.ExpandRouteTemplatesEnabled)
.AsBool(defaultValue: !RouteTemplateResourceNamesEnabled); // disabled by default if route template resource names enabled
KafkaCreateConsumerScopeEnabled = config
.WithKeys(ConfigurationKeys.KafkaCreateConsumerScopeEnabled)
.AsBool(defaultValue: true);
DelayWcfInstrumentationEnabled = config
.WithKeys(ConfigurationKeys.FeatureFlags.DelayWcfInstrumentationEnabled)
.AsBool(defaultValue: true);
WcfWebHttpResourceNamesEnabled = config
.WithKeys(ConfigurationKeys.FeatureFlags.WcfWebHttpResourceNamesEnabled)
.AsBool(defaultValue: true);
WcfObfuscationEnabled = config
.WithKeys(ConfigurationKeys.FeatureFlags.WcfObfuscationEnabled)
.AsBool(defaultValue: true);
ObfuscationQueryStringRegex = config
.WithKeys(ConfigurationKeys.ObfuscationQueryStringRegex)
.AsString(defaultValue: TracerSettingsConstants.DefaultObfuscationQueryStringRegex);
QueryStringReportingEnabled = config
.WithKeys(ConfigurationKeys.QueryStringReportingEnabled)
.AsBool(defaultValue: true);
QueryStringReportingSize = config
.WithKeys(ConfigurationKeys.QueryStringReportingSize)
.AsInt32(defaultValue: 5000); // 5000 being the tag value length limit
ObfuscationQueryStringRegexTimeout = config
.WithKeys(ConfigurationKeys.ObfuscationQueryStringRegexTimeout)
.AsDouble(200, val1 => val1 is > 0).Value;
Func<string[], bool> injectionValidator = styles => styles is { Length: > 0 };
Func<string, ParsingResult<string[]>> otelConverter =
style => TrimSplitString(style, commaSeparator)
.Select(
s => string.Equals(s, "b3", StringComparison.OrdinalIgnoreCase)
? ContextPropagationHeaderStyle.B3SingleHeader // OTEL's "b3" maps to "b3 single header"
: s)
.ToArray();
var getDefaultPropagationHeaders = () => new DefaultResult<string[]>(
[ContextPropagationHeaderStyle.Datadog, ContextPropagationHeaderStyle.W3CTraceContext, ContextPropagationHeaderStyle.W3CBaggage],
$"{ContextPropagationHeaderStyle.Datadog},{ContextPropagationHeaderStyle.W3CTraceContext},{ContextPropagationHeaderStyle.W3CBaggage}");
// Same otel config is used for both injection and extraction
var otelPropagation = config
.WithKeys(ConfigurationKeys.OpenTelemetry.Propagators)
.GetAsClassResult(
validator: injectionValidator, // invalid individual values are rejected later
converter: otelConverter);
PropagationStyleInject = config
.WithKeys(ConfigurationKeys.PropagationStyleInject, "DD_PROPAGATION_STYLE_INJECT", ConfigurationKeys.PropagationStyle)
.GetAsClassResult(
validator: injectionValidator, // invalid individual values are rejected later
converter: style => TrimSplitString(style, commaSeparator))
.OverrideWith(in otelPropagation, ErrorLog, getDefaultPropagationHeaders);
PropagationStyleExtract = config
.WithKeys(ConfigurationKeys.PropagationStyleExtract, "DD_PROPAGATION_STYLE_EXTRACT", ConfigurationKeys.PropagationStyle)
.GetAsClassResult(
validator: injectionValidator, // invalid individual values are rejected later
converter: style => TrimSplitString(style, commaSeparator))
.OverrideWith(in otelPropagation, ErrorLog, getDefaultPropagationHeaders);
PropagationExtractFirstOnly = config
.WithKeys(ConfigurationKeys.PropagationExtractFirstOnly)
.AsBool(false);
BaggageMaximumItems = config
.WithKeys(ConfigurationKeys.BaggageMaximumItems)
.AsInt32(defaultValue: W3CBaggagePropagator.DefaultMaximumBaggageItems);
BaggageMaximumBytes = config
.WithKeys(ConfigurationKeys.BaggageMaximumBytes)
.AsInt32(defaultValue: W3CBaggagePropagator.DefaultMaximumBaggageBytes);
LogSubmissionSettings = new DirectLogSubmissionSettings(source, _telemetry);
TraceMethods = config
.WithKeys(ConfigurationKeys.TraceMethods)
.AsString(string.Empty);
// Filter out tags with empty keys or empty values, and trim whitespaces
GrpcTags = InitializeHeaderTags(config, ConfigurationKeys.GrpcTags, headerTagsNormalizationFixEnabled: true)
?? ReadOnlyDictionary.Empty;
OutgoingTagPropagationHeaderMaxLength = config
.WithKeys(ConfigurationKeys.TagPropagation.HeaderMaxLength)
.AsInt32(
Tagging.TagPropagation.OutgoingTagPropagationHeaderMaxLength,
x => x is >= 0 and <= Tagging.TagPropagation.OutgoingTagPropagationHeaderMaxLength)
.Value;
IpHeader = config
.WithKeys(ConfigurationKeys.IpHeader, ConfigurationKeys.AppSec.CustomIpHeader)
.AsString();
IpHeaderEnabled = config
.WithKeys(ConfigurationKeys.IpHeaderEnabled)
.AsBool(false);
_isDataStreamsMonitoringEnabled = config
.WithKeys(ConfigurationKeys.DataStreamsMonitoring.Enabled)
.AsBool(false);
IsDataStreamsLegacyHeadersEnabled = config
.WithKeys(ConfigurationKeys.DataStreamsMonitoring.LegacyHeadersEnabled)
.AsBool(true);
IsRareSamplerEnabled = config
.WithKeys(ConfigurationKeys.RareSamplerEnabled)
.AsBool(false);
StatsComputationEnabled = config
.WithKeys(ConfigurationKeys.StatsComputationEnabled)
.AsBool(defaultValue: (IsRunningInGCPFunctions || IsRunningMiniAgentInAzureFunctions));
if (AppsecStandaloneEnabledInternal && StatsComputationEnabled)
{
telemetry.Record(ConfigurationKeys.StatsComputationEnabled, false, ConfigurationOrigins.Calculated);
StatsComputationEnabled = false;
}
var urlSubstringSkips = config
.WithKeys(ConfigurationKeys.HttpClientExcludedUrlSubstrings)
.AsString(
IsRunningInAzureAppService ? ImmutableAzureAppServiceSettings.DefaultHttpClientExclusions :
LambdaMetadata is { IsRunningInLambda: true } m ? m.DefaultHttpClientExclusions : string.Empty);
if (isRunningInCiVisibility)
{
// always add the additional exclude in ci vis
const string fakeSessionEndpoint = "/session/FakeSessionIdForPollingPurposes";
urlSubstringSkips = string.IsNullOrEmpty(urlSubstringSkips)
? fakeSessionEndpoint
: $"{urlSubstringSkips},{fakeSessionEndpoint}";
telemetry.Record(ConfigurationKeys.HttpClientExcludedUrlSubstrings, urlSubstringSkips, recordValue: true, ConfigurationOrigins.Calculated);
}
HttpClientExcludedUrlSubstrings = !string.IsNullOrEmpty(urlSubstringSkips)
? TrimSplitString(urlSubstringSkips.ToUpperInvariant(), commaSeparator)
: [];
DbmPropagationMode = config
.WithKeys(ConfigurationKeys.DbmPropagationMode)
.GetAs(
() => new DefaultResult<DbmPropagationLevel>(DbmPropagationLevel.Disabled, nameof(DbmPropagationLevel.Disabled)),
converter: x => ToDbmPropagationInput(x) ?? ParsingResult<DbmPropagationLevel>.Failure(),
validator: null);
TraceId128BitGenerationEnabled = config
.WithKeys(ConfigurationKeys.FeatureFlags.TraceId128BitGenerationEnabled)
.AsBool(true);
TraceId128BitLoggingEnabled = config
.WithKeys(ConfigurationKeys.FeatureFlags.TraceId128BitLoggingEnabled)
.AsBool(false);
CommandsCollectionEnabled = config
.WithKeys(ConfigurationKeys.FeatureFlags.CommandsCollectionEnabled)
.AsBool(false);
var defaultDisabledAdoNetCommandTypes = new string[] { "InterceptableDbCommand", "ProfiledDbCommand" };
var userDisabledAdoNetCommandTypes = config.WithKeys(ConfigurationKeys.DisabledAdoNetCommandTypes).AsString();
DisabledAdoNetCommandTypes = new HashSet<string>(defaultDisabledAdoNetCommandTypes, StringComparer.OrdinalIgnoreCase);
if (!string.IsNullOrEmpty(userDisabledAdoNetCommandTypes))
{
var userSplit = TrimSplitString(userDisabledAdoNetCommandTypes, commaSeparator);
DisabledAdoNetCommandTypes.UnionWith(userSplit);
}
// we "enrich" with these values which aren't _strictly_ configuration, but which we want to track as we tracked them in v1
telemetry.Record(ConfigTelemetryData.NativeTracerVersion, Instrumentation.GetNativeTracerVersion(), recordValue: true, ConfigurationOrigins.Default);
telemetry.Record(ConfigTelemetryData.FullTrustAppDomain, value: AppDomain.CurrentDomain.IsFullyTrusted, ConfigurationOrigins.Default);
telemetry.Record(ConfigTelemetryData.ManagedTracerTfm, value: ConfigTelemetryData.ManagedTracerTfmValue, recordValue: true, ConfigurationOrigins.Default);
// these are SSI variables that would be useful for correlation purposes
telemetry.Record(ConfigTelemetryData.SsiInjectionEnabled, value: EnvironmentHelpers.GetEnvironmentVariable("DD_INJECTION_ENABLED"), recordValue: true, ConfigurationOrigins.EnvVars);
telemetry.Record(ConfigTelemetryData.SsiAllowUnsupportedRuntimesEnabled, value: EnvironmentHelpers.GetEnvironmentVariable("DD_INJECT_FORCE"), recordValue: true, ConfigurationOrigins.EnvVars);
if (AzureAppServiceMetadata is not null)
{
telemetry.Record(ConfigTelemetryData.AasConfigurationError, AzureAppServiceMetadata.IsUnsafeToTrace, ConfigurationOrigins.Default);
telemetry.Record(ConfigTelemetryData.CloudHosting, "Azure", recordValue: true, ConfigurationOrigins.Default);
telemetry.Record(ConfigTelemetryData.AasAppType, AzureAppServiceMetadata.SiteType, recordValue: true, ConfigurationOrigins.Default);
}
static void RecordDisabledIntegrationsTelemetry(IntegrationSettingsCollection integrations, IConfigurationTelemetry telemetry)
{
// Record the final disabled settings values in the telemetry, we can't quite get this information
// through the IntegrationTelemetryCollector currently so record it here instead
StringBuilder? sb = null;
foreach (var setting in integrations.Settings)
{
if (setting.Enabled == false)
{
sb ??= StringBuilderCache.Acquire();
sb.Append(setting.IntegrationName);
sb.Append(';');
}
}
var value = sb is null ? null : StringBuilderCache.GetStringAndRelease(sb);
telemetry.Record(ConfigurationKeys.DisabledIntegrations, value, recordValue: true, ConfigurationOrigins.Calculated);
}
}
internal OverrideErrorLog ErrorLog { get; }
internal IConfigurationTelemetry Telemetry => _telemetry;
/// <summary>
/// Gets the default environment name applied to all spans.
/// </summary>
/// <seealso cref="ConfigurationKeys.Environment"/>
public string? Environment { get; }
/// <summary>
/// Gets the service name applied to top-level spans and used to build derived service names.
/// </summary>
/// <seealso cref="ConfigurationKeys.ServiceName"/>
public string? ServiceName { get; }
/// <summary>
/// Gets the version tag applied to all spans.
/// </summary>
/// <seealso cref="ConfigurationKeys.ServiceVersion"/>
public string? ServiceVersion { get; }
/// <summary>
/// Gets the application's git repository url.
/// </summary>
/// <seealso cref="ConfigurationKeys.GitRepositoryUrl"/>
internal string? GitRepositoryUrl { get; }
/// <summary>
/// Gets the application's git commit hash.
/// </summary>
/// <seealso cref="ConfigurationKeys.GitCommitSha"/>
internal string? GitCommitSha { get; }
/// <summary>
/// Gets a value indicating whether we should tag every telemetry event with git metadata.
/// Default value is <c>true</c> (enabled).
/// </summary>
/// <seealso cref="ConfigurationKeys.GitMetadataEnabled"/>
internal bool GitMetadataEnabled { get; }
/// <summary>
/// Gets a value indicating whether tracing is enabled.
/// Default is <c>true</c>.
/// </summary>
/// <seealso cref="ConfigurationKeys.TraceEnabled"/>
public bool TraceEnabled => DynamicSettings.TraceEnabled ?? _traceEnabled;
/// <summary>
/// Gets a value indicating whether Appsec standalone is enabled.
/// Default is <c>false</c>.
/// </summary>
/// <seealso cref="ConfigurationKeys.AppsecStandaloneEnabled"/>
internal bool AppsecStandaloneEnabledInternal => DynamicSettings.AppsecStandaloneEnabled ?? _appsecStandaloneEnabled;
/// <summary>
/// Gets a value indicating whether profiling is enabled.
/// Default is <c>false</c>.
/// </summary>
/// <seealso cref="ContinuousProfiler.ConfigurationKeys.ProfilingEnabled"/>
internal bool ProfilingEnabledInternal { get; }
/// <summary>
/// Gets the names of disabled integrations.
/// </summary>
/// <seealso cref="ConfigurationKeys.DisabledIntegrations"/>
public HashSet<string> DisabledIntegrationNames { get; }
/// <summary>
/// Gets the transport settings that dictate how the tracer connects to the agent.
/// </summary>
public ExporterSettings Exporter { get; }
/// <summary>
/// Gets a value indicating whether default Analytics are enabled.
/// Settings this value is a shortcut for setting
/// <see cref="Configuration.IntegrationSettings.AnalyticsEnabled"/> on some predetermined integrations.
/// See the documentation for more details.
/// </summary>
/// <seealso cref="ConfigurationKeys.GlobalAnalyticsEnabled"/>
[Obsolete(DeprecationMessages.AppAnalytics)]
public bool AnalyticsEnabled { get; }
/// <summary>
/// Gets a value indicating whether correlation identifiers are
/// automatically injected into the logging context.
/// Default is <c>false</c>, unless <see cref="ConfigurationKeys.DirectLogSubmission.EnabledIntegrations"/>
/// enables Direct Log Submission.
/// </summary>
/// <seealso cref="ConfigurationKeys.LogsInjectionEnabled"/>
public bool LogsInjectionEnabled => DynamicSettings.LogsInjectionEnabled ?? LogSubmissionSettings.LogsInjectionEnabled;
/// <summary>
/// Gets a value indicating the maximum number of traces set to AutoKeep (p1) per second.
/// Default is <c>100</c>.
/// </summary>
/// <seealso cref="ConfigurationKeys.TraceRateLimit"/>
public int MaxTracesSubmittedPerSecond { get; }
/// <summary>
/// Gets a value indicating custom sampling rules.
/// </summary>
/// <seealso cref="ConfigurationKeys.CustomSamplingRules"/>
public string? CustomSamplingRules => DynamicSettings.SamplingRules ?? _customSamplingRules;
internal bool CustomSamplingRulesIsRemote => DynamicSettings.SamplingRules != null;
/// <summary>
/// Gets a value indicating the format for custom trace sampling rules ("regex" or "glob").
/// If the value is not recognized, trace sampling rules are disabled.
/// </summary>
/// <seealso cref="ConfigurationKeys.CustomSamplingRulesFormat"/>
internal string CustomSamplingRulesFormat { get; }
/// <summary>
/// Gets a value indicating span sampling rules.
/// </summary>
/// <seealso cref="ConfigurationKeys.SpanSamplingRules"/>
internal string? SpanSamplingRules { get; }
/// <summary>
/// Gets a value indicating a global rate for sampling.
/// </summary>
/// <seealso cref="ConfigurationKeys.GlobalSamplingRate"/>
public double? GlobalSamplingRate => DynamicSettings.GlobalSamplingRate ?? _globalSamplingRate;
/// <summary>
/// Gets a collection of <see cref="IntegrationSettings"/> keyed by integration name.
/// </summary>
public IntegrationSettingsCollection Integrations { get; }
/// <summary>
/// Gets the global tags, which are applied to all <see cref="Span"/>s.
/// </summary>
public IReadOnlyDictionary<string, string> GlobalTags => DynamicSettings.GlobalTags ?? _globalTags;
/// <summary>
/// Gets the map of header keys to tag names, which are applied to the root <see cref="Span"/>
/// of incoming and outgoing HTTP requests.
/// </summary>
public IReadOnlyDictionary<string, string> HeaderTags => DynamicSettings.HeaderTags ?? _headerTags;
/// <summary>
/// Gets a custom request header configured to read the ip from. For backward compatibility, it fallbacks on DD_APPSEC_IPHEADER
/// </summary>
internal string? IpHeader { get; }
/// <summary>
/// Gets a value indicating whether the ip header should not be collected. The default is false.
/// </summary>
internal bool IpHeaderEnabled { get; }
/// <summary>
/// Gets the map of metadata keys to tag names, which are applied to the root <see cref="Span"/>
/// of incoming and outgoing GRPC requests.
/// </summary>
public IReadOnlyDictionary<string, string> GrpcTags { get; }
/// <summary>
/// Gets a value indicating whether internal metrics
/// are enabled and sent to DogStatsd.
/// </summary>
public bool TracerMetricsEnabled { get; }
/// <summary>
/// Gets a value indicating whether stats are computed on the tracer side
/// </summary>
public bool StatsComputationEnabled { get; }
/// <summary>
/// Gets a value indicating whether the use
/// of System.Diagnostics.DiagnosticSource is enabled.
/// Default is <c>true</c>.
/// </summary>
/// <remark>
/// This value cannot be set in code. Instead,
/// set it using the <c>DD_TRACE_DIAGNOSTIC_SOURCE_ENABLED</c>
/// environment variable or in configuration files.
/// </remark>
[PublicApi]
public bool DiagnosticSourceEnabled
{
get
{
TelemetryFactory.Metrics.Record(PublicApiUsage.TracerSettings_DiagnosticSourceEnabled_Get);
return GlobalSettings.Instance.DiagnosticSourceEnabled;
}
}
/// <summary>
/// Gets a value indicating whether a span context should be created on exiting a successful Kafka
/// Consumer.Consume() call, and closed on entering Consumer.Consume().
/// </summary>
/// <seealso cref="ConfigurationKeys.KafkaCreateConsumerScopeEnabled"/>
public bool KafkaCreateConsumerScopeEnabled { get; }
/// <summary>
/// Gets a value indicating whether to enable the updated WCF instrumentation that delays execution
/// until later in the WCF pipeline when the WCF server exception handling is established.
/// </summary>
internal bool DelayWcfInstrumentationEnabled { get; }
/// <summary>
/// Gets a value indicating whether to enable improved template-based resource names
/// when using WCF Web HTTP.
/// </summary>
internal bool WcfWebHttpResourceNamesEnabled { get; }
/// <summary>
/// Gets a value indicating whether to obfuscate the <c>LocalPath</c> of a WCF request that goes
/// into the <c>resourceName</c> of a span.
/// </summary>
/// <seealso cref="ConfigurationKeys.FeatureFlags.WcfObfuscationEnabled"/>
internal bool WcfObfuscationEnabled { get; }
/// <summary>
/// Gets a value indicating the regex to apply to obfuscate http query strings.
/// Warning: This regex cause crashes under netcoreapp2.1 / linux / arm64, DON'T use default value on manual instrumentation
/// </summary>
internal string ObfuscationQueryStringRegex { get; }
/// <summary>
/// Gets a value indicating whether or not http.url should contain the query string, enabled by default
/// </summary>
internal bool QueryStringReportingEnabled { get; }
/// <summary>
/// Gets a value limiting the size of the querystring to report and obfuscate
/// Default value is 5000, 0 means that we don't limit the size.
/// </summary>
internal int QueryStringReportingSize { get; }
/// <summary>
/// Gets a value indicating a timeout in milliseconds to the execution of the query string obfuscation regex
/// Default value is 200ms
/// </summary>
internal double ObfuscationQueryStringRegexTimeout { get; }
/// <summary>
/// Gets a value indicating whether the diagnostic log at startup is enabled
/// </summary>
public bool StartupDiagnosticLogEnabled { get; }
/// <summary>
/// Gets the time interval (in seconds) for sending stats
/// </summary>
internal int StatsComputationInterval { get; }
/// <summary>
/// Gets the maximum length of an outgoing propagation header's value ("x-datadog-tags")
/// when injecting it into downstream service calls.
/// </summary>
/// <seealso cref="ConfigurationKeys.TagPropagation.HeaderMaxLength"/>
/// <remarks>
/// This value is not used when extracting an incoming propagation header from an upstream service.
/// </remarks>
internal int OutgoingTagPropagationHeaderMaxLength { get; }
/// <summary>
/// Gets a value indicating the injection propagation style.
/// </summary>
internal string[] PropagationStyleInject { get; }
/// <summary>
/// Gets a value indicating the extraction propagation style.
/// </summary>
internal string[] PropagationStyleExtract { get; }
/// <summary>
/// Gets a value indicating whether the propagation should only try
/// extract the first header.
/// </summary>
internal bool PropagationExtractFirstOnly { get; }
/// <summary>
/// Gets the maximum number of items that can be
/// injected into the baggage header when propagating to a downstream service.
/// Default value is 64 items.
/// </summary>
/// <seealso cref="ConfigurationKeys.BaggageMaximumItems"/>
internal int BaggageMaximumItems { get; }
/// <summary>
/// Gets the maximum number of bytes that can be
/// injected into the baggage header when propagating to a downstream service.
/// Default value is 8192 bytes.
/// </summary>
/// <seealso cref="ConfigurationKeys.BaggageMaximumBytes"/>
internal int BaggageMaximumBytes { get; }
/// <summary>
/// Gets a value indicating whether runtime metrics
/// are enabled and sent to DogStatsd.
/// </summary>
internal bool RuntimeMetricsEnabled => DynamicSettings.RuntimeMetricsEnabled ?? _runtimeMetricsEnabled;
/// <summary>
/// Gets the comma separated list of url patterns to skip tracing.
/// </summary>
/// <seealso cref="ConfigurationKeys.HttpClientExcludedUrlSubstrings"/>
internal string[] HttpClientExcludedUrlSubstrings { get; }
/// <summary>
/// Gets the HTTP status code that should be marked as errors for server integrations.
/// </summary>
/// <seealso cref="ConfigurationKeys.HttpServerErrorStatusCodes"/>
internal bool[] HttpServerErrorStatusCodes { get; }
/// <summary>
/// Gets the HTTP status code that should be marked as errors for client integrations.
/// </summary>
/// <seealso cref="ConfigurationKeys.HttpClientErrorStatusCodes"/>
internal bool[] HttpClientErrorStatusCodes { get; }
/// <summary>
/// Gets configuration values for changing service names based on configuration
/// </summary>
internal IReadOnlyDictionary<string, string> ServiceNameMappings => DynamicSettings.ServiceNameMappings ?? _serviceNameMappings;
/// <summary>
/// Gets configuration values for changing peer service names based on configuration
/// </summary>
internal IReadOnlyDictionary<string, string>? PeerServiceNameMappings { get; }
/// <summary>
/// Gets a value indicating the size in bytes of the trace buffer
/// </summary>
internal int TraceBufferSize { get; }
/// <summary>
/// Gets a value indicating the batch interval for the serialization queue, in milliseconds
/// </summary>
internal int TraceBatchInterval { get; }
/// <summary>
/// Gets a value indicating whether the feature flag to enable the updated ASP.NET resource names is enabled
/// </summary>
/// <seealso cref="ConfigurationKeys.FeatureFlags.RouteTemplateResourceNamesEnabled"/>
internal bool RouteTemplateResourceNamesEnabled { get; }
/// <summary>
/// Gets a value indicating whether resource names for ASP.NET and ASP.NET Core spans should be expanded. Only applies
/// when <see cref="RouteTemplateResourceNamesEnabled"/> is <code>true</code>.
/// </summary>
internal bool ExpandRouteTemplatesEnabled { get; }
/// <summary>
/// Gets the direct log submission settings.
/// </summary>
internal DirectLogSubmissionSettings LogSubmissionSettings { get; }
/// <summary>
/// Gets a value indicating the trace methods configuration.
/// </summary>
internal string TraceMethods { get; }
/// <summary>
/// Gets a value indicating whether the activity listener is enabled or not.
/// </summary>
internal bool IsActivityListenerEnabled { get; }
/// <summary>
/// Gets a value indicating whether data streams monitoring is enabled or not.
/// </summary>
internal bool IsDataStreamsMonitoringEnabled => DynamicSettings.DataStreamsMonitoringEnabled ?? _isDataStreamsMonitoringEnabled;
/// <summary>
/// Gets a value indicating whether to inject legacy binary headers for Data Streams.
/// </summary>
internal bool IsDataStreamsLegacyHeadersEnabled { get; }
/// <summary>
/// Gets a value indicating whether the rare sampler is enabled or not.
/// </summary>
internal bool IsRareSamplerEnabled { get; }