-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathenv.rs
More file actions
1262 lines (1173 loc) · 54.1 KB
/
env.rs
File metadata and controls
1262 lines (1173 loc) · 54.1 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
use figment::{Figment, providers::Env};
use serde::Deserialize;
use std::collections::HashMap;
use std::time::Duration;
use dogstatsd::util::parse_metric_namespace;
use libdd_trace_obfuscation::replacer::ReplaceRule;
use crate::{
config::{
Config, ConfigError, ConfigSource,
additional_endpoints::deserialize_additional_endpoints,
apm_replace_rule::deserialize_apm_replace_rules,
deserialize_apm_filter_tags, deserialize_array_from_comma_separated_string,
deserialize_key_value_pairs, deserialize_option_lossless,
deserialize_optional_bool_from_anything, deserialize_optional_duration_from_microseconds,
deserialize_optional_duration_from_seconds,
deserialize_optional_duration_from_seconds_ignore_zero, deserialize_optional_string,
deserialize_string_or_int,
flush_strategy::FlushStrategy,
log_level::LogLevel,
logs_additional_endpoints::{
LogsAdditionalEndpoint, deserialize_logs_additional_endpoints,
},
processing_rule::{ProcessingRule, deserialize_processing_rules},
service_mapping::deserialize_service_mapping,
trace_propagation_style::deserialize_trace_propagation_style,
},
merge_hashmap, merge_option, merge_option_to_value, merge_string, merge_vec,
};
use datadog_opentelemetry::propagation::TracePropagationStyle;
#[derive(Debug, PartialEq, Deserialize, Clone, Default)]
#[serde(default)]
#[allow(clippy::struct_excessive_bools)]
#[allow(clippy::module_name_repetitions)]
pub struct EnvConfig {
/// @env `DD_SITE`
///
/// The Datadog site to send telemetry to
#[serde(deserialize_with = "deserialize_optional_string")]
pub site: Option<String>,
/// @env `DD_API_KEY`
///
/// The Datadog API key used to submit telemetry to Datadog
#[serde(deserialize_with = "deserialize_optional_string")]
pub api_key: Option<String>,
/// @env `DD_LOG_LEVEL`
///
/// Minimum log level of the Datadog Agent.
/// Valid log levels are: trace, debug, info, warn, and error.
pub log_level: Option<LogLevel>,
/// @env `DD_FLUSH_TIMEOUT`
///
/// Flush timeout in seconds
/// todo(duncanista): find out where this comes from
/// todo(?): go agent adds jitter too
#[serde(deserialize_with = "deserialize_option_lossless")]
pub flush_timeout: Option<u64>,
// Proxy
/// @env `DD_PROXY_HTTPS`
///
/// Proxy endpoint for HTTPS connections (most Datadog traffic)
#[serde(deserialize_with = "deserialize_optional_string")]
pub proxy_https: Option<String>,
/// @env `DD_PROXY_NO_PROXY`
///
/// Specify hosts the Agent should connect to directly, bypassing the proxy.
#[serde(deserialize_with = "deserialize_array_from_comma_separated_string")]
pub proxy_no_proxy: Vec<String>,
/// @env `DD_HTTP_PROTOCOL`
///
/// The HTTP protocol to use for the Datadog Agent.
/// The transport type to use for sending logs. Possible values are "auto" or "http1".
#[serde(deserialize_with = "deserialize_optional_string")]
pub http_protocol: Option<String>,
/// @env `DD_TLS_CERT_FILE`
/// The path to a file of concatenated CA certificates in PEM format.
/// Example: `/opt/ca-cert.pem`
#[serde(deserialize_with = "deserialize_optional_string")]
pub tls_cert_file: Option<String>,
/// @env `DD_SKIP_SSL_VALIDATION`
///
/// If set to true, the Agent will skip TLS certificate validation for outgoing connections.
#[serde(deserialize_with = "deserialize_optional_bool_from_anything")]
pub skip_ssl_validation: Option<bool>,
// Metrics
/// @env `DD_DD_URL`
///
/// @default `https://app.datadoghq.com`
///
/// The host of the Datadog intake server to send **metrics** to, only set this option
/// if you need the Agent to send **metrics** to a custom URL, it overrides the site
/// setting defined in "site". It does not affect APM, Logs, Remote Configuration,
/// or Live Process intake which have their own "*_`dd_url`" settings.
///
/// If `DD_DD_URL` and `DD_URL` are both set, `DD_DD_URL` is used in priority.
#[serde(deserialize_with = "deserialize_optional_string")]
pub dd_url: Option<String>,
/// @env `DD_URL`
///
/// @default `https://app.datadoghq.com`
#[serde(deserialize_with = "deserialize_optional_string")]
pub url: Option<String>,
/// @env `DD_ADDITIONAL_ENDPOINTS`
///
/// Additional endpoints to send metrics to.
/// <https://docs.datadoghq.com/agent/configuration/dual-shipping/?tab=helm#environment-variable-configuration>
#[serde(deserialize_with = "deserialize_additional_endpoints")]
pub additional_endpoints: HashMap<String, Vec<String>>,
// Unified Service Tagging
/// @env `DD_ENV`
///
/// The environment name where the agent is running. Attached in-app to every
/// metric, event, log, trace, and service check emitted by this Agent.
#[serde(deserialize_with = "deserialize_string_or_int")]
pub env: Option<String>,
/// @env `DD_SERVICE`
#[serde(deserialize_with = "deserialize_string_or_int")]
pub service: Option<String>,
/// @env `DD_VERSION`
#[serde(deserialize_with = "deserialize_string_or_int")]
pub version: Option<String>,
/// @env `DD_TAGS`
#[serde(deserialize_with = "deserialize_key_value_pairs")]
pub tags: HashMap<String, String>,
/// @env `DD_COMPRESSION_LEVEL`
///
/// Global level `compression_level` parameter accepts values from 0 (no compression)
/// to 9 (maximum compression but higher resource usage). This value is effective only if
/// the individual component doesn't specify its own.
#[serde(deserialize_with = "deserialize_option_lossless")]
pub compression_level: Option<i32>,
// Logs
/// @env `DD_LOGS_CONFIG_LOGS_DD_URL`
///
/// Define the endpoint and port to hit when using a proxy for logs.
#[serde(deserialize_with = "deserialize_optional_string")]
pub logs_config_logs_dd_url: Option<String>,
/// @env `DD_LOGS_CONFIG_PROCESSING_RULES`
///
/// Global processing rules that are applied to all logs. The available rules are
/// "`exclude_at_match`", "`include_at_match`" and "`mask_sequences`". More information in Datadog documentation:
/// <https://docs.datadoghq.com/agent/logs/advanced_log_collection/#global-processing-rules>
#[serde(deserialize_with = "deserialize_processing_rules")]
pub logs_config_processing_rules: Option<Vec<ProcessingRule>>,
/// @env `DD_LOGS_CONFIG_USE_COMPRESSION`
///
/// If enabled, the Agent compresses logs before sending them.
#[serde(deserialize_with = "deserialize_optional_bool_from_anything")]
pub logs_config_use_compression: Option<bool>,
/// @env `DD_LOGS_CONFIG_COMPRESSION_LEVEL`
///
/// The `compression_level` parameter accepts values from 0 (no compression)
/// to 9 (maximum compression but higher resource usage). Only takes effect if
/// `use_compression` is set to `true`.
#[serde(deserialize_with = "deserialize_option_lossless")]
pub logs_config_compression_level: Option<i32>,
/// @env `DD_LOGS_CONFIG_ADDITIONAL_ENDPOINTS`
///
/// Additional endpoints to send logs to.
/// <https://docs.datadoghq.com/agent/configuration/dual-shipping/?tab=helm#environment-variable-configuration-6>
#[serde(deserialize_with = "deserialize_logs_additional_endpoints")]
pub logs_config_additional_endpoints: Vec<LogsAdditionalEndpoint>,
/// @env `DD_OBSERVABILITY_PIPELINES_WORKER_LOGS_ENABLED`
/// When true, emit plain json suitable for Observability Pipelines
#[serde(deserialize_with = "deserialize_optional_bool_from_anything")]
pub observability_pipelines_worker_logs_enabled: Option<bool>,
/// @env `DD_OBSERVABILITY_PIPELINES_WORKER_LOGS_URL`
///
/// The URL endpoint for sending logs to Observability Pipelines Worker
#[serde(deserialize_with = "deserialize_optional_string")]
pub observability_pipelines_worker_logs_url: Option<String>,
// APM
//
/// @env `DD_SERVICE_MAPPING`
#[serde(deserialize_with = "deserialize_service_mapping")]
pub service_mapping: HashMap<String, String>,
//
/// @env `DD_APM_DD_URL`
///
/// Define the endpoint and port to hit when using a proxy for APM.
#[serde(deserialize_with = "deserialize_optional_string")]
pub apm_dd_url: Option<String>,
/// @env `DD_APM_REPLACE_TAGS`
///
/// Defines a set of rules to replace or remove certain resources, tags containing
/// potentially sensitive information.
/// Each rule has to contain:
/// * name - string - The tag name to replace, for resources use "resource.name".
/// * pattern - string - The pattern to match the desired content to replace
/// * repl - string - what to inline if the pattern is matched
///
/// <https://docs.datadoghq.com/tracing/setup_overview/configure_data_security/#replace-rules-for-tag-filtering>
#[serde(deserialize_with = "deserialize_apm_replace_rules")]
pub apm_replace_tags: Option<Vec<ReplaceRule>>,
/// @env `DD_APM_CONFIG_OBFUSCATION_HTTP_REMOVE_QUERY_STRING`
#[serde(deserialize_with = "deserialize_optional_bool_from_anything")]
pub apm_config_obfuscation_http_remove_query_string: Option<bool>,
/// @env `DD_APM_CONFIG_OBFUSCATION_HTTP_REMOVE_PATHS_WITH_DIGITS`
#[serde(deserialize_with = "deserialize_optional_bool_from_anything")]
pub apm_config_obfuscation_http_remove_paths_with_digits: Option<bool>,
/// @env `DD_APM_CONFIG_COMPRESSION_LEVEL`
///
/// The Agent compresses traces before sending them. The `compression_level` parameter
/// accepts values from 0 (no compression) to 9 (maximum compression but
/// higher resource usage).
#[serde(deserialize_with = "deserialize_option_lossless")]
pub apm_config_compression_level: Option<i32>,
/// @env `DD_APM_FEATURES`
#[serde(deserialize_with = "deserialize_array_from_comma_separated_string")]
pub apm_features: Vec<String>,
/// @env `DD_APM_ADDITIONAL_ENDPOINTS`
///
/// Additional endpoints to send traces to.
/// <https://docs.datadoghq.com/agent/configuration/dual-shipping/?tab=helm#environment-variable-configuration-1>
#[serde(deserialize_with = "deserialize_additional_endpoints")]
pub apm_additional_endpoints: HashMap<String, Vec<String>>,
/// @env `DD_APM_FILTER_TAGS_REQUIRE`
///
/// Space-separated list of key:value tag pairs that spans must match to be kept.
/// Only spans matching at least one of these tags will be sent to Datadog.
/// Example: "env:production service:api-gateway"
#[serde(deserialize_with = "deserialize_apm_filter_tags")]
pub apm_filter_tags_require: Option<Vec<String>>,
/// @env `DD_APM_FILTER_TAGS_REJECT`
///
/// Space-separated list of key:value tag pairs that will cause spans to be filtered out.
/// Spans matching any of these tags will be dropped.
/// Example: "env:development debug:true name:health.check"
#[serde(deserialize_with = "deserialize_apm_filter_tags")]
pub apm_filter_tags_reject: Option<Vec<String>>,
/// @env `DD_APM_FILTER_TAGS_REGEX_REQUIRE`
///
/// Space-separated list of key:value tag pairs with regex values that spans must match to be kept.
/// Only spans matching at least one of these regex patterns will be sent to Datadog.
/// Example: "env:^prod.*$ service:^api-.*$"
#[serde(deserialize_with = "deserialize_apm_filter_tags")]
pub apm_filter_tags_regex_require: Option<Vec<String>>,
/// @env `DD_APM_FILTER_TAGS_REGEX_REJECT`
///
/// Space-separated list of key:value tag pairs with regex values that will cause spans to be filtered out.
/// Spans matching any of these regex patterns will be dropped.
/// Example: "env:^test.*$ debug:^true$"
#[serde(deserialize_with = "deserialize_apm_filter_tags")]
pub apm_filter_tags_regex_reject: Option<Vec<String>>,
/// @env `DD_TRACE_AWS_SERVICE_REPRESENTATION_ENABLED`
///
/// Enable the new AWS-resource naming logic in the tracer.
#[serde(deserialize_with = "deserialize_optional_bool_from_anything")]
pub trace_aws_service_representation_enabled: Option<bool>,
//
// Trace Propagation
/// @env `DD_TRACE_PROPAGATION_STYLE`
#[serde(deserialize_with = "deserialize_trace_propagation_style")]
pub trace_propagation_style: Vec<TracePropagationStyle>,
/// @env `DD_TRACE_PROPAGATION_STYLE_EXTRACT`
#[serde(deserialize_with = "deserialize_trace_propagation_style")]
pub trace_propagation_style_extract: Vec<TracePropagationStyle>,
/// @env `DD_TRACE_PROPAGATION_EXTRACT_FIRST`
#[serde(deserialize_with = "deserialize_optional_bool_from_anything")]
pub trace_propagation_extract_first: Option<bool>,
/// @env `DD_TRACE_PROPAGATION_HTTP_BAGGAGE_ENABLED`
#[serde(deserialize_with = "deserialize_optional_bool_from_anything")]
pub trace_propagation_http_baggage_enabled: Option<bool>,
/// @env `DD_METRICS_CONFIG_COMPRESSION_LEVEL`
/// The metrics compresses traces before sending them. The `compression_level` parameter
/// accepts values from 0 (no compression) to 9 (maximum compression but
/// higher resource usage).
#[serde(deserialize_with = "deserialize_option_lossless")]
pub metrics_config_compression_level: Option<i32>,
/// @env `DD_STATSD_METRIC_NAMESPACE`
/// Prefix all `StatsD` metrics with a namespace.
#[serde(deserialize_with = "deserialize_optional_string")]
pub statsd_metric_namespace: Option<String>,
/// @env `DD_DOGSTATSD_SO_RCVBUF`
/// Size of the receive buffer for `DogStatsD` UDP packets, in bytes (`SO_RCVBUF`).
/// Increase to reduce packet loss under high-throughput metric bursts.
#[serde(deserialize_with = "deserialize_option_lossless")]
pub dogstatsd_so_rcvbuf: Option<usize>,
/// @env `DD_DOGSTATSD_BUFFER_SIZE`
/// Maximum size of a single read from any transport (UDP or named pipe), in bytes.
/// Defaults to 8192.
#[serde(deserialize_with = "deserialize_option_lossless")]
pub dogstatsd_buffer_size: Option<usize>,
/// @env `DD_DOGSTATSD_QUEUE_SIZE`
/// Internal queue capacity between the socket reader and metric processor.
/// Defaults to 1024. Increase if the processor can't keep up with burst traffic.
#[serde(deserialize_with = "deserialize_option_lossless")]
pub dogstatsd_queue_size: Option<usize>,
// OTLP
//
// - APM / Traces
/// @env `DD_OTLP_CONFIG_TRACES_ENABLED`
#[serde(deserialize_with = "deserialize_optional_bool_from_anything")]
pub otlp_config_traces_enabled: Option<bool>,
/// @env `DD_OTLP_CONFIG_TRACES_SPAN_NAME_AS_RESOURCE_NAME`
#[serde(deserialize_with = "deserialize_optional_bool_from_anything")]
pub otlp_config_traces_span_name_as_resource_name: Option<bool>,
/// @env `DD_OTLP_CONFIG_TRACES_SPAN_NAME_REMAPPINGS`
#[serde(deserialize_with = "deserialize_key_value_pairs")]
pub otlp_config_traces_span_name_remappings: HashMap<String, String>,
/// @env `DD_OTLP_CONFIG_IGNORE_MISSING_DATADOG_FIELDS`
#[serde(deserialize_with = "deserialize_optional_bool_from_anything")]
pub otlp_config_ignore_missing_datadog_fields: Option<bool>,
//
// - Receiver / HTTP
/// @env `DD_OTLP_CONFIG_RECEIVER_PROTOCOLS_HTTP_ENDPOINT`
#[serde(deserialize_with = "deserialize_optional_string")]
pub otlp_config_receiver_protocols_http_endpoint: Option<String>,
// - Unsupported Configuration
//
// - Receiver / GRPC
/// @env `DD_OTLP_CONFIG_RECEIVER_PROTOCOLS_GRPC_ENDPOINT`
#[serde(deserialize_with = "deserialize_optional_string")]
pub otlp_config_receiver_protocols_grpc_endpoint: Option<String>,
/// @env `DD_OTLP_CONFIG_RECEIVER_PROTOCOLS_GRPC_TRANSPORT`
#[serde(deserialize_with = "deserialize_optional_string")]
pub otlp_config_receiver_protocols_grpc_transport: Option<String>,
/// @env `DD_OTLP_CONFIG_RECEIVER_PROTOCOLS_GRPC_MAX_RECV_MSG_SIZE_MIB`
#[serde(deserialize_with = "deserialize_option_lossless")]
pub otlp_config_receiver_protocols_grpc_max_recv_msg_size_mib: Option<i32>,
// - Metrics
/// @env `DD_OTLP_CONFIG_METRICS_ENABLED`
#[serde(deserialize_with = "deserialize_optional_bool_from_anything")]
pub otlp_config_metrics_enabled: Option<bool>,
/// @env `DD_OTLP_CONFIG_METRICS_RESOURCE_ATTRIBUTES_AS_TAGS`
#[serde(deserialize_with = "deserialize_optional_bool_from_anything")]
pub otlp_config_metrics_resource_attributes_as_tags: Option<bool>,
/// @env `DD_OTLP_CONFIG_METRICS_INSTRUMENTATION_SCOPE_METADATA_AS_TAGS`
#[serde(deserialize_with = "deserialize_optional_bool_from_anything")]
pub otlp_config_metrics_instrumentation_scope_metadata_as_tags: Option<bool>,
/// @env `DD_OTLP_CONFIG_METRICS_TAG_CARDINALITY`
#[serde(deserialize_with = "deserialize_optional_string")]
pub otlp_config_metrics_tag_cardinality: Option<String>,
/// @env `DD_OTLP_CONFIG_METRICS_DELTA_TTL`
#[serde(deserialize_with = "deserialize_option_lossless")]
pub otlp_config_metrics_delta_ttl: Option<i32>,
/// @env `DD_OTLP_CONFIG_METRICS_HISTOGRAMS_MODE`
#[serde(deserialize_with = "deserialize_optional_string")]
pub otlp_config_metrics_histograms_mode: Option<String>,
/// @env `DD_OTLP_CONFIG_METRICS_HISTOGRAMS_SEND_COUNT_SUM_METRICS`
#[serde(deserialize_with = "deserialize_optional_bool_from_anything")]
pub otlp_config_metrics_histograms_send_count_sum_metrics: Option<bool>,
/// @env `DD_OTLP_CONFIG_METRICS_HISTOGRAMS_SEND_AGGREGATION_METRICS`
#[serde(deserialize_with = "deserialize_optional_bool_from_anything")]
pub otlp_config_metrics_histograms_send_aggregation_metrics: Option<bool>,
#[serde(deserialize_with = "deserialize_optional_string")]
pub otlp_config_metrics_sums_cumulative_monotonic_mode: Option<String>,
/// @env `DD_OTLP_CONFIG_METRICS_SUMS_INITIAL_CUMULATIVE_MONOTONIC_VALUE`
#[serde(deserialize_with = "deserialize_optional_string")]
pub otlp_config_metrics_sums_initial_cumulativ_monotonic_value: Option<String>,
/// @env `DD_OTLP_CONFIG_METRICS_SUMMARIES_MODE`
#[serde(deserialize_with = "deserialize_optional_string")]
pub otlp_config_metrics_summaries_mode: Option<String>,
// - Traces
/// @env `DD_OTLP_CONFIG_TRACES_PROBABILISTIC_SAMPLER_SAMPLING_PERCENTAGE`
#[serde(deserialize_with = "deserialize_option_lossless")]
pub otlp_config_traces_probabilistic_sampler_sampling_percentage: Option<i32>,
// - Logs
/// @env `DD_OTLP_CONFIG_LOGS_ENABLED`
#[serde(deserialize_with = "deserialize_optional_bool_from_anything")]
pub otlp_config_logs_enabled: Option<bool>,
// AWS Lambda
/// @env `DD_API_KEY_SECRET_ARN`
///
/// The AWS ARN of the secret containing the Datadog API key.
#[serde(deserialize_with = "deserialize_optional_string")]
pub api_key_secret_arn: Option<String>,
/// @env `DD_KMS_API_KEY`
///
/// The AWS KMS API key to use for the Datadog Agent.
#[serde(deserialize_with = "deserialize_optional_string")]
pub kms_api_key: Option<String>,
/// @env `DD_API_KEY_SSM_ARN`
///
/// The AWS Systems Manager Parameter Store parameter ARN containing the Datadog API key.
#[serde(deserialize_with = "deserialize_optional_string")]
pub api_key_ssm_arn: Option<String>,
/// @env `DD_SERVERLESS_LOGS_ENABLED`
///
/// Enable logs for AWS Lambda. Default is `true`.
#[serde(deserialize_with = "deserialize_optional_bool_from_anything")]
pub serverless_logs_enabled: Option<bool>,
/// @env `DD_LOGS_ENABLED`
///
/// Enable logs for AWS Lambda. Alias for `DD_SERVERLESS_LOGS_ENABLED`. Default is `true`.
#[serde(deserialize_with = "deserialize_optional_bool_from_anything")]
pub logs_enabled: Option<bool>,
/// @env `DD_SERVERLESS_FLUSH_STRATEGY`
///
/// The flush strategy to use for AWS Lambda.
pub serverless_flush_strategy: Option<FlushStrategy>,
/// @env `DD_ENHANCED_METRICS`
///
/// Enable enhanced metrics for AWS Lambda. Default is `true`.
#[serde(deserialize_with = "deserialize_optional_bool_from_anything")]
pub enhanced_metrics: Option<bool>,
/// @env `DD_LAMBDA_PROC_ENHANCED_METRICS`
///
/// Enable Lambda process metrics for AWS Lambda. Default is `true`.
///
/// This is for metrics like:
/// - CPU usage
/// - Network usage
/// - File descriptor count
/// - Thread count
/// - Temp directory usage
#[serde(deserialize_with = "deserialize_optional_bool_from_anything")]
pub lambda_proc_enhanced_metrics: Option<bool>,
/// @env `DD_CAPTURE_LAMBDA_PAYLOAD`
///
/// Enable capture of the Lambda request and response payloads.
/// Default is `false`.
#[serde(deserialize_with = "deserialize_optional_bool_from_anything")]
pub capture_lambda_payload: Option<bool>,
/// @env `DD_CAPTURE_LAMBDA_PAYLOAD_MAX_DEPTH`
///
/// The maximum depth of the Lambda payload to capture.
/// Default is `10`. Requires `capture_lambda_payload` to be `true`.
#[serde(deserialize_with = "deserialize_option_lossless")]
pub capture_lambda_payload_max_depth: Option<u32>,
/// @env `DD_COMPUTE_TRACE_STATS_ON_EXTENSION`
///
/// If true, enable computation of trace stats on the extension side.
/// If false, trace stats will be computed on the backend side.
/// Default is `false`.
#[serde(deserialize_with = "deserialize_optional_bool_from_anything")]
pub compute_trace_stats_on_extension: Option<bool>,
/// @env `DD_SPAN_DEDUP_TIMEOUT`
///
/// The timeout for the span deduplication service to check if a span key exists, in seconds.
/// For now, this is a temporary field added to debug the failure of `check_and_add()` in span dedup service.
/// Do not use this field extensively in production.
#[serde(deserialize_with = "deserialize_optional_duration_from_seconds_ignore_zero")]
pub span_dedup_timeout: Option<Duration>,
/// @env `DD_API_KEY_SECRET_RELOAD_INTERVAL`
///
/// The interval at which the Datadog API key is reloaded, in seconds.
/// If None, the API key will not be reloaded.
/// Default is `None`.
#[serde(deserialize_with = "deserialize_optional_duration_from_seconds_ignore_zero")]
pub api_key_secret_reload_interval: Option<Duration>,
/// @env `DD_SERVERLESS_APPSEC_ENABLED`
///
/// Enable Application and API Protection (AAP), previously known as AppSec/ASM, for AWS Lambda.
/// Default is `false`.
///
#[serde(deserialize_with = "deserialize_optional_bool_from_anything")]
pub serverless_appsec_enabled: Option<bool>,
/// @env `DD_APPSEC_RULES`
///
/// The path to a user-configured App & API Protection ruleset (in JSON format).
#[serde(deserialize_with = "deserialize_optional_string")]
pub appsec_rules: Option<String>,
/// @env `DD_APPSEC_WAF_TIMEOUT`
///
/// The timeout for the WAF to process a request, in microseconds.
#[serde(deserialize_with = "deserialize_optional_duration_from_microseconds")]
pub appsec_waf_timeout: Option<Duration>,
/// @env `DD_API_SECURITY_ENABLED`
///
/// Enable API Security for AWS Lambda.
#[serde(deserialize_with = "deserialize_optional_bool_from_anything")]
pub api_security_enabled: Option<bool>,
/// @env `DD_API_SECURITY_SAMPLE_DELAY`
///
/// The delay between two samples of the API Security schema collection, in seconds.
#[serde(deserialize_with = "deserialize_optional_duration_from_seconds")]
pub api_security_sample_delay: Option<Duration>,
/// @env `DD_ORG_UUID`
///
/// The Datadog organization UUID. When set, delegated auth is auto-enabled.
#[serde(deserialize_with = "deserialize_string_or_int")]
pub org_uuid: Option<String>,
}
#[allow(clippy::too_many_lines)]
fn merge_config(config: &mut Config, env_config: &EnvConfig) {
// Basic fields
merge_string!(config, env_config, site);
merge_string!(config, env_config, api_key);
merge_option_to_value!(config, env_config, log_level);
merge_option_to_value!(config, env_config, flush_timeout);
// Unified Service Tagging
merge_option!(config, env_config, env);
merge_option!(config, env_config, service);
merge_option!(config, env_config, version);
merge_hashmap!(config, env_config, tags);
// Proxy
merge_option!(config, env_config, proxy_https);
merge_vec!(config, env_config, proxy_no_proxy);
merge_option!(config, env_config, http_protocol);
merge_option!(config, env_config, tls_cert_file);
merge_option_to_value!(config, env_config, skip_ssl_validation);
// Endpoints
merge_string!(config, env_config, dd_url);
merge_string!(config, env_config, url);
merge_hashmap!(config, env_config, additional_endpoints);
merge_option_to_value!(config, env_config, compression_level);
// Logs
merge_string!(config, env_config, logs_config_logs_dd_url);
merge_option!(config, env_config, logs_config_processing_rules);
merge_option_to_value!(config, env_config, logs_config_use_compression);
merge_option_to_value!(
config,
logs_config_compression_level,
env_config,
compression_level
);
merge_option_to_value!(config, env_config, logs_config_compression_level);
merge_vec!(config, env_config, logs_config_additional_endpoints);
merge_option_to_value!(
config,
env_config,
observability_pipelines_worker_logs_enabled
);
merge_string!(config, env_config, observability_pipelines_worker_logs_url);
// APM
merge_hashmap!(config, env_config, service_mapping);
merge_string!(config, env_config, apm_dd_url);
merge_option!(config, env_config, apm_replace_tags);
merge_option_to_value!(
config,
env_config,
apm_config_obfuscation_http_remove_query_string
);
merge_option_to_value!(
config,
env_config,
apm_config_obfuscation_http_remove_paths_with_digits
);
merge_option_to_value!(
config,
apm_config_compression_level,
env_config,
compression_level
);
merge_option_to_value!(config, env_config, apm_config_compression_level);
merge_vec!(config, env_config, apm_features);
merge_hashmap!(config, env_config, apm_additional_endpoints);
merge_option!(config, env_config, apm_filter_tags_require);
merge_option!(config, env_config, apm_filter_tags_reject);
merge_option!(config, env_config, apm_filter_tags_regex_require);
merge_option!(config, env_config, apm_filter_tags_regex_reject);
merge_option_to_value!(config, env_config, trace_aws_service_representation_enabled);
// Trace Propagation
merge_vec!(config, env_config, trace_propagation_style);
merge_vec!(config, env_config, trace_propagation_style_extract);
merge_option_to_value!(config, env_config, trace_propagation_extract_first);
merge_option_to_value!(config, env_config, trace_propagation_http_baggage_enabled);
// Metrics
merge_option_to_value!(
config,
metrics_config_compression_level,
env_config,
compression_level
);
merge_option_to_value!(config, env_config, metrics_config_compression_level);
if let Some(namespace) = &env_config.statsd_metric_namespace {
config.statsd_metric_namespace = parse_metric_namespace(namespace);
}
// DogStatsD
merge_option!(config, env_config, dogstatsd_so_rcvbuf);
merge_option!(config, env_config, dogstatsd_buffer_size);
merge_option!(config, env_config, dogstatsd_queue_size);
// OTLP
merge_option_to_value!(config, env_config, otlp_config_traces_enabled);
merge_option_to_value!(
config,
env_config,
otlp_config_traces_span_name_as_resource_name
);
merge_hashmap!(config, env_config, otlp_config_traces_span_name_remappings);
merge_option_to_value!(
config,
env_config,
otlp_config_ignore_missing_datadog_fields
);
merge_option!(
config,
env_config,
otlp_config_receiver_protocols_http_endpoint
);
merge_option!(
config,
env_config,
otlp_config_receiver_protocols_grpc_endpoint
);
merge_option!(
config,
env_config,
otlp_config_receiver_protocols_grpc_transport
);
merge_option!(
config,
env_config,
otlp_config_receiver_protocols_grpc_max_recv_msg_size_mib
);
merge_option_to_value!(config, env_config, otlp_config_metrics_enabled);
merge_option_to_value!(
config,
env_config,
otlp_config_metrics_resource_attributes_as_tags
);
merge_option_to_value!(
config,
env_config,
otlp_config_metrics_instrumentation_scope_metadata_as_tags
);
merge_option!(config, env_config, otlp_config_metrics_tag_cardinality);
merge_option!(config, env_config, otlp_config_metrics_delta_ttl);
merge_option!(config, env_config, otlp_config_metrics_histograms_mode);
merge_option_to_value!(
config,
env_config,
otlp_config_metrics_histograms_send_count_sum_metrics
);
merge_option_to_value!(
config,
env_config,
otlp_config_metrics_histograms_send_aggregation_metrics
);
merge_option!(
config,
env_config,
otlp_config_metrics_sums_cumulative_monotonic_mode
);
merge_option!(
config,
env_config,
otlp_config_metrics_sums_initial_cumulativ_monotonic_value
);
merge_option!(config, env_config, otlp_config_metrics_summaries_mode);
merge_option!(
config,
env_config,
otlp_config_traces_probabilistic_sampler_sampling_percentage
);
merge_option_to_value!(config, env_config, otlp_config_logs_enabled);
// AWS Lambda
merge_string!(config, env_config, api_key_secret_arn);
merge_string!(config, env_config, kms_api_key);
merge_string!(config, env_config, api_key_ssm_arn);
merge_option_to_value!(config, env_config, serverless_logs_enabled);
// Handle serverless_logs_enabled with OR logic: if either DD_LOGS_ENABLED or DD_SERVERLESS_LOGS_ENABLED is true, enable logs
if env_config.serverless_logs_enabled.is_some() || env_config.logs_enabled.is_some() {
config.serverless_logs_enabled = env_config.serverless_logs_enabled.unwrap_or(false)
|| env_config.logs_enabled.unwrap_or(false);
}
merge_option_to_value!(config, env_config, serverless_flush_strategy);
merge_option_to_value!(config, env_config, enhanced_metrics);
merge_option_to_value!(config, env_config, lambda_proc_enhanced_metrics);
merge_option_to_value!(config, env_config, capture_lambda_payload);
merge_option_to_value!(config, env_config, capture_lambda_payload_max_depth);
merge_option_to_value!(config, env_config, compute_trace_stats_on_extension);
merge_option!(config, env_config, span_dedup_timeout);
merge_option!(config, env_config, api_key_secret_reload_interval);
merge_option_to_value!(config, env_config, serverless_appsec_enabled);
merge_option!(config, env_config, appsec_rules);
merge_option_to_value!(config, env_config, appsec_waf_timeout);
merge_option_to_value!(config, env_config, api_security_enabled);
merge_option_to_value!(config, env_config, api_security_sample_delay);
merge_string!(config, dd_org_uuid, env_config, org_uuid);
}
#[derive(Debug, PartialEq, Clone, Copy)]
#[allow(clippy::module_name_repetitions)]
pub struct EnvConfigSource;
impl ConfigSource for EnvConfigSource {
fn load(&self, config: &mut Config) -> Result<(), ConfigError> {
let figment = Figment::new()
.merge(Env::prefixed("DATADOG_"))
.merge(Env::prefixed("DD_"));
match figment.extract::<EnvConfig>() {
Ok(env_config) => merge_config(config, &env_config),
Err(e) => {
return Err(ConfigError::ParseError(format!(
"Failed to parse config from environment variables: {e}, using default config.",
)));
}
}
Ok(())
}
}
#[cfg_attr(coverage_nightly, coverage(off))] // Test modules skew coverage metrics
#[cfg(test)]
mod tests {
use std::time::Duration;
use super::*;
use crate::config::{
Config,
flush_strategy::{FlushStrategy, PeriodicStrategy},
log_level::LogLevel,
processing_rule::{Kind, ProcessingRule},
};
use datadog_opentelemetry::propagation::TracePropagationStyle;
#[test]
#[allow(clippy::too_many_lines)]
fn test_merge_config_overrides_with_environment_variables() {
figment::Jail::expect_with(|jail| {
jail.clear_env();
// Set environment variables here
jail.set_env("DD_SITE", "test-site");
jail.set_env("DD_API_KEY", "test-api-key");
jail.set_env("DD_LOG_LEVEL", "debug");
jail.set_env("DD_FLUSH_TIMEOUT", "42");
// Proxy
jail.set_env("DD_PROXY_HTTPS", "https://proxy.example.com");
jail.set_env("DD_PROXY_NO_PROXY", "localhost,127.0.0.1");
jail.set_env("DD_HTTP_PROTOCOL", "http1");
jail.set_env("DD_TLS_CERT_FILE", "/opt/ca-cert.pem");
jail.set_env("DD_SKIP_SSL_VALIDATION", "true");
// Metrics
jail.set_env("DD_DD_URL", "https://metrics.datadoghq.com");
jail.set_env("DD_URL", "https://app.datadoghq.com");
jail.set_env(
"DD_ADDITIONAL_ENDPOINTS",
"{\"https://app.datadoghq.com\": [\"apikey2\", \"apikey3\"], \"https://app.datadoghq.eu\": [\"apikey4\"]}",
);
// Unified Service Tagging
jail.set_env("DD_ENV", "test-env");
jail.set_env("DD_SERVICE", "test-service");
jail.set_env("DD_VERSION", "1.0.0");
jail.set_env("DD_TAGS", "team:test-team,project:test-project");
jail.set_env("DD_COMPRESSION_LEVEL", "4");
// Logs
jail.set_env("DD_LOGS_CONFIG_LOGS_DD_URL", "https://logs.datadoghq.com");
jail.set_env(
"DD_LOGS_CONFIG_PROCESSING_RULES",
r#"[{"type":"exclude_at_match","name":"exclude","pattern":"exclude"}]"#,
);
jail.set_env("DD_LOGS_CONFIG_USE_COMPRESSION", "false");
jail.set_env("DD_LOGS_CONFIG_COMPRESSION_LEVEL", "1");
jail.set_env(
"DD_LOGS_CONFIG_ADDITIONAL_ENDPOINTS",
"[{\"api_key\": \"apikey2\", \"Host\": \"agent-http-intake.logs.datadoghq.com\", \"Port\": 443, \"is_reliable\": true}]",
);
// APM
jail.set_env("DD_SERVICE_MAPPING", "old-service:new-service");
jail.set_env("DD_APPSEC_ENABLED", "true");
jail.set_env("DD_APM_DD_URL", "https://apm.datadoghq.com");
jail.set_env(
"DD_APM_REPLACE_TAGS",
r#"[{"name":"test-tag","pattern":"test-pattern","repl":"replacement"}]"#,
);
jail.set_env("DD_APM_CONFIG_OBFUSCATION_HTTP_REMOVE_QUERY_STRING", "true");
jail.set_env(
"DD_APM_CONFIG_OBFUSCATION_HTTP_REMOVE_PATHS_WITH_DIGITS",
"true",
);
jail.set_env("DD_APM_CONFIG_COMPRESSION_LEVEL", "2");
jail.set_env(
"DD_APM_FEATURES",
"enable_otlp_compute_top_level_by_span_kind,enable_stats_by_span_kind",
);
jail.set_env("DD_APM_ADDITIONAL_ENDPOINTS", "{\"https://trace.agent.datadoghq.com\": [\"apikey2\", \"apikey3\"], \"https://trace.agent.datadoghq.eu\": [\"apikey4\"]}");
jail.set_env("DD_APM_FILTER_TAGS_REQUIRE", "env:production service:api");
jail.set_env("DD_APM_FILTER_TAGS_REJECT", "debug:true env:test");
jail.set_env(
"DD_APM_FILTER_TAGS_REGEX_REQUIRE",
"env:^test.*$ debug:^true$",
);
jail.set_env(
"DD_APM_FILTER_TAGS_REGEX_REJECT",
"env:^test.*$ debug:^true$",
);
jail.set_env("DD_METRICS_CONFIG_COMPRESSION_LEVEL", "3");
// Trace Propagation
jail.set_env("DD_TRACE_PROPAGATION_STYLE", "datadog");
jail.set_env("DD_TRACE_PROPAGATION_STYLE_EXTRACT", "tracecontext");
jail.set_env("DD_TRACE_PROPAGATION_EXTRACT_FIRST", "true");
jail.set_env("DD_TRACE_PROPAGATION_HTTP_BAGGAGE_ENABLED", "true");
jail.set_env("DD_TRACE_AWS_SERVICE_REPRESENTATION_ENABLED", "true");
// OTLP
jail.set_env("DD_OTLP_CONFIG_TRACES_ENABLED", "false");
jail.set_env("DD_OTLP_CONFIG_TRACES_SPAN_NAME_AS_RESOURCE_NAME", "true");
jail.set_env(
"DD_OTLP_CONFIG_TRACES_SPAN_NAME_REMAPPINGS",
"old-span:new-span",
);
jail.set_env("DD_OTLP_CONFIG_IGNORE_MISSING_DATADOG_FIELDS", "true");
jail.set_env(
"DD_OTLP_CONFIG_RECEIVER_PROTOCOLS_HTTP_ENDPOINT",
"http://localhost:4318",
);
jail.set_env(
"DD_OTLP_CONFIG_RECEIVER_PROTOCOLS_GRPC_ENDPOINT",
"http://localhost:4317",
);
jail.set_env("DD_OTLP_CONFIG_RECEIVER_PROTOCOLS_GRPC_TRANSPORT", "tcp");
jail.set_env(
"DD_OTLP_CONFIG_RECEIVER_PROTOCOLS_GRPC_MAX_RECV_MSG_SIZE_MIB",
"4",
);
jail.set_env("DD_OTLP_CONFIG_METRICS_ENABLED", "true");
jail.set_env("DD_OTLP_CONFIG_METRICS_RESOURCE_ATTRIBUTES_AS_TAGS", "true");
jail.set_env(
"DD_OTLP_CONFIG_METRICS_INSTRUMENTATION_SCOPE_METADATA_AS_TAGS",
"true",
);
jail.set_env("DD_OTLP_CONFIG_METRICS_TAG_CARDINALITY", "low");
jail.set_env("DD_OTLP_CONFIG_METRICS_DELTA_TTL", "3600");
jail.set_env("DD_OTLP_CONFIG_METRICS_HISTOGRAMS_MODE", "counters");
jail.set_env(
"DD_OTLP_CONFIG_METRICS_HISTOGRAMS_SEND_COUNT_SUM_METRICS",
"true",
);
jail.set_env(
"DD_OTLP_CONFIG_METRICS_HISTOGRAMS_SEND_AGGREGATION_METRICS",
"true",
);
jail.set_env(
"DD_OTLP_CONFIG_METRICS_SUMS_CUMULATIVE_MONOTONIC_MODE",
"to_delta",
);
jail.set_env(
"DD_OTLP_CONFIG_METRICS_SUMS_INITIAL_CUMULATIV_MONOTONIC_VALUE",
"auto",
);
jail.set_env("DD_OTLP_CONFIG_METRICS_SUMMARIES_MODE", "quantiles");
jail.set_env(
"DD_OTLP_CONFIG_TRACES_PROBABILISTIC_SAMPLER_SAMPLING_PERCENTAGE",
"50",
);
jail.set_env("DD_OTLP_CONFIG_LOGS_ENABLED", "true");
// DogStatsD
jail.set_env("DD_DOGSTATSD_SO_RCVBUF", "1048576");
jail.set_env("DD_DOGSTATSD_BUFFER_SIZE", "65507");
jail.set_env("DD_DOGSTATSD_QUEUE_SIZE", "2048");
// AWS Lambda
jail.set_env(
"DD_API_KEY_SECRET_ARN",
"arn:aws:secretsmanager:region:account:secret:datadog-api-key",
);
jail.set_env("DD_KMS_API_KEY", "test-kms-key");
jail.set_env("DD_SERVERLESS_LOGS_ENABLED", "false");
jail.set_env("DD_SERVERLESS_FLUSH_STRATEGY", "periodically,60000");
jail.set_env("DD_ENHANCED_METRICS", "false");
jail.set_env("DD_LAMBDA_PROC_ENHANCED_METRICS", "false");
jail.set_env("DD_CAPTURE_LAMBDA_PAYLOAD", "true");
jail.set_env("DD_CAPTURE_LAMBDA_PAYLOAD_MAX_DEPTH", "5");
jail.set_env("DD_COMPUTE_TRACE_STATS_ON_EXTENSION", "true");
jail.set_env("DD_SPAN_DEDUP_TIMEOUT", "5");
jail.set_env("DD_API_KEY_SECRET_RELOAD_INTERVAL", "10");
jail.set_env("DD_SERVERLESS_APPSEC_ENABLED", "true");
jail.set_env("DD_APPSEC_RULES", "/path/to/rules.json");
jail.set_env("DD_APPSEC_WAF_TIMEOUT", "1000000"); // Microseconds
jail.set_env("DD_API_SECURITY_ENABLED", "0"); // Seconds
jail.set_env("DD_API_SECURITY_SAMPLE_DELAY", "60"); // Seconds
let mut config = Config::default();
let env_config_source = EnvConfigSource;
env_config_source
.load(&mut config)
.expect("Failed to load config");
let expected_config = Config {
site: "test-site".to_string(),
api_key: "test-api-key".to_string(),
log_level: LogLevel::Debug,
compression_level: 4,
flush_timeout: 42,
proxy_https: Some("https://proxy.example.com".to_string()),
proxy_no_proxy: vec!["localhost".to_string(), "127.0.0.1".to_string()],
http_protocol: Some("http1".to_string()),
tls_cert_file: Some("/opt/ca-cert.pem".to_string()),
skip_ssl_validation: true,
dd_url: "https://metrics.datadoghq.com".to_string(),
url: "https://app.datadoghq.com".to_string(),
additional_endpoints: HashMap::from([
(
"https://app.datadoghq.com".to_string(),
vec!["apikey2".to_string(), "apikey3".to_string()],
),
(
"https://app.datadoghq.eu".to_string(),
vec!["apikey4".to_string()],
),
]),
env: Some("test-env".to_string()),
service: Some("test-service".to_string()),
version: Some("1.0.0".to_string()),
tags: HashMap::from([
("team".to_string(), "test-team".to_string()),
("project".to_string(), "test-project".to_string()),
]),
logs_config_logs_dd_url: "https://logs.datadoghq.com".to_string(),
logs_config_processing_rules: Some(vec![ProcessingRule {
kind: Kind::ExcludeAtMatch,
name: "exclude".to_string(),
pattern: "exclude".to_string(),
replace_placeholder: None,
}]),
logs_config_use_compression: false,
logs_config_compression_level: 1,
logs_config_additional_endpoints: vec![LogsAdditionalEndpoint {
api_key: "apikey2".to_string(),
host: "agent-http-intake.logs.datadoghq.com".to_string(),
port: 443,
is_reliable: true,
}],
observability_pipelines_worker_logs_enabled: false,
observability_pipelines_worker_logs_url: String::default(),
service_mapping: HashMap::from([(
"old-service".to_string(),
"new-service".to_string(),
)]),
apm_dd_url: "https://apm.datadoghq.com".to_string(),
apm_replace_tags: Some(
libdd_trace_obfuscation::replacer::parse_rules_from_string(
r#"[{"name":"test-tag","pattern":"test-pattern","repl":"replacement"}]"#,
)
.expect("Failed to parse replace rules"),
),
apm_config_obfuscation_http_remove_query_string: true,
apm_config_obfuscation_http_remove_paths_with_digits: true,
apm_config_compression_level: 2,
apm_features: vec![
"enable_otlp_compute_top_level_by_span_kind".to_string(),
"enable_stats_by_span_kind".to_string(),
],
apm_additional_endpoints: HashMap::from([
(
"https://trace.agent.datadoghq.com".to_string(),
vec!["apikey2".to_string(), "apikey3".to_string()],
),
(
"https://trace.agent.datadoghq.eu".to_string(),
vec!["apikey4".to_string()],
),
]),
apm_filter_tags_require: Some(vec![
"env:production".to_string(),
"service:api".to_string(),
]),
apm_filter_tags_reject: Some(vec![
"debug:true".to_string(),
"env:test".to_string(),
]),
apm_filter_tags_regex_require: Some(vec![
"env:^test.*$".to_string(),
"debug:^true$".to_string(),
]),
apm_filter_tags_regex_reject: Some(vec![
"env:^test.*$".to_string(),
"debug:^true$".to_string(),
]),
trace_propagation_style: vec![TracePropagationStyle::Datadog],
trace_propagation_style_extract: vec![TracePropagationStyle::TraceContext],
trace_propagation_extract_first: true,
trace_propagation_http_baggage_enabled: true,
trace_aws_service_representation_enabled: true,
metrics_config_compression_level: 3,