datadog 2.12.1 → 2.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +243 -2
- data/ext/datadog_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +63 -56
- data/ext/datadog_profiling_native_extension/collectors_stack.c +263 -76
- data/ext/datadog_profiling_native_extension/collectors_stack.h +20 -3
- data/ext/datadog_profiling_native_extension/collectors_thread_context.c +78 -26
- data/ext/datadog_profiling_native_extension/collectors_thread_context.h +1 -0
- data/ext/datadog_profiling_native_extension/datadog_ruby_common.c +1 -4
- data/ext/datadog_profiling_native_extension/datadog_ruby_common.h +10 -0
- data/ext/datadog_profiling_native_extension/encoded_profile.c +79 -0
- data/ext/datadog_profiling_native_extension/encoded_profile.h +8 -0
- data/ext/datadog_profiling_native_extension/extconf.rb +10 -0
- data/ext/datadog_profiling_native_extension/heap_recorder.c +247 -364
- data/ext/datadog_profiling_native_extension/heap_recorder.h +4 -6
- data/ext/datadog_profiling_native_extension/http_transport.c +60 -94
- data/ext/datadog_profiling_native_extension/libdatadog_helpers.c +22 -0
- data/ext/datadog_profiling_native_extension/libdatadog_helpers.h +8 -5
- data/ext/datadog_profiling_native_extension/private_vm_api_access.c +41 -21
- data/ext/datadog_profiling_native_extension/private_vm_api_access.h +6 -4
- data/ext/datadog_profiling_native_extension/profiling.c +2 -0
- data/ext/datadog_profiling_native_extension/ruby_helpers.c +1 -13
- data/ext/datadog_profiling_native_extension/ruby_helpers.h +3 -11
- data/ext/datadog_profiling_native_extension/stack_recorder.c +173 -76
- data/ext/libdatadog_api/crashtracker.c +11 -12
- data/ext/libdatadog_api/crashtracker.h +5 -0
- data/ext/libdatadog_api/datadog_ruby_common.c +1 -4
- data/ext/libdatadog_api/datadog_ruby_common.h +10 -0
- data/ext/libdatadog_api/extconf.rb +2 -2
- data/ext/libdatadog_api/init.c +15 -0
- data/ext/libdatadog_api/library_config.c +164 -0
- data/ext/libdatadog_api/library_config.h +25 -0
- data/ext/libdatadog_api/macos_development.md +3 -3
- data/ext/libdatadog_api/process_discovery.c +112 -0
- data/ext/libdatadog_api/process_discovery.h +5 -0
- data/ext/libdatadog_extconf_helpers.rb +2 -2
- data/lib/datadog/appsec/actions_handler/serializable_backtrace.rb +89 -0
- data/lib/datadog/appsec/actions_handler.rb +24 -2
- data/lib/datadog/appsec/anonymizer.rb +16 -0
- data/lib/datadog/appsec/api_security/lru_cache.rb +56 -0
- data/lib/datadog/appsec/api_security/route_extractor.rb +71 -0
- data/lib/datadog/appsec/api_security/sampler.rb +59 -0
- data/lib/datadog/appsec/api_security.rb +23 -0
- data/lib/datadog/appsec/assets/waf_rules/README.md +50 -5
- data/lib/datadog/appsec/assets/waf_rules/recommended.json +257 -85
- data/lib/datadog/appsec/assets/waf_rules/strict.json +10 -78
- data/lib/datadog/appsec/autoload.rb +1 -1
- data/lib/datadog/appsec/component.rb +46 -61
- data/lib/datadog/appsec/compressed_json.rb +40 -0
- data/lib/datadog/appsec/configuration/settings.rb +153 -30
- data/lib/datadog/appsec/context.rb +7 -7
- data/lib/datadog/appsec/contrib/active_record/instrumentation.rb +10 -12
- data/lib/datadog/appsec/contrib/active_record/integration.rb +2 -2
- data/lib/datadog/appsec/contrib/active_record/patcher.rb +22 -22
- data/lib/datadog/appsec/contrib/auto_instrument.rb +1 -1
- data/lib/datadog/appsec/contrib/devise/configuration.rb +7 -31
- data/lib/datadog/appsec/contrib/devise/data_extractor.rb +78 -0
- data/lib/datadog/appsec/contrib/devise/ext.rb +22 -0
- data/lib/datadog/appsec/contrib/devise/integration.rb +1 -2
- data/lib/datadog/appsec/contrib/devise/patcher.rb +34 -23
- data/lib/datadog/appsec/contrib/devise/patches/signin_tracking_patch.rb +102 -0
- data/lib/datadog/appsec/contrib/devise/patches/signup_tracking_patch.rb +69 -0
- data/lib/datadog/appsec/contrib/devise/{patcher/rememberable_patch.rb → patches/skip_signin_tracking_patch.rb} +2 -2
- data/lib/datadog/appsec/contrib/devise/tracking_middleware.rb +106 -0
- data/lib/datadog/appsec/contrib/excon/integration.rb +1 -1
- data/lib/datadog/appsec/contrib/excon/ssrf_detection_middleware.rb +9 -10
- data/lib/datadog/appsec/contrib/faraday/integration.rb +1 -1
- data/lib/datadog/appsec/contrib/faraday/ssrf_detection_middleware.rb +8 -9
- data/lib/datadog/appsec/contrib/graphql/gateway/watcher.rb +8 -9
- data/lib/datadog/appsec/contrib/graphql/integration.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/ext.rb +34 -0
- data/lib/datadog/appsec/contrib/rack/gateway/watcher.rb +49 -32
- data/lib/datadog/appsec/contrib/rack/integration.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/request_middleware.rb +42 -30
- data/lib/datadog/appsec/contrib/rails/gateway/watcher.rb +11 -13
- data/lib/datadog/appsec/contrib/rails/integration.rb +1 -1
- data/lib/datadog/appsec/contrib/rails/patcher.rb +21 -21
- data/lib/datadog/appsec/contrib/rest_client/integration.rb +1 -1
- data/lib/datadog/appsec/contrib/rest_client/request_ssrf_detection_patch.rb +10 -11
- data/lib/datadog/appsec/contrib/sinatra/gateway/watcher.rb +17 -23
- data/lib/datadog/appsec/contrib/sinatra/integration.rb +1 -1
- data/lib/datadog/appsec/event.rb +96 -135
- data/lib/datadog/appsec/ext.rb +4 -2
- data/lib/datadog/appsec/instrumentation/gateway/argument.rb +7 -2
- data/lib/datadog/appsec/instrumentation/gateway/middleware.rb +24 -0
- data/lib/datadog/appsec/instrumentation/gateway.rb +17 -22
- data/lib/datadog/appsec/metrics/telemetry.rb +1 -1
- data/lib/datadog/appsec/monitor/gateway/watcher.rb +49 -14
- data/lib/datadog/appsec/processor/rule_loader.rb +30 -33
- data/lib/datadog/appsec/remote.rb +31 -59
- data/lib/datadog/appsec/response.rb +6 -6
- data/lib/datadog/appsec/security_engine/engine.rb +194 -0
- data/lib/datadog/appsec/security_engine/runner.rb +13 -14
- data/lib/datadog/appsec/security_event.rb +39 -0
- data/lib/datadog/appsec/utils.rb +0 -2
- data/lib/datadog/appsec.rb +5 -8
- data/lib/datadog/core/buffer/random.rb +18 -2
- data/lib/datadog/core/configuration/agent_settings.rb +52 -0
- data/lib/datadog/core/configuration/agent_settings_resolver.rb +4 -46
- data/lib/datadog/core/configuration/agentless_settings_resolver.rb +176 -0
- data/lib/datadog/core/configuration/components.rb +48 -31
- data/lib/datadog/core/configuration/components_state.rb +23 -0
- data/lib/datadog/core/configuration/ext.rb +4 -0
- data/lib/datadog/core/configuration/option.rb +81 -45
- data/lib/datadog/core/configuration/option_definition.rb +4 -4
- data/lib/datadog/core/configuration/options.rb +3 -3
- data/lib/datadog/core/configuration/settings.rb +109 -44
- data/lib/datadog/core/configuration/stable_config.rb +22 -0
- data/lib/datadog/core/configuration.rb +40 -16
- data/lib/datadog/core/crashtracking/component.rb +3 -10
- data/lib/datadog/core/crashtracking/tag_builder.rb +4 -22
- data/lib/datadog/core/diagnostics/environment_logger.rb +1 -1
- data/lib/datadog/core/encoding.rb +1 -1
- data/lib/datadog/core/environment/agent_info.rb +4 -3
- data/lib/datadog/core/environment/cgroup.rb +10 -12
- data/lib/datadog/core/environment/container.rb +38 -40
- data/lib/datadog/core/environment/ext.rb +6 -6
- data/lib/datadog/core/environment/git.rb +1 -0
- data/lib/datadog/core/environment/identity.rb +3 -3
- data/lib/datadog/core/environment/platform.rb +3 -3
- data/lib/datadog/core/environment/variable_helpers.rb +1 -1
- data/lib/datadog/core/error.rb +11 -9
- data/lib/datadog/core/logger.rb +2 -2
- data/lib/datadog/core/metrics/client.rb +20 -21
- data/lib/datadog/core/metrics/logging.rb +5 -5
- data/lib/datadog/core/process_discovery/tracer_memfd.rb +15 -0
- data/lib/datadog/core/process_discovery.rb +36 -0
- data/lib/datadog/core/rate_limiter.rb +4 -2
- data/lib/datadog/core/remote/client.rb +40 -32
- data/lib/datadog/core/remote/component.rb +6 -9
- data/lib/datadog/core/remote/configuration/digest.rb +7 -7
- data/lib/datadog/core/remote/configuration/path.rb +1 -1
- data/lib/datadog/core/remote/configuration/repository.rb +14 -1
- data/lib/datadog/core/remote/negotiation.rb +9 -9
- data/lib/datadog/core/remote/transport/config.rb +4 -3
- data/lib/datadog/core/remote/transport/http/client.rb +5 -4
- data/lib/datadog/core/remote/transport/http/config.rb +27 -37
- data/lib/datadog/core/remote/transport/http/negotiation.rb +7 -33
- data/lib/datadog/core/remote/transport/http.rb +22 -57
- data/lib/datadog/core/remote/transport/negotiation.rb +4 -3
- data/lib/datadog/core/runtime/metrics.rb +12 -5
- data/lib/datadog/core/tag_builder.rb +56 -0
- data/lib/datadog/core/telemetry/component.rb +81 -52
- data/lib/datadog/core/telemetry/emitter.rb +23 -11
- data/lib/datadog/core/telemetry/event/app_client_configuration_change.rb +66 -0
- data/lib/datadog/core/telemetry/event/app_closing.rb +18 -0
- data/lib/datadog/core/telemetry/event/app_dependencies_loaded.rb +33 -0
- data/lib/datadog/core/telemetry/event/app_heartbeat.rb +18 -0
- data/lib/datadog/core/telemetry/event/app_integrations_change.rb +58 -0
- data/lib/datadog/core/telemetry/event/app_started.rb +287 -0
- data/lib/datadog/core/telemetry/event/base.rb +40 -0
- data/lib/datadog/core/telemetry/event/distributions.rb +18 -0
- data/lib/datadog/core/telemetry/event/generate_metrics.rb +43 -0
- data/lib/datadog/core/telemetry/event/log.rb +76 -0
- data/lib/datadog/core/telemetry/event/message_batch.rb +42 -0
- data/lib/datadog/core/telemetry/event/synth_app_client_configuration_change.rb +43 -0
- data/lib/datadog/core/telemetry/event.rb +17 -472
- data/lib/datadog/core/telemetry/http/adapters/net.rb +12 -97
- data/lib/datadog/core/telemetry/logger.rb +5 -4
- data/lib/datadog/core/telemetry/logging.rb +11 -5
- data/lib/datadog/core/telemetry/metric.rb +8 -8
- data/lib/datadog/core/telemetry/request.rb +4 -4
- data/lib/datadog/core/telemetry/transport/http/api.rb +43 -0
- data/lib/datadog/core/telemetry/transport/http/client.rb +49 -0
- data/lib/datadog/core/telemetry/transport/http/telemetry.rb +92 -0
- data/lib/datadog/core/telemetry/transport/http.rb +63 -0
- data/lib/datadog/core/telemetry/transport/telemetry.rb +51 -0
- data/lib/datadog/core/telemetry/worker.rb +90 -24
- data/lib/datadog/core/transport/http/adapters/net.rb +17 -2
- data/lib/datadog/core/transport/http/adapters/test.rb +2 -1
- data/lib/datadog/core/transport/http/api/instance.rb +17 -0
- data/lib/datadog/core/transport/http/api/spec.rb +17 -0
- data/lib/datadog/core/transport/http/builder.rb +19 -17
- data/lib/datadog/core/transport/http/env.rb +8 -0
- data/lib/datadog/core/transport/http.rb +39 -2
- data/lib/datadog/core/utils/at_fork_monkey_patch.rb +6 -6
- data/lib/datadog/core/utils/duration.rb +32 -32
- data/lib/datadog/core/utils/forking.rb +2 -2
- data/lib/datadog/core/utils/network.rb +6 -6
- data/lib/datadog/core/utils/only_once_successful.rb +16 -5
- data/lib/datadog/core/utils/time.rb +20 -0
- data/lib/datadog/core/utils/truncation.rb +21 -0
- data/lib/datadog/core/utils.rb +7 -0
- data/lib/datadog/core/vendor/multipart-post/multipart/post/composite_read_io.rb +1 -1
- data/lib/datadog/core/vendor/multipart-post/multipart/post/multipartable.rb +8 -8
- data/lib/datadog/core/vendor/multipart-post/multipart/post/parts.rb +7 -7
- data/lib/datadog/core/worker.rb +1 -1
- data/lib/datadog/core/workers/async.rb +29 -12
- data/lib/datadog/core/workers/interval_loop.rb +12 -1
- data/lib/datadog/core/workers/runtime_metrics.rb +2 -2
- data/lib/datadog/core.rb +8 -0
- data/lib/datadog/di/boot.rb +34 -0
- data/lib/datadog/di/component.rb +0 -2
- data/lib/datadog/di/instrumenter.rb +48 -5
- data/lib/datadog/di/probe_notification_builder.rb +38 -43
- data/lib/datadog/di/probe_notifier_worker.rb +25 -17
- data/lib/datadog/di/remote.rb +2 -0
- data/lib/datadog/di/serializer.rb +10 -2
- data/lib/datadog/di/transport/diagnostics.rb +4 -3
- data/lib/datadog/di/transport/http/api.rb +2 -12
- data/lib/datadog/di/transport/http/client.rb +4 -3
- data/lib/datadog/di/transport/http/diagnostics.rb +7 -34
- data/lib/datadog/di/transport/http/input.rb +18 -35
- data/lib/datadog/di/transport/http.rb +14 -62
- data/lib/datadog/di/transport/input.rb +14 -5
- data/lib/datadog/di/utils.rb +5 -0
- data/lib/datadog/di.rb +0 -33
- data/lib/datadog/error_tracking/collector.rb +87 -0
- data/lib/datadog/error_tracking/component.rb +167 -0
- data/lib/datadog/error_tracking/configuration/settings.rb +63 -0
- data/lib/datadog/error_tracking/configuration.rb +11 -0
- data/lib/datadog/error_tracking/ext.rb +18 -0
- data/lib/datadog/error_tracking/extensions.rb +16 -0
- data/lib/datadog/error_tracking/filters.rb +77 -0
- data/lib/datadog/error_tracking.rb +18 -0
- data/lib/datadog/kit/appsec/events/v2.rb +195 -0
- data/lib/datadog/kit/appsec/events.rb +12 -0
- data/lib/datadog/kit/identity.rb +5 -1
- data/lib/datadog/opentelemetry/api/baggage.rb +90 -0
- data/lib/datadog/opentelemetry/api/baggage.rbs +26 -0
- data/lib/datadog/opentelemetry/api/context.rb +16 -2
- data/lib/datadog/opentelemetry/sdk/trace/span.rb +1 -1
- data/lib/datadog/opentelemetry.rb +2 -1
- data/lib/datadog/profiling/collectors/code_provenance.rb +18 -9
- data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +6 -0
- data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +1 -0
- data/lib/datadog/profiling/collectors/info.rb +44 -0
- data/lib/datadog/profiling/collectors/thread_context.rb +17 -2
- data/lib/datadog/profiling/component.rb +8 -9
- data/lib/datadog/profiling/encoded_profile.rb +11 -0
- data/lib/datadog/profiling/exporter.rb +12 -7
- data/lib/datadog/profiling/ext.rb +0 -14
- data/lib/datadog/profiling/flush.rb +5 -8
- data/lib/datadog/profiling/http_transport.rb +7 -61
- data/lib/datadog/profiling/profiler.rb +2 -0
- data/lib/datadog/profiling/scheduler.rb +10 -2
- data/lib/datadog/profiling/sequence_tracker.rb +44 -0
- data/lib/datadog/profiling/stack_recorder.rb +9 -9
- data/lib/datadog/profiling/tag_builder.rb +7 -41
- data/lib/datadog/profiling/tasks/setup.rb +2 -0
- data/lib/datadog/profiling.rb +7 -2
- data/lib/datadog/single_step_instrument.rb +9 -0
- data/lib/datadog/tracing/analytics.rb +1 -1
- data/lib/datadog/tracing/component.rb +15 -12
- data/lib/datadog/tracing/configuration/ext.rb +7 -1
- data/lib/datadog/tracing/configuration/settings.rb +18 -2
- data/lib/datadog/tracing/context_provider.rb +1 -1
- data/lib/datadog/tracing/contrib/action_pack/action_controller/instrumentation.rb +15 -0
- data/lib/datadog/tracing/contrib/action_pack/action_dispatch/instrumentation.rb +19 -12
- data/lib/datadog/tracing/contrib/action_pack/ext.rb +2 -0
- data/lib/datadog/tracing/contrib/active_record/integration.rb +1 -1
- data/lib/datadog/tracing/contrib/active_support/cache/events/cache.rb +11 -2
- data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +33 -0
- data/lib/datadog/tracing/contrib/active_support/cache/patcher.rb +4 -0
- data/lib/datadog/tracing/contrib/active_support/cache/redis.rb +2 -4
- data/lib/datadog/tracing/contrib/active_support/configuration/settings.rb +13 -0
- data/lib/datadog/tracing/contrib/aws/instrumentation.rb +10 -0
- data/lib/datadog/tracing/contrib/aws/parsed_context.rb +5 -1
- data/lib/datadog/tracing/contrib/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/ethon/easy_patch.rb +4 -5
- data/lib/datadog/tracing/contrib/excon/middleware.rb +5 -3
- data/lib/datadog/tracing/contrib/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/faraday/middleware.rb +5 -3
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb +7 -1
- data/lib/datadog/tracing/contrib/grpc/distributed/propagation.rb +3 -0
- data/lib/datadog/tracing/contrib/http/circuit_breaker.rb +0 -15
- data/lib/datadog/tracing/contrib/http/distributed/propagation.rb +4 -1
- data/lib/datadog/tracing/contrib/http/instrumentation.rb +6 -10
- data/lib/datadog/tracing/contrib/httpclient/instrumentation.rb +6 -16
- data/lib/datadog/tracing/contrib/httprb/instrumentation.rb +7 -15
- data/lib/datadog/tracing/contrib/karafka/configuration/settings.rb +27 -0
- data/lib/datadog/tracing/contrib/karafka/distributed/propagation.rb +48 -0
- data/lib/datadog/tracing/contrib/karafka/ext.rb +27 -0
- data/lib/datadog/tracing/contrib/karafka/integration.rb +45 -0
- data/lib/datadog/tracing/contrib/karafka/monitor.rb +66 -0
- data/lib/datadog/tracing/contrib/karafka/patcher.rb +71 -0
- data/lib/datadog/tracing/contrib/karafka.rb +37 -0
- data/lib/datadog/tracing/contrib/lograge/patcher.rb +4 -2
- data/lib/datadog/tracing/contrib/mongodb/configuration/settings.rb +8 -0
- data/lib/datadog/tracing/contrib/mongodb/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/mongodb/subscribers.rb +18 -1
- data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +16 -6
- data/lib/datadog/tracing/contrib/opensearch/configuration/settings.rb +17 -0
- data/lib/datadog/tracing/contrib/opensearch/ext.rb +9 -0
- data/lib/datadog/tracing/contrib/opensearch/patcher.rb +5 -1
- data/lib/datadog/tracing/contrib/patcher.rb +5 -2
- data/lib/datadog/tracing/contrib/rack/request_queue.rb +1 -1
- data/lib/datadog/tracing/contrib/rails/patcher.rb +4 -1
- data/lib/datadog/tracing/contrib/rails/runner.rb +61 -40
- data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +5 -3
- data/lib/datadog/tracing/contrib/sidekiq/client_tracer.rb +6 -1
- data/lib/datadog/tracing/contrib/sidekiq/distributed/propagation.rb +3 -0
- data/lib/datadog/tracing/contrib/sidekiq/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/sidekiq/server_tracer.rb +5 -2
- data/lib/datadog/tracing/contrib/support.rb +28 -0
- data/lib/datadog/tracing/contrib.rb +1 -0
- data/lib/datadog/tracing/correlation.rb +9 -2
- data/lib/datadog/tracing/diagnostics/environment_logger.rb +3 -1
- data/lib/datadog/tracing/distributed/b3_multi.rb +1 -1
- data/lib/datadog/tracing/distributed/b3_single.rb +1 -1
- data/lib/datadog/tracing/distributed/baggage.rb +131 -0
- data/lib/datadog/tracing/distributed/datadog.rb +4 -2
- data/lib/datadog/tracing/distributed/propagation.rb +25 -4
- data/lib/datadog/tracing/distributed/propagation_policy.rb +42 -0
- data/lib/datadog/tracing/metadata/errors.rb +4 -4
- data/lib/datadog/tracing/metadata/ext.rb +5 -0
- data/lib/datadog/tracing/metadata/metastruct.rb +36 -0
- data/lib/datadog/tracing/metadata/metastruct_tagging.rb +42 -0
- data/lib/datadog/tracing/metadata.rb +2 -0
- data/lib/datadog/tracing/sampling/rate_sampler.rb +2 -1
- data/lib/datadog/tracing/sampling/span/rule.rb +0 -1
- data/lib/datadog/tracing/span.rb +10 -1
- data/lib/datadog/tracing/span_event.rb +2 -2
- data/lib/datadog/tracing/span_operation.rb +68 -16
- data/lib/datadog/tracing/sync_writer.rb +2 -3
- data/lib/datadog/tracing/trace_digest.rb +9 -2
- data/lib/datadog/tracing/trace_operation.rb +55 -27
- data/lib/datadog/tracing/trace_segment.rb +6 -4
- data/lib/datadog/tracing/tracer.rb +51 -7
- data/lib/datadog/tracing/transport/http/api.rb +2 -10
- data/lib/datadog/tracing/transport/http/client.rb +5 -4
- data/lib/datadog/tracing/transport/http/traces.rb +13 -41
- data/lib/datadog/tracing/transport/http.rb +11 -44
- data/lib/datadog/tracing/transport/serializable_trace.rb +3 -1
- data/lib/datadog/tracing/transport/trace_formatter.rb +7 -0
- data/lib/datadog/tracing/transport/traces.rb +26 -9
- data/lib/datadog/tracing/utils.rb +1 -1
- data/lib/datadog/tracing/workers/trace_writer.rb +2 -6
- data/lib/datadog/tracing/writer.rb +2 -6
- data/lib/datadog/tracing.rb +16 -3
- data/lib/datadog/version.rb +2 -2
- data/lib/datadog.rb +8 -2
- metadata +88 -23
- data/lib/datadog/appsec/assets/waf_rules/processors.json +0 -92
- data/lib/datadog/appsec/assets/waf_rules/scanners.json +0 -114
- data/lib/datadog/appsec/contrib/devise/event.rb +0 -54
- data/lib/datadog/appsec/contrib/devise/patcher/authenticatable_patch.rb +0 -72
- data/lib/datadog/appsec/contrib/devise/patcher/registration_controller_patch.rb +0 -47
- data/lib/datadog/appsec/contrib/devise/resource.rb +0 -35
- data/lib/datadog/appsec/contrib/devise/tracking.rb +0 -57
- data/lib/datadog/appsec/processor/rule_merger.rb +0 -170
- data/lib/datadog/appsec/processor.rb +0 -107
- data/lib/datadog/appsec/utils/trace_operation.rb +0 -15
- data/lib/datadog/core/telemetry/http/env.rb +0 -20
- data/lib/datadog/core/telemetry/http/ext.rb +0 -28
- data/lib/datadog/core/telemetry/http/response.rb +0 -70
- data/lib/datadog/core/telemetry/http/transport.rb +0 -90
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative 'stable_config'
|
3
4
|
require_relative '../utils/safe_dup'
|
4
5
|
|
5
6
|
module Datadog
|
@@ -21,7 +22,7 @@ module Datadog
|
|
21
22
|
# Represents an Option precedence level.
|
22
23
|
# Each precedence has a `numeric` value; higher values means higher precedence.
|
23
24
|
# `name` is for inspection purposes only.
|
24
|
-
Value = Struct.new(:numeric, :name) do
|
25
|
+
Value = Struct.new(:numeric, :name, :origin) do
|
25
26
|
include Comparable
|
26
27
|
|
27
28
|
def <=>(other)
|
@@ -32,17 +33,25 @@ module Datadog
|
|
32
33
|
end
|
33
34
|
|
34
35
|
# Remote configuration provided through the Datadog app.
|
35
|
-
REMOTE_CONFIGURATION = Value.new(
|
36
|
+
REMOTE_CONFIGURATION = Value.new(5, :remote_configuration, 'remote_config').freeze
|
36
37
|
|
37
38
|
# Configuration provided in Ruby code, in this same process
|
38
|
-
|
39
|
-
|
39
|
+
PROGRAMMATIC = Value.new(4, :programmatic, 'code').freeze
|
40
|
+
|
41
|
+
# Configuration provided by fleet managed stable config
|
42
|
+
FLEET_STABLE = Value.new(3, :fleet_stable, 'fleet_stable_config').freeze
|
43
|
+
|
44
|
+
# Configuration provided via environment variable
|
45
|
+
ENVIRONMENT = Value.new(2, :environment, 'env_var').freeze
|
46
|
+
|
47
|
+
# Configuration provided by local stable config file
|
48
|
+
LOCAL_STABLE = Value.new(1, :local_stable, 'local_stable_config').freeze
|
40
49
|
|
41
50
|
# Configuration that comes from default values
|
42
|
-
DEFAULT = Value.new(0, :default).freeze
|
51
|
+
DEFAULT = Value.new(0, :default, 'default').freeze
|
43
52
|
|
44
53
|
# All precedences, sorted from highest to lowest
|
45
|
-
LIST = [REMOTE_CONFIGURATION, PROGRAMMATIC, DEFAULT].sort.reverse.freeze
|
54
|
+
LIST = [REMOTE_CONFIGURATION, PROGRAMMATIC, FLEET_STABLE, ENVIRONMENT, LOCAL_STABLE, DEFAULT].sort.reverse.freeze
|
46
55
|
end
|
47
56
|
|
48
57
|
def initialize(definition, context)
|
@@ -118,23 +127,29 @@ module Datadog
|
|
118
127
|
end
|
119
128
|
|
120
129
|
def get
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
130
|
+
unless @is_set
|
131
|
+
# Ensures that both the default value and the environment value are set.
|
132
|
+
# This approach handles scenarios where an environment value is unset
|
133
|
+
# by falling back to the default value consistently.
|
134
|
+
set_default_value
|
135
|
+
set_customer_stable_config_value
|
136
|
+
set_env_value
|
137
|
+
set_fleet_stable_config_value
|
125
138
|
end
|
139
|
+
|
140
|
+
@value
|
126
141
|
end
|
127
142
|
|
128
143
|
def reset
|
129
144
|
@value = if definition.resetter
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
145
|
+
# Don't change @is_set to false; custom resetters are
|
146
|
+
# responsible for changing @value back to a good state.
|
147
|
+
# Setting @is_set = false would cause a default to be applied.
|
148
|
+
context_exec(@value, &definition.resetter)
|
149
|
+
else
|
150
|
+
@is_set = false
|
151
|
+
nil
|
152
|
+
end
|
138
153
|
|
139
154
|
# Reset back to the lowest precedence, to allow all `set`s to succeed right after a reset.
|
140
155
|
@precedence_set = Precedence::DEFAULT
|
@@ -192,7 +207,7 @@ module Datadog
|
|
192
207
|
when :bool
|
193
208
|
string_value = value.strip
|
194
209
|
string_value = string_value.downcase
|
195
|
-
string_value == 'true' || string_value == '1'
|
210
|
+
string_value == 'true' || string_value == '1'
|
196
211
|
when :string, NilClass
|
197
212
|
value
|
198
213
|
else
|
@@ -212,20 +227,20 @@ module Datadog
|
|
212
227
|
|
213
228
|
unless valid_type
|
214
229
|
raise_error = if @definition.type_options[:nilable]
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
230
|
+
!value.is_a?(NilClass)
|
231
|
+
else
|
232
|
+
true
|
233
|
+
end
|
219
234
|
end
|
220
235
|
|
221
236
|
if raise_error
|
222
237
|
error_msg = if @definition.type_options[:nilable]
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
238
|
+
"The setting `#{@definition.name}` inside your app's `Datadog.configure` block expects a " \
|
239
|
+
"#{@definition.type} or `nil`, but a `#{value.class}` was provided (#{value.inspect})." \
|
240
|
+
else
|
241
|
+
"The setting `#{@definition.name}` inside your app's `Datadog.configure` block expects a " \
|
242
|
+
"#{@definition.type}, but a `#{value.class}` was provided (#{value.inspect})." \
|
243
|
+
end
|
229
244
|
|
230
245
|
error_msg = "#{error_msg} Please update your `configure` block. "
|
231
246
|
|
@@ -256,7 +271,8 @@ module Datadog
|
|
256
271
|
when NilClass
|
257
272
|
true # No validation is performed when option is typeless
|
258
273
|
else
|
259
|
-
raise
|
274
|
+
raise InvalidDefinitionError,
|
275
|
+
"The option #{@definition.name} is using an unsupported type option `#{@definition.type}`"
|
260
276
|
end
|
261
277
|
end
|
262
278
|
|
@@ -269,7 +285,7 @@ module Datadog
|
|
269
285
|
@resolved_env = resolved_env
|
270
286
|
# Store original value to ensure we can always safely call `#internal_set`
|
271
287
|
# when restoring a value from `@value_per_precedence`, and we are only running `definition.setter`
|
272
|
-
# on the original value, not on a
|
288
|
+
# on the original value, not on a value that has already been processed by `definition.setter`.
|
273
289
|
@value_per_precedence[precedence] = value
|
274
290
|
context_exec(v, old_value, precedence, &definition.after_set) if definition.after_set
|
275
291
|
end
|
@@ -283,39 +299,59 @@ module Datadog
|
|
283
299
|
@context.instance_eval(&block)
|
284
300
|
end
|
285
301
|
|
286
|
-
def
|
302
|
+
def set_default_value
|
303
|
+
set(default_value, precedence: Precedence::DEFAULT)
|
304
|
+
end
|
305
|
+
|
306
|
+
def set_env_value
|
307
|
+
value, resolved_env = get_value_and_resolved_env_from(ENV)
|
308
|
+
set(value, precedence: Precedence::ENVIRONMENT, resolved_env: resolved_env) unless value.nil?
|
309
|
+
end
|
310
|
+
|
311
|
+
def set_customer_stable_config_value
|
312
|
+
customer_config = StableConfig.configuration.dig(:local, :config)
|
313
|
+
return if customer_config.nil?
|
314
|
+
|
315
|
+
value, resolved_env = get_value_and_resolved_env_from(customer_config, source: 'local stable config')
|
316
|
+
set(value, precedence: Precedence::LOCAL_STABLE, resolved_env: resolved_env) unless value.nil?
|
317
|
+
end
|
318
|
+
|
319
|
+
def set_fleet_stable_config_value
|
320
|
+
fleet_config = StableConfig.configuration.dig(:fleet, :config)
|
321
|
+
return if fleet_config.nil?
|
322
|
+
|
323
|
+
value, resolved_env = get_value_and_resolved_env_from(fleet_config, source: 'fleet stable config')
|
324
|
+
set(value, precedence: Precedence::FLEET_STABLE, resolved_env: resolved_env) unless value.nil?
|
325
|
+
end
|
326
|
+
|
327
|
+
def get_value_and_resolved_env_from(env_vars, source: 'environment variable')
|
287
328
|
value = nil
|
288
|
-
precedence = nil
|
289
329
|
resolved_env = nil
|
290
330
|
|
291
331
|
if definition.env
|
292
332
|
Array(definition.env).each do |env|
|
293
|
-
next if
|
333
|
+
next if env_vars[env].nil?
|
294
334
|
|
295
335
|
resolved_env = env
|
296
|
-
value = coerce_env_variable(
|
297
|
-
precedence = Precedence::PROGRAMMATIC
|
336
|
+
value = coerce_env_variable(env_vars[env])
|
298
337
|
break
|
299
338
|
end
|
300
339
|
end
|
301
340
|
|
302
|
-
if value.nil? && definition.deprecated_env &&
|
341
|
+
if value.nil? && definition.deprecated_env && env_vars[definition.deprecated_env]
|
303
342
|
resolved_env = definition.deprecated_env
|
304
|
-
value = coerce_env_variable(
|
305
|
-
precedence = Precedence::PROGRAMMATIC
|
343
|
+
value = coerce_env_variable(env_vars[definition.deprecated_env])
|
306
344
|
|
307
345
|
Datadog::Core.log_deprecation do
|
308
|
-
"#{definition.deprecated_env}
|
346
|
+
"#{definition.deprecated_env} #{source} is deprecated, use #{definition.env} instead."
|
309
347
|
end
|
310
348
|
end
|
311
349
|
|
312
|
-
|
313
|
-
|
314
|
-
set(option_value, precedence: precedence || Precedence::DEFAULT, resolved_env: resolved_env)
|
350
|
+
[value, resolved_env]
|
315
351
|
rescue ArgumentError
|
316
352
|
raise ArgumentError,
|
317
|
-
"Expected
|
318
|
-
"but '#{
|
353
|
+
"Expected #{source} #{resolved_env} to be a #{@definition.type}, " \
|
354
|
+
"but '#{env_vars[resolved_env]}' was provided"
|
319
355
|
end
|
320
356
|
|
321
357
|
# Anchor object that represents a value that is not set.
|
@@ -71,11 +71,11 @@ module Datadog
|
|
71
71
|
validate_options!
|
72
72
|
end
|
73
73
|
|
74
|
-
def env(value)
|
74
|
+
def env(value) # standard:disable Style/TrivialAccessors
|
75
75
|
@env = value
|
76
76
|
end
|
77
77
|
|
78
|
-
def deprecated_env(value)
|
78
|
+
def deprecated_env(value) # standard:disable Style/TrivialAccessors
|
79
79
|
@deprecated_env = value
|
80
80
|
end
|
81
81
|
|
@@ -111,7 +111,7 @@ module Datadog
|
|
111
111
|
|
112
112
|
def type(value, nilable: false)
|
113
113
|
@type = value
|
114
|
-
@type_options = {
|
114
|
+
@type_options = {nilable: nilable}
|
115
115
|
|
116
116
|
value
|
117
117
|
end
|
@@ -156,7 +156,7 @@ module Datadog
|
|
156
156
|
if !@default.nil? && @default_proc
|
157
157
|
raise InvalidOptionError,
|
158
158
|
'Using `default` and `default_proc` is not allowed. Please use one or the other.' \
|
159
|
-
'If you want to store a block as the default value use `default_proc`'\
|
159
|
+
'If you want to store a block as the default value use `default_proc`' \
|
160
160
|
' otherwise use `default`'
|
161
161
|
end
|
162
162
|
end
|
@@ -18,7 +18,7 @@ module Datadog
|
|
18
18
|
module ClassMethods
|
19
19
|
def options
|
20
20
|
# Allows for class inheritance of option definitions
|
21
|
-
@options ||= superclass <= Options ? superclass.options.dup : {}
|
21
|
+
@options ||= (superclass <= Options) ? superclass.options.dup : {}
|
22
22
|
end
|
23
23
|
|
24
24
|
protected
|
@@ -45,7 +45,7 @@ module Datadog
|
|
45
45
|
option_name.to_sym => proc do
|
46
46
|
get_option(option_name)
|
47
47
|
end,
|
48
|
-
"#{option_name}="
|
48
|
+
:"#{option_name}=" => proc do |value|
|
49
49
|
set_option(option_name, value)
|
50
50
|
end
|
51
51
|
}
|
@@ -117,7 +117,7 @@ module Datadog
|
|
117
117
|
end
|
118
118
|
|
119
119
|
def resolved_env(name)
|
120
|
-
|
120
|
+
options[name].resolved_env if options.key?(name)
|
121
121
|
end
|
122
122
|
|
123
123
|
def assert_valid_option!(name)
|
@@ -18,7 +18,7 @@ module Datadog
|
|
18
18
|
module Configuration
|
19
19
|
# Global configuration settings for the Datadog library.
|
20
20
|
# @public_api
|
21
|
-
#
|
21
|
+
# standard:disable Metrics/BlockLength
|
22
22
|
class Settings
|
23
23
|
include Base
|
24
24
|
|
@@ -123,7 +123,7 @@ module Datadog
|
|
123
123
|
# @return [Boolean]
|
124
124
|
option :debug do |o|
|
125
125
|
o.env [Datadog::Core::Configuration::Ext::Diagnostics::ENV_DEBUG_ENABLED,
|
126
|
-
|
126
|
+
Datadog::Core::Configuration::Ext::Diagnostics::ENV_OTEL_LOG_LEVEL]
|
127
127
|
o.default false
|
128
128
|
o.type :bool
|
129
129
|
o.env_parser do |value|
|
@@ -137,7 +137,7 @@ module Datadog
|
|
137
137
|
o.after_set do |enabled|
|
138
138
|
# Enable rich debug print statements.
|
139
139
|
# We do not need to unnecessarily load 'pp' unless in debugging mode.
|
140
|
-
require 'pp' if enabled
|
140
|
+
require 'pp' if enabled # standard:disable Lint/RedundantRequireStatement
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
@@ -313,7 +313,7 @@ module Datadog
|
|
313
313
|
|
314
314
|
# Can be used to enable/disable the collection of heap profiles.
|
315
315
|
#
|
316
|
-
# This feature is
|
316
|
+
# This feature is in preview and disabled by default. Requires Ruby 3.1+.
|
317
317
|
#
|
318
318
|
# @warn To enable heap profiling you are required to also enable allocation profiling.
|
319
319
|
#
|
@@ -326,12 +326,12 @@ module Datadog
|
|
326
326
|
|
327
327
|
# Can be used to enable/disable the collection of heap size profiles.
|
328
328
|
#
|
329
|
-
# This feature is
|
329
|
+
# This feature is in preview and by default is enabled whenever heap profiling is enabled.
|
330
330
|
#
|
331
|
-
# @warn
|
331
|
+
# @warn Heap size profiling depends on allocation and heap profiling, so they must be enabled as well.
|
332
332
|
#
|
333
|
-
# @default `DD_PROFILING_EXPERIMENTAL_HEAP_SIZE_ENABLED` environment variable as a boolean, otherwise
|
334
|
-
#
|
333
|
+
# @default `DD_PROFILING_EXPERIMENTAL_HEAP_SIZE_ENABLED` environment variable as a boolean, otherwise it
|
334
|
+
# follows the value of `experimental_heap_enabled`.
|
335
335
|
option :experimental_heap_size_enabled do |o|
|
336
336
|
o.type :bool
|
337
337
|
o.env 'DD_PROFILING_EXPERIMENTAL_HEAP_SIZE_ENABLED'
|
@@ -341,17 +341,19 @@ module Datadog
|
|
341
341
|
# Can be used to configure the heap sampling rate: a heap sample will be collected for every x allocation
|
342
342
|
# samples.
|
343
343
|
#
|
344
|
-
# The
|
345
|
-
#
|
344
|
+
# The higher the value, the less accuracy in heap tracking but the smaller the overhead.
|
345
|
+
#
|
346
|
+
# If you needed to tweak this, please tell us why on <https://github.com/DataDog/dd-trace-rb/issues/new>,
|
347
|
+
# so we can fix it!
|
346
348
|
#
|
347
349
|
# The effective heap sampling rate in terms of allocations (not allocation samples) can be calculated via
|
348
350
|
# effective_heap_sample_rate = allocation_sample_rate * heap_sample_rate.
|
349
351
|
#
|
350
|
-
# @default `DD_PROFILING_EXPERIMENTAL_HEAP_SAMPLE_RATE` environment variable, otherwise `
|
352
|
+
# @default `DD_PROFILING_EXPERIMENTAL_HEAP_SAMPLE_RATE` environment variable, otherwise `1`.
|
351
353
|
option :experimental_heap_sample_rate do |o|
|
352
354
|
o.type :int
|
353
355
|
o.env 'DD_PROFILING_EXPERIMENTAL_HEAP_SAMPLE_RATE'
|
354
|
-
o.default
|
356
|
+
o.default 1
|
355
357
|
end
|
356
358
|
|
357
359
|
# Can be used to disable checking which version of `libmysqlclient` is being used by the `mysql2` gem.
|
@@ -454,7 +456,7 @@ module Datadog
|
|
454
456
|
o.after_set do |_, _, precedence|
|
455
457
|
unless precedence == Datadog::Core::Configuration::Option::Precedence::DEFAULT
|
456
458
|
Core.log_deprecation(key: :experimental_crash_tracking_enabled) do
|
457
|
-
'The profiling.advanced.experimental_crash_tracking_enabled setting has been deprecated for removal '\
|
459
|
+
'The profiling.advanced.experimental_crash_tracking_enabled setting has been deprecated for removal ' \
|
458
460
|
'and no longer does anything. Please remove it from your Datadog.configure block.'
|
459
461
|
end
|
460
462
|
end
|
@@ -542,6 +544,36 @@ module Datadog
|
|
542
544
|
o.env 'DD_PROFILING_HEAP_CLEAN_AFTER_GC_ENABLED'
|
543
545
|
o.default true
|
544
546
|
end
|
547
|
+
|
548
|
+
# Controls if the profiler should use native filenames for frames in stack traces for functions implemented using
|
549
|
+
# native code. Setting to `false` will make the profiler fall back to default Ruby stack trace behavior (only show .rb files).
|
550
|
+
#
|
551
|
+
# @default true
|
552
|
+
option :native_filenames_enabled do |o|
|
553
|
+
o.type :bool
|
554
|
+
o.env 'DD_PROFILING_NATIVE_FILENAMES_ENABLED'
|
555
|
+
o.default true
|
556
|
+
end
|
557
|
+
|
558
|
+
# Controls if the profiler should sample directly from the signal handler.
|
559
|
+
# Sampling directly from the signal handler improves accuracy of the data collected.
|
560
|
+
#
|
561
|
+
# We recommend using this setting with Ruby 3.2.5+ / Ruby 3.3.4+ and above
|
562
|
+
# as they include additional safety measures added in https://github.com/ruby/ruby/pull/11036.
|
563
|
+
# We have not validated it thoroughly with earlier versions, but in practice it should work on Ruby 3.0+
|
564
|
+
# (the key change was https://github.com/ruby/ruby/pull/3296).
|
565
|
+
#
|
566
|
+
# Enabling this on Ruby 2 is not recommended as it may cause VM crashes and/or incorrect data.
|
567
|
+
#
|
568
|
+
# @default true on Ruby 3.2.5+ / Ruby 3.3.4+, false on older Rubies
|
569
|
+
option :sighandler_sampling_enabled do |o|
|
570
|
+
o.type :bool
|
571
|
+
o.env 'DD_PROFILING_SIGHANDLER_SAMPLING_ENABLED'
|
572
|
+
o.default do
|
573
|
+
Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.2.5') &&
|
574
|
+
!(RUBY_VERSION.start_with?('3.3.') && Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.3.4'))
|
575
|
+
end
|
576
|
+
end
|
545
577
|
end
|
546
578
|
|
547
579
|
# @public_api
|
@@ -570,6 +602,12 @@ module Datadog
|
|
570
602
|
o.type :bool
|
571
603
|
end
|
572
604
|
|
605
|
+
option :experimental_runtime_id_enabled do |o|
|
606
|
+
o.type :bool
|
607
|
+
o.env ['DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED', 'DD_RUNTIME_METRICS_RUNTIME_ID_ENABLED']
|
608
|
+
o.default false
|
609
|
+
end
|
610
|
+
|
573
611
|
option :opts, default: {}, type: :hash
|
574
612
|
option :statsd
|
575
613
|
end
|
@@ -619,38 +657,31 @@ module Datadog
|
|
619
657
|
o.type :hash, nilable: true
|
620
658
|
o.env [Core::Environment::Ext::ENV_TAGS, Core::Environment::Ext::ENV_OTEL_RESOURCE_ATTRIBUTES]
|
621
659
|
o.env_parser do |env_value|
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
when 'deployment.environment'
|
645
|
-
tags['env'] = value
|
646
|
-
when 'service.version'
|
647
|
-
tags['version'] = value
|
648
|
-
when 'service.name'
|
649
|
-
tags['service'] = value
|
650
|
-
else
|
651
|
-
tags[key] = value
|
660
|
+
# Parses a string containing key-value pairs and returns a hash.
|
661
|
+
# Key-value pairs are delimited by ':' OR `=`, and pairs are separated by whitespace, comma, OR BOTH.
|
662
|
+
result = {}
|
663
|
+
unless env_value.nil? || env_value.empty?
|
664
|
+
# falling back to comma as separator
|
665
|
+
sep = env_value.include?(',') ? ',' : ' '
|
666
|
+
# split by separator
|
667
|
+
env_value.split(sep).each do |tag|
|
668
|
+
tag.strip!
|
669
|
+
next if tag.empty?
|
670
|
+
|
671
|
+
# tag by : or = (for OpenTelemetry)
|
672
|
+
key, val = tag.split(/[:=]/, 2).map(&:strip)
|
673
|
+
val ||= ''
|
674
|
+
# maps OpenTelemetry semantic attributes to Datadog tags
|
675
|
+
key = case key.downcase
|
676
|
+
when 'deployment.environment' then 'env'
|
677
|
+
when 'service.version' then 'version'
|
678
|
+
when 'service.name' then 'service'
|
679
|
+
else key
|
680
|
+
end
|
681
|
+
result[key] = val unless key.empty?
|
652
682
|
end
|
653
683
|
end
|
684
|
+
result
|
654
685
|
end
|
655
686
|
o.setter do |new_value, old_value|
|
656
687
|
raw_tags = new_value || {}
|
@@ -889,6 +920,16 @@ module Datadog
|
|
889
920
|
o.env Core::Telemetry::Ext::ENV_LOG_COLLECTION
|
890
921
|
o.default true
|
891
922
|
end
|
923
|
+
|
924
|
+
# For internal use only.
|
925
|
+
# Enables telemetry debugging through the Datadog platform.
|
926
|
+
#
|
927
|
+
# @default `false`.
|
928
|
+
# @return [Boolean]
|
929
|
+
option :debug do |o|
|
930
|
+
o.type :bool
|
931
|
+
o.default false
|
932
|
+
end
|
892
933
|
end
|
893
934
|
|
894
935
|
# Remote configuration
|
@@ -958,11 +999,35 @@ module Datadog
|
|
958
999
|
end
|
959
1000
|
end
|
960
1001
|
|
1002
|
+
# Tracer specific configuration starting with APM (e.g. DD_APM_TRACING_ENABLED).
|
1003
|
+
# @public_api
|
1004
|
+
settings :apm do
|
1005
|
+
# Tracing as a transport
|
1006
|
+
# @public_api
|
1007
|
+
settings :tracing do
|
1008
|
+
# Enables tracing as transport.
|
1009
|
+
# Disabling it will set sampling priority to -1 (FORCE_DROP) on most traces,
|
1010
|
+
# (which tells to the agent to drop these traces)
|
1011
|
+
# except heartbeat ones (1 per minute) and manually kept ones (sampling priority to 2) (e.g. appsec events)
|
1012
|
+
#
|
1013
|
+
# This is different than `DD_TRACE_ENABLED`, which completely disables tracing (sends no trace at all),
|
1014
|
+
# while this will send heartbeat traces (1 per minute) so that the service is considered alive in the backend.
|
1015
|
+
#
|
1016
|
+
# @default `DD_APM_TRACING_ENABLED` environment variable, otherwise `true`
|
1017
|
+
# @return [Boolean]
|
1018
|
+
option :enabled do |o|
|
1019
|
+
o.env Configuration::Ext::APM::ENV_TRACING_ENABLED
|
1020
|
+
o.default true
|
1021
|
+
o.type :bool
|
1022
|
+
end
|
1023
|
+
end
|
1024
|
+
end
|
1025
|
+
|
961
1026
|
# TODO: Tracing should manage its own settings.
|
962
1027
|
# Keep this extension here for now to keep things working.
|
963
1028
|
extend Datadog::Tracing::Configuration::Settings
|
964
1029
|
end
|
965
|
-
#
|
1030
|
+
# standard:enable Metrics/BlockLength
|
966
1031
|
end
|
967
1032
|
end
|
968
1033
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Datadog
|
4
|
+
module Core
|
5
|
+
module Configuration
|
6
|
+
# Import config from config files (fleet automation)
|
7
|
+
module StableConfig
|
8
|
+
def self.extract_configuration
|
9
|
+
if (libdatadog_api_failure = Datadog::Core::LIBDATADOG_API_FAILURE)
|
10
|
+
Datadog.config_init_logger.debug("Cannot enable stable config: #{libdatadog_api_failure}")
|
11
|
+
return {}
|
12
|
+
end
|
13
|
+
Configurator.new.get
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.configuration
|
17
|
+
@configuration ||= StableConfig.extract_configuration
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -172,6 +172,10 @@ module Datadog
|
|
172
172
|
end
|
173
173
|
end
|
174
174
|
|
175
|
+
def config_init_logger
|
176
|
+
configuration? ? logger : logger_without_configuration
|
177
|
+
end
|
178
|
+
|
175
179
|
# Gracefully shuts down all components.
|
176
180
|
#
|
177
181
|
# Components will still respond to method calls as usual,
|
@@ -231,19 +235,21 @@ module Datadog
|
|
231
235
|
end
|
232
236
|
|
233
237
|
COMPONENTS_WRITE_LOCK.synchronize do
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
nil
|
243
|
-
end
|
238
|
+
yield write_components
|
239
|
+
rescue ThreadError => e
|
240
|
+
logger_without_components.error(
|
241
|
+
'Detected deadlock during datadog initialization. ' \
|
242
|
+
'Please report this at https://github.com/datadog/dd-trace-rb/blob/master/CONTRIBUTING.md#found-a-bug' \
|
243
|
+
"\n\tSource:\n\t#{Array(e.backtrace).join("\n\t")}"
|
244
|
+
)
|
245
|
+
nil
|
244
246
|
end
|
245
247
|
end
|
246
248
|
|
249
|
+
def configuration?
|
250
|
+
(defined?(@configuration) && @configuration) != nil
|
251
|
+
end
|
252
|
+
|
247
253
|
def components?
|
248
254
|
# This does not need to grab the COMPONENTS_READ_LOCK because it's not returning the components
|
249
255
|
(defined?(@components) && @components) != nil
|
@@ -259,12 +265,14 @@ module Datadog
|
|
259
265
|
components = Components.new(settings)
|
260
266
|
|
261
267
|
# Carry over state from existing components to the new ones.
|
262
|
-
# Currently
|
263
|
-
#
|
264
|
-
#
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
+
# Currently:
|
269
|
+
# 1. If we already started the remote component (which
|
270
|
+
# happens after a request goes through installed Rack middleware),
|
271
|
+
# we will start the new remote component as well.
|
272
|
+
# 2. If telemetry has been enabled and is enabled in the new
|
273
|
+
# component tree, we send AppConfigurationChange event instead
|
274
|
+
# of AppStarted event.
|
275
|
+
old_state = old.state
|
268
276
|
|
269
277
|
old.shutdown!(components)
|
270
278
|
components.startup!(settings, old_state: old_state)
|
@@ -274,6 +282,7 @@ module Datadog
|
|
274
282
|
def logger_without_components
|
275
283
|
# Use default logger without initializing components.
|
276
284
|
# This enables logging during initialization, otherwise we'd run into deadlocks.
|
285
|
+
|
277
286
|
@temp_logger ||= begin
|
278
287
|
logger = configuration.logger.instance || Core::Logger.new($stdout)
|
279
288
|
logger.level = configuration.diagnostics.debug ? ::Logger::DEBUG : configuration.logger.level
|
@@ -281,6 +290,21 @@ module Datadog
|
|
281
290
|
end
|
282
291
|
end
|
283
292
|
|
293
|
+
def logger_without_configuration
|
294
|
+
# There's rare cases where we need to use logger during configuration initialization,
|
295
|
+
# such as reading stable config. In this case we cannot access configuration.
|
296
|
+
|
297
|
+
@temp_config_logger ||= begin
|
298
|
+
debug_env_value = ENV[Ext::Diagnostics::ENV_DEBUG_ENABLED]&.strip&.downcase
|
299
|
+
debug_value = debug_env_value == 'true' || debug_env_value == '1'
|
300
|
+
|
301
|
+
logger = Core::Logger.new($stdout)
|
302
|
+
# We cannot access config and the default level is INFO, so we need to set the level manually
|
303
|
+
logger.level = debug_value ? ::Logger::DEBUG : ::Logger::INFO
|
304
|
+
logger
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
284
308
|
# Called from our at_exit hook whenever there was a pending Interrupt exception (e.g. typically due to ctrl+c)
|
285
309
|
# to print a nice message whenever we're taking a bit longer than usual to finish the process.
|
286
310
|
def handle_interrupt_shutdown!
|