-
Notifications
You must be signed in to change notification settings - Fork 157
Expand file tree
/
Copy pathTracerSettings.cs
More file actions
1446 lines (1210 loc) · 75.6 KB
/
TracerSettings.cs
File metadata and controls
1446 lines (1210 loc) · 75.6 KB
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.Linq;
using Datadog.Trace.Agent;
using Datadog.Trace.ClrProfiler;
using Datadog.Trace.ClrProfiler.ServerlessInstrumentation;
using Datadog.Trace.Configuration.ConfigurationSources.Telemetry;
using Datadog.Trace.Configuration.Telemetry;
using Datadog.Trace.LibDatadog;
using Datadog.Trace.Logging;
using Datadog.Trace.Logging.DirectSubmission;
using Datadog.Trace.PlatformHelpers;
using Datadog.Trace.Propagators;
using Datadog.Trace.Sampling;
using Datadog.Trace.Serverless;
using Datadog.Trace.SourceGenerators;
using Datadog.Trace.Telemetry;
using Datadog.Trace.Telemetry.Metrics;
using Datadog.Trace.Util;
namespace Datadog.Trace.Configuration
{
/// <summary>
/// Contains Tracer settings.
/// </summary>
public partial record TracerSettings
{
private static readonly IDatadogLogger Log = DatadogLogging.GetLoggerFor<TracerSettings>();
private static readonly HashSet<string> DefaultExperimentalFeatures = ["DD_TAGS", ConfigurationKeys.PropagateProcessTags];
private readonly Lazy<string> _fallbackApplicationName;
[TestingOnly]
internal TracerSettings()
: this(null, new ConfigurationTelemetry(), new OverrideErrorLog())
{
}
[TestingOnly]
internal TracerSettings(IConfigurationSource? source, IConfigurationTelemetry? telemetry = null)
: this(source, telemetry ?? new ConfigurationTelemetry(), new OverrideErrorLog())
{
}
/// <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)
: this(source, telemetry, errorLog, LibDatadogAvailabilityHelper.IsLibDatadogAvailable)
{
}
/// <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>
/// <param name="isLibDatadogAvailable">Used to check whether the libdatadog library is available. Useful for integration tests</param>
internal TracerSettings(IConfigurationSource? source, IConfigurationTelemetry telemetry, OverrideErrorLog errorLog, LibDatadogAvailableResult isLibDatadogAvailable)
{
var commaSeparator = Separators.Comma;
source ??= NullConfigurationSource.Instance;
ErrorLog = errorLog;
var config = new ConfigurationBuilder(source, telemetry);
ExperimentalFeaturesEnabled = config
.WithKeys(ConfigurationKeys.ExperimentalFeaturesEnabled)
.AsString()?.Trim() switch
{
null or "none" => new HashSet<string>(),
"all" => DefaultExperimentalFeatures,
string s => new HashSet<string>(s.Split([','], StringSplitOptions.RemoveEmptyEntries)),
};
PropagateProcessTags = config
.WithKeys(ConfigurationKeys.PropagateProcessTags)
.AsBool(ExperimentalFeaturesEnabled.Contains(ConfigurationKeys.PropagateProcessTags)); // read it as "defaults to false"
GCPFunctionSettings = new ImmutableGCPFunctionSettings(source, telemetry);
IsRunningInGCPFunctions = GCPFunctionSettings.IsGCPFunction;
// We don't want/need to record this value, so explicitly use null telemetry
IsRunningInCiVisibility = new ConfigurationBuilder(source, NullConfigurationTelemetry.Instance)
.WithKeys(ConfigurationKeys.CIVisibility.IsRunningInCiVisMode)
.AsBool(false);
LambdaMetadata = LambdaMetadata.Create();
if (ImmutableAzureAppServiceSettings.IsRunningInAzureAppServices(source, telemetry))
{
AzureAppServiceMetadata = new ImmutableAzureAppServiceSettings(source, telemetry);
}
GitMetadataEnabled = config
.WithKeys(ConfigurationKeys.GitMetadataEnabled)
.AsBool(defaultValue: true);
ApmTracingEnabled = config
.WithKeys(ConfigurationKeys.ApmTracingEnabled)
.AsBool(defaultValue: true);
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)
.AsBoolResult()
.OverrideWith(in otelActivityListenerEnabled, ErrorLog, defaultValue: false);
PeerServiceTagsEnabled = config
.WithKeys(ConfigurationKeys.PeerServiceDefaultsEnabled)
.AsBool(defaultValue: false);
RemoveClientServiceNamesEnabled = config
.WithKeys(ConfigurationKeys.RemoveClientServiceNamesEnabled)
.AsBool(defaultValue: false);
SpanPointersEnabled = config
.WithKeys(ConfigurationKeys.SpanPointersEnabled)
.AsBool(defaultValue: true);
PeerServiceNameMappings = TrimConfigKeysValues(config.WithKeys(ConfigurationKeys.PeerServiceNameMappings));
MetadataSchemaVersion = config
.WithKeys(ConfigurationKeys.MetadataSchemaVersion)
.GetAs(
defaultValue: 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);
StatsComputationInterval = config.WithKeys(ConfigurationKeys.StatsComputationInterval).AsInt32(defaultValue: 10);
var otelMetricsExporter = config
.WithKeys(ConfigurationKeys.OpenTelemetry.MetricsExporter);
OtelMetricsExporterEnabled = string.Equals(otelMetricsExporter.AsString(defaultValue: "otlp"), "otlp", StringComparison.OrdinalIgnoreCase);
var otelExporterResult = otelMetricsExporter
.AsBoolResult(
null,
value => value switch
{
not null when string.Equals(value, "none", StringComparison.OrdinalIgnoreCase) => ParsingResult<bool>.Success(result: false),
not null when string.Equals(value, "otlp", StringComparison.OrdinalIgnoreCase) => ParsingResult<bool>.Success(result: true),
_ => ParsingResult<bool>.Failure()
});
var runtimeMetricsEnabledResult = config
.WithKeys(ConfigurationKeys.RuntimeMetricsEnabled)
.AsBoolResult();
if (runtimeMetricsEnabledResult.ConfigurationResult.IsPresent && otelExporterResult.ConfigurationResult.IsPresent)
{
ErrorLog.LogDuplicateConfiguration(ConfigurationKeys.RuntimeMetricsEnabled, ConfigurationKeys.OpenTelemetry.MetricsExporter);
}
else if (otelExporterResult.ConfigurationResult is { IsPresent: true, IsValid: false })
{
ErrorLog.LogInvalidConfiguration(ConfigurationKeys.OpenTelemetry.MetricsExporter);
}
#if NET6_0_OR_GREATER
var defaultRuntimeMetrics = true;
#else
var defaultRuntimeMetrics = false;
#endif
if (runtimeMetricsEnabledResult.ConfigurationResult is { IsPresent: true, IsValid: true })
{
RuntimeMetricsEnabled = runtimeMetricsEnabledResult.WithDefault(defaultRuntimeMetrics);
}
else if (otelExporterResult.ConfigurationResult is { IsPresent: true, IsValid: true, Result: false })
{
// OTEL_METRICS_EXPORTER=none explicitly disables metrics export, which takes precedence
// over the .NET 6+ default and disables runtime metrics.
RuntimeMetricsEnabled = false;
}
else
{
RuntimeMetricsEnabled = runtimeMetricsEnabledResult.WithDefault(defaultRuntimeMetrics);
}
var runtimeMetricsDiagnosticsMetricsApiEnabledResult = config
.WithKeys(ConfigurationKeys.RuntimeMetricsDiagnosticsMetricsApiEnabled)
.AsBoolResult();
#if NET6_0_OR_GREATER
// On .NET 8+, default to Diagnostics for all users (full metric coverage including ASP.NET Core meters).
// On .NET 6/7, default to Diagnostics only when runtime metrics were not explicitly configured,
// to avoid EventPipe crash/leak issues (dotnet/runtime#103480, dotnet/runtime#111368).
// Explicit DD_RUNTIME_METRICS_ENABLED=true users on .NET 6/7 keep EventListener
// to preserve ASP.NET Core EventCounter metrics not available via Diagnostics on < .NET 8.
var diagnosticsDefault = !runtimeMetricsEnabledResult.ConfigurationResult.IsValid || FrameworkDescription.Instance.RuntimeVersion.Major >= 8;
RuntimeMetricsDiagnosticsMetricsApiEnabled = runtimeMetricsDiagnosticsMetricsApiEnabledResult.WithDefault(diagnosticsDefault);
#else
// System.Diagnostics.Metrics is not available before .NET 6, keep disabled by default
RuntimeMetricsDiagnosticsMetricsApiEnabled = runtimeMetricsDiagnosticsMetricsApiEnabledResult.WithDefault(false);
if (RuntimeMetricsEnabled && RuntimeMetricsDiagnosticsMetricsApiEnabled)
{
Log.Warning(
$"{ConfigurationKeys.RuntimeMetricsDiagnosticsMetricsApiEnabled} was enabled, but System.Diagnostics.Metrics is only available on .NET 6+. Using standard runtime metrics collector.");
telemetry.Record(ConfigurationKeys.RuntimeMetricsDiagnosticsMetricsApiEnabled, false, ConfigurationOrigins.Calculated);
RuntimeMetricsDiagnosticsMetricsApiEnabled = false;
}
#endif
OtelMetricExportIntervalMs = config
.WithKeys(ConfigurationKeys.OpenTelemetry.MetricExportIntervalMs)
.AsInt32(defaultValue: 10_000);
OtelMetricExportTimeoutMs = config
.WithKeys(ConfigurationKeys.OpenTelemetry.MetricExportTimeoutMs)
.AsInt32(defaultValue: 7_500);
var defaultAgentHost = config
.WithKeys(ConfigurationKeys.AgentHost)
.AsString(defaultValue: "localhost");
OtlpGeneralProtocol = config
.WithKeys(ConfigurationKeys.OpenTelemetry.ExporterOtlpProtocol)
.GetAs(
defaultValue: new(OtlpProtocol.Grpc, "grpc"),
converter: x => x switch
{
not null when string.Equals(x, "grpc", StringComparison.OrdinalIgnoreCase) => OtlpProtocol.Grpc,
not null when string.Equals(x, "http/protobuf", StringComparison.OrdinalIgnoreCase) => OtlpProtocol.HttpProtobuf,
_ => UnsupportedOtlpProtocol(inputValue: x ?? "null"),
},
validator: null);
OtlpMetricsProtocol = config
.WithKeys(ConfigurationKeys.OpenTelemetry.ExporterOtlpMetricsProtocol)
.GetAs(
defaultValue: new(OtlpProtocol.Grpc, "grpc"),
converter: x => x switch
{
not null when string.Equals(x, "grpc", StringComparison.OrdinalIgnoreCase) => OtlpProtocol.Grpc,
not null when string.Equals(x, "http/protobuf", StringComparison.OrdinalIgnoreCase) => OtlpProtocol.HttpProtobuf,
not null when string.Equals(x, "http/json", StringComparison.OrdinalIgnoreCase) => OtlpProtocol.HttpJson,
_ => UnsupportedOtlpProtocol(inputValue: x ?? "null"),
},
validator: null);
var defaultUri = $"http://{defaultAgentHost}:{(!OtlpGeneralProtocol.Equals(OtlpProtocol.Grpc) ? 4318 : 4317)}/";
OtlpEndpoint = config
.WithKeys(ConfigurationKeys.OpenTelemetry.ExporterOtlpEndpoint)
.GetAs(
defaultValue: new DefaultResult<Uri>(result: new Uri(defaultUri), telemetryValue: defaultUri),
validator: null,
converter: uriString => new Uri(uriString));
OtlpMetricsEndpoint = config
.WithKeys(ConfigurationKeys.OpenTelemetry.ExporterOtlpMetricsEndpoint)
.GetAs(
defaultValue: new DefaultResult<Uri>(
result: OtlpMetricsProtocol switch
{
OtlpProtocol.Grpc => OtlpEndpoint,
_ => new Uri(OtlpEndpoint, "/v1/metrics")
},
telemetryValue: $"{OtlpEndpoint}{(!OtlpMetricsProtocol.Equals(OtlpProtocol.Grpc) ? "v1/metrics" : string.Empty)}"),
validator: null,
converter: uriString => new Uri(uriString));
OtlpMetricsHeaders = config
.WithKeys(ConfigurationKeys.OpenTelemetry.ExporterOtlpMetricsHeaders)
.AsDictionaryResult(separator: '=')
.WithDefault(new DefaultResult<IDictionary<string, string>>(new Dictionary<string, string>(), "[]"))
.Where(kvp => !string.IsNullOrWhiteSpace(kvp.Key))
.ToDictionary(kvp => kvp.Key.Trim(), kvp => kvp.Value?.Trim() ?? string.Empty);
OtlpMetricsTimeoutMs = config
.WithKeys(ConfigurationKeys.OpenTelemetry.ExporterOtlpMetricsTimeoutMs)
.AsInt32(defaultValue: 10_000);
OtlpMetricsTemporalityPreference = config
.WithKeys(ConfigurationKeys.OpenTelemetry.ExporterOtlpMetricsTemporalityPreference)
.GetAs(
defaultValue: new(OtlpTemporalityPreference.Delta, "delta"),
converter: x => x switch
{
not null when string.Equals(x, "cumulative", StringComparison.OrdinalIgnoreCase) => OtlpTemporalityPreference.Cumulative,
not null when string.Equals(x, "delta", StringComparison.OrdinalIgnoreCase) => OtlpTemporalityPreference.Delta,
not null when string.Equals(x, "lowmemory", StringComparison.OrdinalIgnoreCase) => OtlpTemporalityPreference.LowMemory,
_ => ParsingResult<OtlpTemporalityPreference>.Failure(),
},
validator: null);
OtlpLogsProtocol = config
.WithKeys(ConfigurationKeys.OpenTelemetry.ExporterOtlpLogsProtocol)
.GetAs(
defaultValue: new(OtlpProtocol.Grpc, "grpc"),
converter: x => x switch
{
not null when string.Equals(x, "grpc", StringComparison.OrdinalIgnoreCase) => OtlpProtocol.Grpc,
not null when string.Equals(x, "http/json", StringComparison.OrdinalIgnoreCase) => OtlpProtocol.HttpJson,
not null when string.Equals(x, "http/protobuf", StringComparison.OrdinalIgnoreCase) => OtlpProtocol.HttpProtobuf,
_ => UnsupportedOtlpProtocol(inputValue: x ?? "null"),
},
validator: null);
OtlpLogsEndpoint = config
.WithKeys(ConfigurationKeys.OpenTelemetry.ExporterOtlpLogsEndpoint)
.GetAs(
defaultValue: new DefaultResult<Uri>(
result: OtlpLogsProtocol switch
{
OtlpProtocol.Grpc => OtlpEndpoint,
_ => new Uri(OtlpEndpoint, "/v1/logs")
},
telemetryValue: $"{OtlpEndpoint}{(!OtlpLogsProtocol.Equals(OtlpProtocol.Grpc) ? "v1/logs" : string.Empty)}"),
validator: null,
converter: uriString => new Uri(uriString));
OtlpLogsHeaders = config
.WithKeys(ConfigurationKeys.OpenTelemetry.ExporterOtlpLogsHeaders)
.AsDictionaryResult(separator: '=')
.WithDefault(new DefaultResult<IDictionary<string, string>>(new Dictionary<string, string>(), "[]"))
.Where(kvp => !string.IsNullOrWhiteSpace(kvp.Key))
.ToDictionary(kvp => kvp.Key.Trim(), kvp => kvp.Value?.Trim() ?? string.Empty);
OtlpLogsTimeoutMs = config
.WithKeys(ConfigurationKeys.OpenTelemetry.ExporterOtlpLogsTimeoutMs)
.AsInt32(defaultValue: 10_000);
var otelLogsExporter = config
.WithKeys(ConfigurationKeys.OpenTelemetry.LogsExporter);
var otelLogsExporterResult = otelLogsExporter
.AsBoolResult(
null,
value => value switch
{
not null when string.Equals(value, "none", StringComparison.OrdinalIgnoreCase) => ParsingResult<bool>.Success(result: false),
not null when string.Equals(value, "otlp", StringComparison.OrdinalIgnoreCase) => ParsingResult<bool>.Success(result: true),
_ => ParsingResult<bool>.Failure()
});
// Per OpenTelemetry spec, OTEL_LOGS_EXPORTER defaults to "otlp" if not set
OtelLogsExporterEnabled = otelLogsExporterResult.ConfigurationResult switch
{
{ IsPresent: true, IsValid: true, Result: true } => true,
{ IsPresent: true, IsValid: true, Result: false } => false,
_ => true // Default to otlp per spec
};
if (otelLogsExporterResult.ConfigurationResult is { IsPresent: true, IsValid: false })
{
ErrorLog.LogInvalidConfiguration(ConfigurationKeys.OpenTelemetry.LogsExporter);
}
OpenTelemetryLogsEnabled = config
.WithKeys(ConfigurationKeys.FeatureFlags.OpenTelemetryLogsEnabled)
.AsBool(defaultValue: false);
OpenTelemetryLogsEnabled = OpenTelemetryLogsEnabled && OtelLogsExporterEnabled;
// 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
CustomSamplingRulesFormat = config.WithKeys(ConfigurationKeys.CustomSamplingRulesFormat)
.GetAs(
defaultValue: 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();
TraceBufferSize = config
.WithKeys(ConfigurationKeys.BufferSize)
.AsInt32(defaultValue: 1024 * 1024 * 10); // 10MB
// If Lambda/GCP we don't want to have a flush interval. Some serverless integrations
// 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 || IsRunningInAzureFunctions ? 0 : 100;
TraceBatchInterval = config
.WithKeys(ConfigurationKeys.SerializationBatchInterval)
.AsInt32(defaultTraceBatchInterval);
RouteTemplateResourceNamesEnabled = config
.WithKeys(ConfigurationKeys.FeatureFlags.RouteTemplateResourceNamesEnabled)
.AsBool(defaultValue: true);
SingleSpanAspNetCoreEnabled = config
.WithKeys(ConfigurationKeys.FeatureFlags.SingleSpanAspNetCoreEnabled)
.AsBool(defaultValue: false);
#if !NET6_0_OR_GREATER
// single span aspnetcore is only supported in .NET 6+, so override for telemetry purposes
if (SingleSpanAspNetCoreEnabled)
{
SingleSpanAspNetCoreEnabled = false;
Log.Warning(
$"{ConfigurationKeys.FeatureFlags.SingleSpanAspNetCoreEnabled} is set to true, but is only supported in .NET 6+. Using false instead.");
telemetry.Record(ConfigurationKeys.FeatureFlags.SingleSpanAspNetCoreEnabled, false, ConfigurationOrigins.Calculated);
}
#endif
ExpandRouteTemplatesEnabled = config
.WithKeys(ConfigurationKeys.ExpandRouteTemplatesEnabled)
.AsBool(defaultValue: !(RouteTemplateResourceNamesEnabled || SingleSpanAspNetCoreEnabled)); // disabled by default if route template resource names or single-span enabled
AzureServiceBusBatchLinksEnabled = config
.WithKeys(ConfigurationKeys.AzureServiceBusBatchLinksEnabled)
.AsBool(defaultValue: true);
AzureEventHubsBatchLinksEnabled = config
.WithKeys(ConfigurationKeys.AzureEventHubsBatchLinksEnabled)
.AsBool(defaultValue: true);
AgentFeaturePollingEnabled = config
.WithKeys(ConfigurationKeys.AgentFeaturePollingEnabled)
.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);
InferredProxySpansEnabled = config
.WithKeys(ConfigurationKeys.FeatureFlags.InferredProxySpansEnabled)
.AsBool(defaultValue: false);
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)
.GetAsClassResult(
validator: injectionValidator, // invalid individual values are rejected later
converter: style => TrimSplitString(style, commaSeparator))
.OverrideWith(in otelPropagation, ErrorLog, getDefaultPropagationHeaders);
PropagationStyleExtract = config
.WithKeys(ConfigurationKeys.PropagationStyleExtract)
.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);
PropagationBehaviorExtract = config
.WithKeys(ConfigurationKeys.PropagationBehaviorExtract)
.GetAs(
defaultValue: new(ExtractBehavior.Continue, "continue"),
converter: x => x.ToLowerInvariant() switch
{
"continue" => ExtractBehavior.Continue,
"restart" => ExtractBehavior.Restart,
"ignore" => ExtractBehavior.Ignore,
_ => ParsingResult<ExtractBehavior>.Failure(),
},
validator: null);
BaggageMaximumItems = config
.WithKeys(ConfigurationKeys.BaggageMaximumItems)
.AsInt32(defaultValue: W3CBaggagePropagator.DefaultMaximumBaggageItems);
BaggageMaximumBytes = config
.WithKeys(ConfigurationKeys.BaggageMaximumBytes)
.AsInt32(defaultValue: W3CBaggagePropagator.DefaultMaximumBaggageBytes);
BaggageTagKeys = new HashSet<string>(
config
.WithKeys(ConfigurationKeys.BaggageTagKeys)
.AsString(defaultValue: "user.id,session.id,account.id")
?.Split([','], StringSplitOptions.RemoveEmptyEntries) ?? []);
LogSubmissionSettings = new DirectLogSubmissionSettings(source, telemetry, OpenTelemetryLogsEnabled);
TraceMethods = config
.WithKeys(ConfigurationKeys.TraceMethods)
.AsString(string.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)
.AsString();
IpHeaderEnabled = config
.WithKeys(ConfigurationKeys.IpHeaderEnabled)
.AsBool(false);
// DSM is now enabled by default in non-serverless environments
IsDataStreamsMonitoringEnabled = config
.WithKeys(ConfigurationKeys.DataStreamsMonitoring.Enabled)
.AsBool(
!AwsInfo.Instance.IsAwsLambda &&
!AzureInfo.Instance.IsAzureAppService &&
!AzureInfo.Instance.IsAzureFunction &&
!GcpInfo.Instance.IsCloudFunction);
IsDataStreamsMonitoringInDefaultState = config
.WithKeys(ConfigurationKeys.DataStreamsMonitoring.Enabled)
.AsBool() == null;
// no legacy headers if we are in "enbaled by default" state
IsDataStreamsLegacyHeadersEnabled = config
.WithKeys(ConfigurationKeys.DataStreamsMonitoring.LegacyHeadersEnabled)
.AsBool(!IsDataStreamsMonitoringInDefaultState);
IsRareSamplerEnabled = config
.WithKeys(ConfigurationKeys.RareSamplerEnabled)
.AsBool(false);
StatsComputationEnabled = config
.WithKeys(ConfigurationKeys.StatsComputationEnabled)
.AsBool(false); // default is false, but user config can be overridden below
if (StatsComputationEnabled && !ApmTracingEnabled)
{
// if APM is not enabled, disable stats computation (override user config)
telemetry.Record(ConfigurationKeys.StatsComputationEnabled, value: false, ConfigurationOrigins.Calculated);
StatsComputationEnabled = false;
}
var urlSubstringSkips = config
.WithKeys(ConfigurationKeys.HttpClientExcludedUrlSubstrings)
.AsString(GetDefaultHttpClientExclusions());
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(
defaultValue: new(DbmPropagationLevel.Disabled, nameof(DbmPropagationLevel.Disabled)),
converter: x => ToDbmPropagationInput(x) ?? ParsingResult<DbmPropagationLevel>.Failure(),
validator: null);
DbmInjectSqlBasehash = config
.WithKeys(ConfigurationKeys.DbmInjectSqlBasehash)
.AsBool(false);
RemoteConfigurationEnabled = config.WithKeys(ConfigurationKeys.Rcm.RemoteConfigurationEnabled).AsBool(true);
TraceId128BitGenerationEnabled = config
.WithKeys(ConfigurationKeys.FeatureFlags.TraceId128BitGenerationEnabled)
.AsBool(true);
TraceId128BitLoggingEnabled = config
.WithKeys(ConfigurationKeys.FeatureFlags.TraceId128BitLoggingEnabled)
.AsBool(TraceId128BitGenerationEnabled);
CommandsCollectionEnabled = config
.WithKeys(ConfigurationKeys.FeatureFlags.CommandsCollectionEnabled)
.AsBool(false);
BypassHttpRequestUrlCachingEnabled = config.WithKeys(ConfigurationKeys.FeatureFlags.BypassHttpRequestUrlCachingEnabled)
.AsBool(false);
InjectContextIntoStoredProceduresEnabled = config.WithKeys(ConfigurationKeys.FeatureFlags.InjectContextIntoStoredProceduresEnabled)
.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);
}
IsFlaggingProviderEnabled = config.WithKeys(ConfigurationKeys.FeatureFlags.FlaggingProviderEnabled)
.AsBool(false);
if (source is CompositeConfigurationSource compositeSource)
{
foreach (var nestedSource in compositeSource)
{
if (nestedSource is JsonConfigurationSource { JsonConfigurationFilePath: { } jsonFilePath }
&& !string.IsNullOrEmpty(jsonFilePath))
{
JsonConfigurationFilePaths.Add(jsonFilePath);
}
}
}
OpenTelemetryMetricsEnabled = config
.WithKeys(ConfigurationKeys.FeatureFlags.OpenTelemetryMetricsEnabled)
.AsBool(defaultValue: false);
var enabledMeters = config.WithKeys(ConfigurationKeys.FeatureFlags.OpenTelemetryMeterNames).AsString();
OpenTelemetryMeterNames = !string.IsNullOrEmpty(enabledMeters)
? new HashSet<string>(TrimSplitString(enabledMeters, commaSeparator), StringComparer.Ordinal)
: new HashSet<string>(StringComparer.Ordinal);
var disabledActivitySources = config.WithKeys(ConfigurationKeys.DisabledActivitySources).AsString();
DisabledActivitySources = !string.IsNullOrEmpty(disabledActivitySources) ? TrimSplitString(disabledActivitySources, commaSeparator) : [];
// 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(ConfigurationKeys.SsiDeployed), recordValue: true, ConfigurationOrigins.EnvVars);
telemetry.Record(ConfigTelemetryData.SsiAllowUnsupportedRuntimesEnabled, value: EnvironmentHelpers.GetEnvironmentVariable(ConfigurationKeys.InjectForce), recordValue: true, ConfigurationOrigins.EnvVars);
var installType = EnvironmentHelpers.GetEnvironmentVariable(ConfigurationKeys.Telemetry.InstrumentationInstallType);
var instrumentationSource = installType switch
{
"dd_dotnet_launcher" => "cmd_line",
"dd_trace_tool" => "cmd_line",
"dotnet_msi" => "env_var",
"windows_fleet_installer" => "ssi", // windows SSI on IIS
_ when !string.IsNullOrEmpty(EnvironmentHelpers.GetEnvironmentVariable(ConfigurationKeys.SsiDeployed)) => "ssi", // "normal" ssi
_ => "manual" // everything else
};
telemetry.Record(ConfigTelemetryData.InstrumentationSource, instrumentationSource, recordValue: true, ConfigurationOrigins.Calculated);
#if NET6_0_OR_GREATER
var trimState = TrimmingDetector.DetectedTrimmingState;
var invalidTrimming = trimState == TrimmingDetector.TrimState.TrimmedAppMissingTrimmingFile;
var isTrimmed = invalidTrimming || trimState == TrimmingDetector.TrimState.TrimmedAppUsingTrimmingFile;
telemetry.Record(ConfigTelemetryData.TrimmedAppDetected, isTrimmed, ConfigurationOrigins.Calculated);
telemetry.Record(ConfigTelemetryData.TrimmedAppMissingTrimmingFile, invalidTrimming, ConfigurationOrigins.Calculated);
#endif
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);
}
PartialFlushEnabled = config.WithKeys(ConfigurationKeys.PartialFlushEnabled).AsBool(false);
PartialFlushMinSpans = config
.WithKeys(ConfigurationKeys.PartialFlushMinSpans)
.AsInt32(500, value => value > 0).Value;
GraphQLErrorExtensions = TrimSplitString(
config.WithKeys(ConfigurationKeys.GraphQLErrorExtensions).AsString(),
commaSeparator);
// We create a lazy here because this is kind of expensive, and we want to avoid calling it if we can
_fallbackApplicationName = new(() => ApplicationNameHelpers.GetFallbackApplicationName(this));
// There's a circular dependency here because DataPipeline depends on ExporterSettings,
// but the settings manager depends on TracerSettings. Basically this is all fine as long
// as nothing in the MutableSettings or ExporterSettings depends on the value of DataPipelineEnabled!
Manager = new(source, this, telemetry, errorLog);
DataPipelineEnabled = config
.WithKeys(ConfigurationKeys.TraceDataPipelineEnabled)
.AsBool(defaultValue: false);
if (DataPipelineEnabled)
{
// Due to missing quantization and obfuscation in native side, we can't enable the native trace exporter
// as it may lead to different stats results than the managed one.
if (StatsComputationEnabled)
{
DataPipelineEnabled = false;
Log.Warning(
$"{ConfigurationKeys.TraceDataPipelineEnabled} is enabled, but {ConfigurationKeys.StatsComputationEnabled} is enabled. Disabling data pipeline.");
telemetry.Record(ConfigurationKeys.TraceDataPipelineEnabled, false, ConfigurationOrigins.Calculated);
}
// Windows supports UnixDomainSocket https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/
// but tokio hasn't added support for it yet https://github.com/tokio-rs/tokio/issues/2201
// There's an issue here, in that technically a user can initially be configured to send over TCP/named pipes,
// and so we allow and enable the datapipeline. Later, they could configure the app in code to send over UDS.
// This is a problem, as we currently don't support toggling the data pipeline at runtime, so we explicitly block
// this scenario in the public API.
if (Manager.InitialExporterSettings.TracesTransport == TracesTransportType.UnixDomainSocket && FrameworkDescription.Instance.IsWindows())
{
DataPipelineEnabled = false;
Log.Warning(
$"{ConfigurationKeys.TraceDataPipelineEnabled} is enabled, but TracesTransport is set to UnixDomainSocket which is not supported on Windows. Disabling data pipeline.");
telemetry.Record(ConfigurationKeys.TraceDataPipelineEnabled, false, ConfigurationOrigins.Calculated);
}
if (!isLibDatadogAvailable.IsAvailable)
{
DataPipelineEnabled = false;
if (isLibDatadogAvailable.Exception is not null)
{
Log.Warning(
isLibDatadogAvailable.Exception,
$"{ConfigurationKeys.TraceDataPipelineEnabled} is enabled, but libdatadog is not available. Disabling data pipeline.");
}
else
{
Log.Warning(
$"{ConfigurationKeys.TraceDataPipelineEnabled} is enabled, but libdatadog is not available. Disabling data pipeline.");
}
telemetry.Record(ConfigurationKeys.TraceDataPipelineEnabled, false, ConfigurationOrigins.Calculated);
}
// SSI already utilizes libdatadog. To prevent unexpected behavior,
// we proactively disable the data pipeline when SSI is enabled. Theoretically, this should not cause any issues,
// but as a precaution, we are taking a conservative approach during the initial rollout phase.
if (!string.IsNullOrEmpty(EnvironmentHelpers.GetEnvironmentVariable(ConfigurationKeys.SsiDeployed)))
{
DataPipelineEnabled = false;
Log.Warning(
$"{ConfigurationKeys.TraceDataPipelineEnabled} is enabled, but SSI is enabled. Disabling data pipeline.");
telemetry.Record(ConfigurationKeys.TraceDataPipelineEnabled, false, ConfigurationOrigins.Calculated);
}
}
}
internal bool IsRunningInCiVisibility { get; }
internal HashSet<string> ExperimentalFeaturesEnabled { get; }
internal bool PropagateProcessTags { get; }
internal OverrideErrorLog ErrorLog { get; }
internal string FallbackApplicationName => _fallbackApplicationName.Value;
/// <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 APM traces are enabled.
/// Default is <c>true</c>.
/// </summary>
/// <seealso cref="ConfigurationKeys.ApmTracingEnabled"/>
internal bool ApmTracingEnabled { get; }
/// <summary>
/// Gets a value indicating whether OpenTelemetry Metrics are enabled.
/// </summary>
/// <seealso cref="ConfigurationKeys.FeatureFlags.OpenTelemetryMetricsEnabled"/>
internal bool OpenTelemetryMetricsEnabled { get; }
/// Gets the names of enabled Meters.
/// <seealso cref="ConfigurationKeys.FeatureFlags.OpenTelemetryMeterNames"/>
internal HashSet<string> OpenTelemetryMeterNames { get; }
/// <summary>
/// Gets a value indicating whether the OpenTelemetry metrics exporter is enabled.
/// This is derived from <see cref="ConfigurationKeys.OpenTelemetry.MetricsExporter"/> config where 'otlp' enables the exporter
/// and 'none' disables it and runtime metrics if related DD env var is not set.
/// Default is enabled (true).
/// </summary>
internal bool OtelMetricsExporterEnabled { get; }
/// <summary>
/// Gets the OTLP protocol for metrics export with fallback behavior.
/// </summary>
/// <seealso cref="ConfigurationKeys.OpenTelemetry.ExporterOtlpMetricsProtocol"/>
/// <seealso cref="ConfigurationKeys.OpenTelemetry.ExporterOtlpProtocol"/>
internal OtlpProtocol OtlpMetricsProtocol { get; }
/// <summary>
/// Gets the OTLP endpoint URL for metrics export fallbacks on <see cref="OtlpEndpoint"/>.
/// </summary>
/// <seealso cref="ConfigurationKeys.OpenTelemetry.ExporterOtlpMetricsEndpoint"/>
internal Uri OtlpMetricsEndpoint { get; }
/// <summary>
/// Gets the OTLP base endpoint URL for otlp export.
/// </summary>
/// <seealso cref="ConfigurationKeys.OpenTelemetry.ExporterOtlpEndpoint"/>
internal Uri OtlpEndpoint { get; }
/// <summary>
/// Gets the OTLP headers for metrics export with fallback behavior.
/// Parsed from comma-separated key-value pairs (api-key=key,other=value).
/// </summary>
/// <seealso cref="ConfigurationKeys.OpenTelemetry.ExporterOtlpMetricsHeaders"/>
/// <seealso cref="ConfigurationKeys.OpenTelemetry.ExporterOtlpHeaders"/>
internal IReadOnlyDictionary<string, string> OtlpMetricsHeaders { get; }
/// <summary>
/// Gets the OpenTelemetry metric export interval (in milliseconds) between export attempts.
/// Default is 10000ms (10s) for Datadog - deviates from OTel spec default of 60000ms (60s).
/// </summary>
/// <seealso cref="ConfigurationKeys.OpenTelemetry.MetricExportIntervalMs"/>
internal int OtelMetricExportIntervalMs { get; }
/// <summary>
/// Gets the OpenTelemetry metric export timeout (in milliseconds) for collection and export.
/// Default is 7500ms (7.5s) for Datadog - deviates from OTel spec default of 30000ms (30s).
/// </summary>
/// <seealso cref="ConfigurationKeys.OpenTelemetry.MetricExportTimeoutMs"/>
internal int OtelMetricExportTimeoutMs { get; }
/// <summary>
/// Gets the OTLP request timeout (in milliseconds).
/// Default is 10000ms (10s).
/// </summary>
/// <seealso cref="ConfigurationKeys.OpenTelemetry.ExporterOtlpMetricsTimeoutMs"/>
/// <seealso cref="ConfigurationKeys.OpenTelemetry.ExporterOtlpTimeoutMs"/>
internal int OtlpMetricsTimeoutMs { get; }
/// <summary>
/// Gets the OTLP metrics temporality preference.
/// Default is 'delta' for Datadog - deviates from OTel spec default of 'cumulative'.
/// </summary>
/// <seealso cref="ConfigurationKeys.OpenTelemetry.ExporterOtlpMetricsTemporalityPreference"/>
internal OtlpTemporalityPreference OtlpMetricsTemporalityPreference { get; }
/// <summary>
/// Gets a value indicating whether the OpenTelemetry metrics exporter is enabled.
/// This is derived from <see cref="ConfigurationKeys.OpenTelemetry.LogsExporter"/> config where 'otlp' enables the exporter
/// and 'none' disables it and runtime metrics if related DD env var is not set.
/// Default is enabled (true).
/// </summary>
internal bool OtelLogsExporterEnabled { get; }
/// <summary>
/// Gets a value indicating whether Datadog's OTLP logs feature is enabled.
/// This is set via DD_LOGS_OTEL_ENABLED (parallel to DD_METRICS_OTEL_ENABLED).
/// Default is disabled (false).
/// </summary>
/// <seealso cref="ConfigurationKeys.FeatureFlags.OpenTelemetryLogsEnabled"/>
internal bool OpenTelemetryLogsEnabled { get; }
/// <summary>
/// Gets the OTLP protocol for logs export with fallback behavior.
/// </summary>
/// <seealso cref="ConfigurationKeys.OpenTelemetry.ExporterOtlpLogsProtocol"/>
/// <seealso cref="ConfigurationKeys.OpenTelemetry.ExporterOtlpProtocol"/>
internal OtlpProtocol OtlpLogsProtocol { get; }
/// <summary>
/// Gets the OTLP endpoint URL for logs export fallbacks on <see cref="OtlpEndpoint"/>.
/// </summary>
/// <seealso cref="ConfigurationKeys.OpenTelemetry.ExporterOtlpLogsEndpoint"/>
internal Uri OtlpLogsEndpoint { get; }
/// <summary>
/// Gets the OTLP headers for logs export with fallback behavior.
/// Parsed from comma-separated key-value pairs (api-key=key,other=value).
/// </summary>
/// <seealso cref="ConfigurationKeys.OpenTelemetry.ExporterOtlpLogsHeaders"/>
/// <seealso cref="ConfigurationKeys.OpenTelemetry.ExporterOtlpHeaders"/>
internal IReadOnlyDictionary<string, string> OtlpLogsHeaders { get; }
/// <summary>
/// Gets the OTLP request timeout (in milliseconds) for logs.
/// Default is 10000ms (10s).
/// </summary>
/// <seealso cref="ConfigurationKeys.OpenTelemetry.ExporterOtlpLogsTimeoutMs"/>
/// <seealso cref="ConfigurationKeys.OpenTelemetry.ExporterOtlpTimeoutMs"/>
internal int OtlpLogsTimeoutMs { get; }
/// <summary>
/// Gets the non siganl specific OTLP protocol.
/// </summary>
/// <seealso cref="ConfigurationKeys.OpenTelemetry.ExporterOtlpProtocol"/>
internal OtlpProtocol OtlpGeneralProtocol { get; }
/// <summary>
/// Gets the names of disabled ActivitySources.
/// </summary>
/// <seealso cref="ConfigurationKeys.DisabledActivitySources"/>
internal string[] DisabledActivitySources { get; }
/// <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 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 a value indicating whether stats are computed on the tracer side
/// </summary>
public bool StatsComputationEnabled { get; }
/// <summary>
/// Gets a value indicating whether to enable span linking for individual messages
/// when using Azure Service Bus batch operations.
/// </summary>
/// <seealso cref="ConfigurationKeys.AzureServiceBusBatchLinksEnabled"/>
public bool AzureServiceBusBatchLinksEnabled { get; }