datadog 2.7.1 → 2.18.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 +353 -1
- data/ext/datadog_profiling_native_extension/clock_id.h +2 -2
- data/ext/datadog_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +78 -102
- data/ext/datadog_profiling_native_extension/collectors_discrete_dynamic_sampler.c +1 -1
- data/ext/datadog_profiling_native_extension/collectors_discrete_dynamic_sampler.h +1 -1
- data/ext/datadog_profiling_native_extension/collectors_idle_sampling_helper.c +16 -16
- data/ext/datadog_profiling_native_extension/collectors_stack.c +235 -57
- data/ext/datadog_profiling_native_extension/collectors_stack.h +21 -5
- data/ext/datadog_profiling_native_extension/collectors_thread_context.c +376 -156
- 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 +14 -8
- data/ext/datadog_profiling_native_extension/gvl_profiling_helper.c +2 -0
- data/ext/datadog_profiling_native_extension/gvl_profiling_helper.h +0 -8
- data/ext/datadog_profiling_native_extension/heap_recorder.c +295 -532
- data/ext/datadog_profiling_native_extension/heap_recorder.h +6 -8
- data/ext/datadog_profiling_native_extension/http_transport.c +64 -98
- 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 +69 -1
- data/ext/datadog_profiling_native_extension/private_vm_api_access.h +16 -4
- data/ext/datadog_profiling_native_extension/profiling.c +19 -8
- data/ext/datadog_profiling_native_extension/ruby_helpers.c +9 -21
- data/ext/datadog_profiling_native_extension/ruby_helpers.h +2 -10
- data/ext/datadog_profiling_native_extension/stack_recorder.c +231 -181
- data/ext/datadog_profiling_native_extension/stack_recorder.h +2 -2
- data/ext/datadog_profiling_native_extension/time_helpers.h +1 -1
- data/ext/datadog_profiling_native_extension/unsafe_api_calls_check.c +47 -0
- data/ext/datadog_profiling_native_extension/unsafe_api_calls_check.h +31 -0
- data/ext/libdatadog_api/crashtracker.c +17 -15
- 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 +49 -0
- 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 +65 -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 +623 -253
- data/lib/datadog/appsec/assets/waf_rules/strict.json +69 -107
- data/lib/datadog/appsec/autoload.rb +1 -1
- data/lib/datadog/appsec/component.rb +49 -65
- data/lib/datadog/appsec/compressed_json.rb +40 -0
- data/lib/datadog/appsec/configuration/settings.rb +212 -27
- data/lib/datadog/appsec/context.rb +74 -0
- data/lib/datadog/appsec/contrib/active_record/instrumentation.rb +92 -0
- data/lib/datadog/appsec/contrib/active_record/integration.rb +41 -0
- data/lib/datadog/appsec/contrib/active_record/patcher.rb +101 -0
- data/lib/datadog/appsec/contrib/auto_instrument.rb +1 -1
- data/lib/datadog/appsec/contrib/devise/configuration.rb +52 -0
- 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 +33 -25
- 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} +3 -3
- data/lib/datadog/appsec/contrib/devise/tracking_middleware.rb +106 -0
- data/lib/datadog/appsec/contrib/excon/integration.rb +41 -0
- data/lib/datadog/appsec/contrib/excon/patcher.rb +28 -0
- data/lib/datadog/appsec/contrib/excon/ssrf_detection_middleware.rb +42 -0
- data/lib/datadog/appsec/contrib/faraday/connection_patch.rb +22 -0
- data/lib/datadog/appsec/contrib/faraday/integration.rb +42 -0
- data/lib/datadog/appsec/contrib/faraday/patcher.rb +53 -0
- data/lib/datadog/appsec/contrib/faraday/rack_builder_patch.rb +22 -0
- data/lib/datadog/appsec/contrib/faraday/ssrf_detection_middleware.rb +41 -0
- data/lib/datadog/appsec/contrib/graphql/appsec_trace.rb +1 -7
- data/lib/datadog/appsec/contrib/graphql/gateway/watcher.rb +17 -30
- data/lib/datadog/appsec/contrib/graphql/integration.rb +1 -1
- data/lib/datadog/appsec/contrib/graphql/patcher.rb +0 -3
- data/lib/datadog/appsec/contrib/rack/ext.rb +34 -0
- data/lib/datadog/appsec/contrib/rack/gateway/response.rb +3 -3
- data/lib/datadog/appsec/contrib/rack/gateway/watcher.rb +78 -98
- data/lib/datadog/appsec/contrib/rack/integration.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/patcher.rb +0 -3
- data/lib/datadog/appsec/contrib/rack/request_body_middleware.rb +10 -11
- data/lib/datadog/appsec/contrib/rack/request_middleware.rb +73 -78
- data/lib/datadog/appsec/contrib/rails/gateway/watcher.rb +16 -33
- data/lib/datadog/appsec/contrib/rails/integration.rb +1 -1
- data/lib/datadog/appsec/contrib/rails/patcher.rb +25 -38
- data/lib/datadog/appsec/contrib/rest_client/integration.rb +45 -0
- data/lib/datadog/appsec/contrib/rest_client/patcher.rb +28 -0
- data/lib/datadog/appsec/contrib/rest_client/request_ssrf_detection_patch.rb +38 -0
- data/lib/datadog/appsec/contrib/sinatra/gateway/watcher.rb +31 -68
- data/lib/datadog/appsec/contrib/sinatra/integration.rb +1 -1
- data/lib/datadog/appsec/contrib/sinatra/patcher.rb +5 -31
- data/lib/datadog/appsec/event.rb +96 -135
- data/lib/datadog/appsec/ext.rb +12 -3
- 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/collector.rb +38 -0
- data/lib/datadog/appsec/metrics/exporter.rb +35 -0
- data/lib/datadog/appsec/metrics/telemetry.rb +23 -0
- data/lib/datadog/appsec/metrics.rb +13 -0
- data/lib/datadog/appsec/monitor/gateway/watcher.rb +52 -32
- data/lib/datadog/appsec/processor/rule_loader.rb +30 -36
- data/lib/datadog/appsec/remote.rb +31 -57
- data/lib/datadog/appsec/response.rb +19 -85
- data/lib/datadog/appsec/security_engine/engine.rb +194 -0
- data/lib/datadog/appsec/security_engine/result.rb +67 -0
- data/lib/datadog/appsec/security_engine/runner.rb +87 -0
- data/lib/datadog/appsec/security_engine.rb +9 -0
- data/lib/datadog/appsec/security_event.rb +39 -0
- data/lib/datadog/appsec/utils.rb +0 -2
- data/lib/datadog/appsec.rb +22 -12
- data/lib/datadog/auto_instrument.rb +3 -0
- 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 -18
- data/lib/datadog/core/configuration/agentless_settings_resolver.rb +176 -0
- data/lib/datadog/core/configuration/components.rb +74 -32
- data/lib/datadog/core/configuration/components_state.rb +23 -0
- data/lib/datadog/core/configuration/ext.rb +5 -1
- data/lib/datadog/core/configuration/option.rb +81 -45
- data/lib/datadog/core/configuration/option_definition.rb +6 -4
- data/lib/datadog/core/configuration/options.rb +3 -3
- data/lib/datadog/core/configuration/settings.rb +121 -50
- data/lib/datadog/core/configuration/stable_config.rb +22 -0
- data/lib/datadog/core/configuration.rb +43 -11
- data/lib/datadog/{tracing → core}/contrib/rails/utils.rb +1 -3
- data/lib/datadog/core/crashtracking/component.rb +4 -13
- 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 +17 -1
- data/lib/datadog/core/environment/agent_info.rb +78 -0
- 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 +27 -27
- 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/capabilities.rb +6 -0
- data/lib/datadog/core/remote/client.rb +107 -92
- data/lib/datadog/core/remote/component.rb +18 -19
- 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/api.rb +13 -18
- data/lib/datadog/core/remote/transport/http/client.rb +5 -4
- data/lib/datadog/core/remote/transport/http/config.rb +27 -55
- data/lib/datadog/core/remote/transport/http/negotiation.rb +8 -51
- data/lib/datadog/core/remote/transport/http.rb +25 -94
- data/lib/datadog/core/remote/transport/negotiation.rb +17 -4
- data/lib/datadog/core/remote/worker.rb +10 -7
- 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 +84 -49
- 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 +269 -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 -383
- data/lib/datadog/core/telemetry/ext.rb +1 -0
- 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 +12 -6
- data/lib/datadog/core/telemetry/metric.rb +28 -6
- 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 +128 -25
- 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/adapters/unix_socket.rb +1 -1
- data/lib/datadog/{tracing → core}/transport/http/api/instance.rb +18 -1
- data/lib/datadog/core/transport/http/api/spec.rb +36 -0
- data/lib/datadog/{tracing → core}/transport/http/builder.rb +53 -31
- data/lib/datadog/core/transport/http/env.rb +8 -0
- data/lib/datadog/core/transport/http.rb +75 -0
- data/lib/datadog/core/transport/response.rb +4 -0
- 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/base.rb +115 -0
- data/lib/datadog/di/boot.rb +34 -0
- data/lib/datadog/di/code_tracker.rb +26 -15
- data/lib/datadog/di/component.rb +23 -14
- data/lib/datadog/di/configuration/settings.rb +25 -1
- data/lib/datadog/di/contrib/active_record.rb +1 -0
- data/lib/datadog/di/contrib/railtie.rb +15 -0
- data/lib/datadog/di/contrib.rb +28 -0
- data/lib/datadog/di/error.rb +5 -0
- data/lib/datadog/di/instrumenter.rb +162 -21
- data/lib/datadog/di/logger.rb +30 -0
- data/lib/datadog/di/preload.rb +18 -0
- data/lib/datadog/di/probe.rb +14 -7
- data/lib/datadog/di/probe_builder.rb +1 -0
- data/lib/datadog/di/probe_manager.rb +11 -5
- data/lib/datadog/di/probe_notification_builder.rb +54 -38
- data/lib/datadog/di/probe_notifier_worker.rb +60 -26
- data/lib/datadog/di/redactor.rb +0 -1
- data/lib/datadog/di/remote.rb +147 -0
- data/lib/datadog/di/serializer.rb +19 -8
- data/lib/datadog/di/transport/diagnostics.rb +62 -0
- data/lib/datadog/di/transport/http/api.rb +42 -0
- data/lib/datadog/di/transport/http/client.rb +47 -0
- data/lib/datadog/di/transport/http/diagnostics.rb +65 -0
- data/lib/datadog/di/transport/http/input.rb +77 -0
- data/lib/datadog/di/transport/http.rb +57 -0
- data/lib/datadog/di/transport/input.rb +70 -0
- data/lib/datadog/di/utils.rb +103 -0
- data/lib/datadog/di.rb +14 -76
- 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.rb +15 -3
- data/lib/datadog/kit/identity.rb +9 -5
- 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 +4 -0
- data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +1 -0
- data/lib/datadog/profiling/collectors/info.rb +3 -0
- data/lib/datadog/profiling/collectors/thread_context.rb +17 -2
- data/lib/datadog/profiling/component.rb +64 -82
- data/lib/datadog/profiling/encoded_profile.rb +11 -0
- data/lib/datadog/profiling/exporter.rb +3 -4
- data/lib/datadog/profiling/ext.rb +0 -14
- data/lib/datadog/profiling/flush.rb +5 -8
- data/lib/datadog/profiling/http_transport.rb +8 -87
- data/lib/datadog/profiling/load_native_extension.rb +1 -33
- data/lib/datadog/profiling/profiler.rb +2 -0
- data/lib/datadog/profiling/scheduler.rb +10 -2
- data/lib/datadog/profiling/stack_recorder.rb +9 -9
- data/lib/datadog/profiling/tag_builder.rb +5 -41
- data/lib/datadog/profiling/tasks/setup.rb +2 -0
- data/lib/datadog/profiling.rb +6 -2
- data/lib/datadog/tracing/analytics.rb +1 -1
- data/lib/datadog/tracing/component.rb +16 -12
- data/lib/datadog/tracing/configuration/ext.rb +8 -1
- data/lib/datadog/tracing/configuration/settings.rb +22 -10
- data/lib/datadog/tracing/context_provider.rb +1 -1
- data/lib/datadog/tracing/contrib/action_cable/integration.rb +5 -2
- data/lib/datadog/tracing/contrib/action_mailer/integration.rb +6 -2
- 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/action_pack/integration.rb +5 -2
- data/lib/datadog/tracing/contrib/action_view/integration.rb +5 -2
- data/lib/datadog/tracing/contrib/active_job/integration.rb +5 -2
- data/lib/datadog/tracing/contrib/active_record/integration.rb +7 -3
- data/lib/datadog/tracing/contrib/active_support/cache/events/cache.rb +7 -2
- data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +36 -1
- data/lib/datadog/tracing/contrib/active_support/cache/patcher.rb +4 -0
- data/lib/datadog/tracing/contrib/active_support/cache/redis.rb +14 -4
- data/lib/datadog/tracing/contrib/active_support/configuration/settings.rb +10 -0
- data/lib/datadog/tracing/contrib/active_support/integration.rb +5 -2
- data/lib/datadog/tracing/contrib/auto_instrument.rb +2 -2
- data/lib/datadog/tracing/contrib/aws/instrumentation.rb +10 -0
- data/lib/datadog/tracing/contrib/aws/integration.rb +3 -0
- data/lib/datadog/tracing/contrib/aws/parsed_context.rb +5 -1
- data/lib/datadog/tracing/contrib/concurrent_ruby/integration.rb +3 -0
- data/lib/datadog/tracing/contrib/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/elasticsearch/configuration/settings.rb +4 -0
- data/lib/datadog/tracing/contrib/elasticsearch/patcher.rb +6 -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/extensions.rb +29 -3
- data/lib/datadog/tracing/contrib/faraday/middleware.rb +5 -3
- data/lib/datadog/tracing/contrib/graphql/configuration/error_extension_env_parser.rb +21 -0
- data/lib/datadog/tracing/contrib/graphql/configuration/settings.rb +11 -0
- data/lib/datadog/tracing/contrib/graphql/ext.rb +5 -0
- data/lib/datadog/tracing/contrib/graphql/unified_trace.rb +102 -11
- 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/http/integration.rb +3 -0
- 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/httprb/integration.rb +3 -0
- data/lib/datadog/tracing/contrib/kafka/integration.rb +3 -0
- 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/integration.rb +3 -0
- data/lib/datadog/tracing/contrib/mongodb/subscribers.rb +18 -1
- 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/integration.rb +3 -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/presto/integration.rb +3 -0
- data/lib/datadog/tracing/contrib/rack/header_collection.rb +11 -1
- data/lib/datadog/tracing/contrib/rack/integration.rb +2 -2
- data/lib/datadog/tracing/contrib/rack/middlewares.rb +1 -1
- data/lib/datadog/tracing/contrib/rack/request_queue.rb +1 -1
- data/lib/datadog/tracing/contrib/rails/framework.rb +2 -2
- data/lib/datadog/tracing/contrib/rails/patcher.rb +1 -1
- data/lib/datadog/tracing/contrib/rest_client/integration.rb +3 -0
- 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/span_attribute_schema.rb +6 -1
- 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/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 +22 -5
- data/lib/datadog/tracing/span_event.rb +124 -4
- data/lib/datadog/tracing/span_operation.rb +52 -16
- data/lib/datadog/tracing/sync_writer.rb +10 -6
- 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 +66 -14
- data/lib/datadog/tracing/transport/http/api.rb +5 -4
- data/lib/datadog/tracing/transport/http/client.rb +5 -4
- data/lib/datadog/tracing/transport/http/traces.rb +13 -44
- data/lib/datadog/tracing/transport/http.rb +13 -70
- data/lib/datadog/tracing/transport/serializable_trace.rb +31 -7
- data/lib/datadog/tracing/transport/trace_formatter.rb +7 -0
- data/lib/datadog/tracing/transport/traces.rb +47 -13
- data/lib/datadog/tracing/utils.rb +1 -1
- data/lib/datadog/tracing/workers/trace_writer.rb +8 -5
- data/lib/datadog/tracing/workers.rb +5 -4
- data/lib/datadog/tracing/writer.rb +10 -6
- data/lib/datadog/tracing.rb +16 -3
- data/lib/datadog/version.rb +2 -2
- data/lib/datadog.rb +2 -0
- metadata +149 -54
- data/ext/datadog_profiling_loader/datadog_profiling_loader.c +0 -142
- data/ext/datadog_profiling_loader/extconf.rb +0 -60
- 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 -57
- data/lib/datadog/appsec/contrib/devise/patcher/authenticatable_patch.rb +0 -77
- data/lib/datadog/appsec/contrib/devise/patcher/registration_controller_patch.rb +0 -54
- data/lib/datadog/appsec/contrib/devise/resource.rb +0 -35
- data/lib/datadog/appsec/contrib/devise/tracking.rb +0 -57
- data/lib/datadog/appsec/contrib/graphql/reactive/multiplex.rb +0 -46
- data/lib/datadog/appsec/contrib/patcher.rb +0 -12
- data/lib/datadog/appsec/contrib/rack/reactive/request.rb +0 -69
- data/lib/datadog/appsec/contrib/rack/reactive/request_body.rb +0 -47
- data/lib/datadog/appsec/contrib/rack/reactive/response.rb +0 -53
- data/lib/datadog/appsec/contrib/rails/reactive/action.rb +0 -53
- data/lib/datadog/appsec/contrib/sinatra/ext.rb +0 -14
- data/lib/datadog/appsec/contrib/sinatra/reactive/routed.rb +0 -48
- data/lib/datadog/appsec/monitor/reactive/set_user.rb +0 -45
- data/lib/datadog/appsec/processor/actions.rb +0 -49
- data/lib/datadog/appsec/processor/context.rb +0 -107
- data/lib/datadog/appsec/processor/rule_merger.rb +0 -170
- data/lib/datadog/appsec/processor.rb +0 -106
- data/lib/datadog/appsec/reactive/address_hash.rb +0 -22
- data/lib/datadog/appsec/reactive/engine.rb +0 -47
- data/lib/datadog/appsec/reactive/operation.rb +0 -68
- data/lib/datadog/appsec/reactive/subscriber.rb +0 -19
- data/lib/datadog/appsec/scope.rb +0 -58
- data/lib/datadog/appsec/utils/trace_operation.rb +0 -15
- data/lib/datadog/core/crashtracking/agent_base_url.rb +0 -21
- data/lib/datadog/core/remote/transport/http/api/instance.rb +0 -39
- data/lib/datadog/core/remote/transport/http/api/spec.rb +0 -21
- data/lib/datadog/core/remote/transport/http/builder.rb +0 -219
- 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
- data/lib/datadog/di/transport.rb +0 -81
- data/lib/datadog/tracing/transport/http/api/spec.rb +0 -19
@@ -14,7 +14,10 @@ module Datadog
|
|
14
14
|
#
|
15
15
|
# This class acts both as a collector (collecting data) as well as a recorder (records/serializes it)
|
16
16
|
class CodeProvenance
|
17
|
-
def initialize(
|
17
|
+
def initialize(
|
18
|
+
standard_library_path: RbConfig::CONFIG.fetch("rubylibdir"),
|
19
|
+
ruby_native_filename: Datadog::Profiling::Collectors::Stack._native_ruby_native_filename
|
20
|
+
)
|
18
21
|
@libraries_by_name = {}
|
19
22
|
@libraries_by_path = {}
|
20
23
|
@seen_files = Set.new
|
@@ -26,6 +29,7 @@ module Datadog
|
|
26
29
|
name: "stdlib",
|
27
30
|
version: RUBY_VERSION,
|
28
31
|
path: standard_library_path,
|
32
|
+
extra_path: ruby_native_filename,
|
29
33
|
)
|
30
34
|
)
|
31
35
|
end
|
@@ -37,12 +41,8 @@ module Datadog
|
|
37
41
|
self
|
38
42
|
end
|
39
43
|
|
40
|
-
def generate
|
41
|
-
seen_libraries
|
42
|
-
end
|
43
|
-
|
44
44
|
def generate_json
|
45
|
-
JSON.
|
45
|
+
JSON.generate(v1: seen_libraries.to_a)
|
46
46
|
end
|
47
47
|
|
48
48
|
private
|
@@ -79,7 +79,15 @@ module Datadog
|
|
79
79
|
loaded_specs.each do |spec|
|
80
80
|
next if libraries_by_name.key?(spec.name)
|
81
81
|
|
82
|
-
record_library(
|
82
|
+
record_library(
|
83
|
+
Library.new(
|
84
|
+
kind: "library",
|
85
|
+
name: spec.name,
|
86
|
+
version: spec.version,
|
87
|
+
path: spec.gem_dir,
|
88
|
+
extra_path: (spec.extension_dir if spec.extensions.any?),
|
89
|
+
)
|
90
|
+
)
|
83
91
|
recorded_library = true
|
84
92
|
end
|
85
93
|
|
@@ -110,11 +118,12 @@ module Datadog
|
|
110
118
|
class Library
|
111
119
|
attr_reader :kind, :name, :version
|
112
120
|
|
113
|
-
def initialize(kind:, name:, version:, path:)
|
121
|
+
def initialize(kind:, name:, version:, path:, extra_path: nil)
|
122
|
+
extra_path = nil if extra_path&.empty?
|
114
123
|
@kind = kind.freeze
|
115
124
|
@name = name.dup.freeze
|
116
125
|
@version = version.to_s.dup.freeze
|
117
|
-
@paths = [path.dup.freeze].freeze
|
126
|
+
@paths = [path.dup.freeze, extra_path.dup.freeze].compact.freeze
|
118
127
|
freeze
|
119
128
|
end
|
120
129
|
|
@@ -33,6 +33,9 @@ module Datadog
|
|
33
33
|
Datadog.logger.warn(
|
34
34
|
"Profiling dynamic sampling rate disabled. This should only be used for testing, and will increase overhead!"
|
35
35
|
)
|
36
|
+
Datadog::Core::Telemetry::Logger.error(
|
37
|
+
"Profiling dynamic sampling rate disabled. This should only be used for testing, and will increase overhead!"
|
38
|
+
)
|
36
39
|
end
|
37
40
|
|
38
41
|
self.class._native_initialize(
|
@@ -77,6 +80,7 @@ module Datadog
|
|
77
80
|
"Cause: #{e.class.name} #{e.message} Location: #{Array(e.backtrace).first}"
|
78
81
|
)
|
79
82
|
on_failure_proc&.call
|
83
|
+
Datadog::Core::Telemetry::Logger.report(e, description: "CpuAndWallTimeWorker thread error", pii_safe: true)
|
80
84
|
end
|
81
85
|
@worker_thread.name = self.class.name # Repeated from above to make sure thread gets named asap
|
82
86
|
@worker_thread.thread_variable_set(:fork_safe, true)
|
@@ -41,6 +41,7 @@ module Datadog
|
|
41
41
|
"IdleSamplingHelper thread error. " \
|
42
42
|
"Cause: #{e.class.name} #{e.message} Location: #{Array(e.backtrace).first}"
|
43
43
|
)
|
44
|
+
Datadog::Core::Telemetry::Logger.report(e, description: "IdleSamplingHelper thread error", pii_safe: true)
|
44
45
|
end
|
45
46
|
@worker_thread.name = self.class.name # Repeated from above to make sure thread gets named asap
|
46
47
|
@worker_thread.thread_variable_set(:fork_safe, true)
|
@@ -31,6 +31,9 @@ module Datadog
|
|
31
31
|
# Instead of trying to figure out real process start time by checking
|
32
32
|
# /proc or some other complex/non-portable way, approximate start time
|
33
33
|
# by time of requirement of this file.
|
34
|
+
#
|
35
|
+
# Note: this does not use Core::Utils::Time.now because this constant
|
36
|
+
# gets initialized before a user has a chance to configure the library.
|
34
37
|
START_TIME = Time.now.utc.freeze
|
35
38
|
|
36
39
|
def collect_platform_info
|
@@ -21,7 +21,8 @@ module Datadog
|
|
21
21
|
endpoint_collection_enabled:,
|
22
22
|
timeline_enabled:,
|
23
23
|
waiting_for_gvl_threshold_ns:,
|
24
|
-
otel_context_enabled
|
24
|
+
otel_context_enabled:,
|
25
|
+
native_filenames_enabled:
|
25
26
|
)
|
26
27
|
tracer_context_key = safely_extract_context_key_from(tracer)
|
27
28
|
self.class._native_initialize(
|
@@ -33,6 +34,7 @@ module Datadog
|
|
33
34
|
timeline_enabled: timeline_enabled,
|
34
35
|
waiting_for_gvl_threshold_ns: waiting_for_gvl_threshold_ns,
|
35
36
|
otel_context_enabled: otel_context_enabled,
|
37
|
+
native_filenames_enabled: validate_native_filenames(native_filenames_enabled),
|
36
38
|
)
|
37
39
|
end
|
38
40
|
|
@@ -44,6 +46,7 @@ module Datadog
|
|
44
46
|
timeline_enabled: false,
|
45
47
|
waiting_for_gvl_threshold_ns: 10_000_000,
|
46
48
|
otel_context_enabled: false,
|
49
|
+
native_filenames_enabled: true,
|
47
50
|
**options
|
48
51
|
)
|
49
52
|
new(
|
@@ -54,13 +57,14 @@ module Datadog
|
|
54
57
|
timeline_enabled: timeline_enabled,
|
55
58
|
waiting_for_gvl_threshold_ns: waiting_for_gvl_threshold_ns,
|
56
59
|
otel_context_enabled: otel_context_enabled,
|
60
|
+
native_filenames_enabled: native_filenames_enabled,
|
57
61
|
**options,
|
58
62
|
)
|
59
63
|
end
|
60
64
|
|
61
65
|
def inspect
|
62
66
|
# Compose Ruby's default inspect with our custom inspect for the native parts
|
63
|
-
result = super
|
67
|
+
result = super
|
64
68
|
result[-1] = "#{self.class._native_inspect(self)}>"
|
65
69
|
result
|
66
70
|
end
|
@@ -81,6 +85,17 @@ module Datadog
|
|
81
85
|
context = provider.instance_variable_get(:@context)
|
82
86
|
context&.instance_variable_get(:@key)
|
83
87
|
end
|
88
|
+
|
89
|
+
def validate_native_filenames(native_filenames_enabled)
|
90
|
+
if native_filenames_enabled && !Datadog::Profiling::Collectors::Stack._native_filenames_available?
|
91
|
+
Datadog.logger.debug(
|
92
|
+
"Native filenames are enabled, but the required dladdr API was not available. Disabling native filenames."
|
93
|
+
)
|
94
|
+
false
|
95
|
+
else
|
96
|
+
native_filenames_enabled
|
97
|
+
end
|
98
|
+
end
|
84
99
|
end
|
85
100
|
end
|
86
101
|
end
|
@@ -4,10 +4,13 @@ module Datadog
|
|
4
4
|
module Profiling
|
5
5
|
# Responsible for wiring up the Profiler for execution
|
6
6
|
module Component
|
7
|
+
ALLOCATION_WITH_RACTORS_ONLY_ONCE = Datadog::Core::Utils::OnlyOnce.new
|
8
|
+
private_constant :ALLOCATION_WITH_RACTORS_ONLY_ONCE
|
9
|
+
|
7
10
|
# Passing in a `nil` tracer is supported and will disable the following profiling features:
|
8
|
-
# *
|
11
|
+
# * Profiling in the trace viewer, as well as scoping a profile down to a span
|
9
12
|
# * Endpoint aggregation in the profiler UX, including normalization (resource per endpoint call)
|
10
|
-
def self.build_profiler_component(settings:, agent_settings:, optional_tracer:) # rubocop:disable Metrics/MethodLength
|
13
|
+
def self.build_profiler_component(settings:, agent_settings:, optional_tracer:, logger:) # rubocop:disable Metrics/MethodLength
|
11
14
|
return [nil, {profiling_enabled: false}] unless settings.profiling.enabled
|
12
15
|
|
13
16
|
# Workaround for weird dependency direction: the Core::Configuration::Components class currently has a
|
@@ -36,14 +39,14 @@ module Datadog
|
|
36
39
|
|
37
40
|
# NOTE: Please update the Initialization section of ProfilingDevelopment.md with any changes to this method
|
38
41
|
|
39
|
-
no_signals_workaround_enabled = no_signals_workaround_enabled?(settings)
|
42
|
+
no_signals_workaround_enabled = no_signals_workaround_enabled?(settings, logger)
|
40
43
|
timeline_enabled = settings.profiling.advanced.timeline_enabled
|
41
|
-
allocation_profiling_enabled = enable_allocation_profiling?(settings)
|
44
|
+
allocation_profiling_enabled = enable_allocation_profiling?(settings, logger)
|
42
45
|
heap_sample_every = get_heap_sample_every(settings)
|
43
|
-
heap_profiling_enabled = enable_heap_profiling?(settings, allocation_profiling_enabled, heap_sample_every)
|
44
|
-
heap_size_profiling_enabled = enable_heap_size_profiling?(settings, heap_profiling_enabled)
|
46
|
+
heap_profiling_enabled = enable_heap_profiling?(settings, allocation_profiling_enabled, heap_sample_every, logger)
|
47
|
+
heap_size_profiling_enabled = enable_heap_size_profiling?(settings, heap_profiling_enabled, logger)
|
45
48
|
|
46
|
-
overhead_target_percentage = valid_overhead_target(settings.profiling.advanced.overhead_target_percentage)
|
49
|
+
overhead_target_percentage = valid_overhead_target(settings.profiling.advanced.overhead_target_percentage, logger)
|
47
50
|
upload_period_seconds = [60, settings.profiling.advanced.upload_period_seconds].max
|
48
51
|
|
49
52
|
recorder = Datadog::Profiling::StackRecorder.new(
|
@@ -57,13 +60,13 @@ module Datadog
|
|
57
60
|
)
|
58
61
|
thread_context_collector = build_thread_context_collector(settings, recorder, optional_tracer, timeline_enabled)
|
59
62
|
worker = Datadog::Profiling::Collectors::CpuAndWallTimeWorker.new(
|
60
|
-
gc_profiling_enabled: enable_gc_profiling?(settings),
|
63
|
+
gc_profiling_enabled: enable_gc_profiling?(settings, logger),
|
61
64
|
no_signals_workaround_enabled: no_signals_workaround_enabled,
|
62
65
|
thread_context_collector: thread_context_collector,
|
63
66
|
dynamic_sampling_rate_overhead_target_percentage: overhead_target_percentage,
|
64
67
|
allocation_profiling_enabled: allocation_profiling_enabled,
|
65
68
|
allocation_counting_enabled: settings.profiling.advanced.allocation_counting_enabled,
|
66
|
-
gvl_profiling_enabled: enable_gvl_profiling?(settings),
|
69
|
+
gvl_profiling_enabled: enable_gvl_profiling?(settings, logger),
|
67
70
|
)
|
68
71
|
|
69
72
|
internal_metadata = {
|
@@ -93,6 +96,7 @@ module Datadog
|
|
93
96
|
timeline_enabled: timeline_enabled,
|
94
97
|
waiting_for_gvl_threshold_ns: settings.profiling.advanced.waiting_for_gvl_threshold_ns,
|
95
98
|
otel_context_enabled: settings.profiling.advanced.preview_otel_context_enabled,
|
99
|
+
native_filenames_enabled: settings.profiling.advanced.native_filenames_enabled,
|
96
100
|
)
|
97
101
|
end
|
98
102
|
|
@@ -120,7 +124,7 @@ module Datadog
|
|
120
124
|
)
|
121
125
|
end
|
122
126
|
|
123
|
-
private_class_method def self.enable_gc_profiling?(settings)
|
127
|
+
private_class_method def self.enable_gc_profiling?(settings, logger)
|
124
128
|
return false unless settings.profiling.advanced.gc_enabled
|
125
129
|
|
126
130
|
# SEVERE - Only with Ractors
|
@@ -131,14 +135,14 @@ module Datadog
|
|
131
135
|
if RUBY_VERSION.start_with?("3.0.") ||
|
132
136
|
(RUBY_VERSION.start_with?("3.1.") && RUBY_VERSION < "3.1.4") ||
|
133
137
|
(RUBY_VERSION.start_with?("3.2.") && RUBY_VERSION < "3.2.3")
|
134
|
-
|
138
|
+
logger.warn(
|
135
139
|
"Current Ruby version (#{RUBY_VERSION}) has a VM bug where enabling GC profiling would cause " \
|
136
140
|
"crashes (https://bugs.ruby-lang.org/issues/18464). GC profiling has been disabled."
|
137
141
|
)
|
138
142
|
return false
|
139
143
|
elsif RUBY_VERSION.start_with?("3.")
|
140
|
-
|
141
|
-
"
|
144
|
+
logger.debug(
|
145
|
+
"Using Ractors may result in GC profiling unexpectedly " \
|
142
146
|
"stopping (https://bugs.ruby-lang.org/issues/19112). Note that this stop has no impact in your " \
|
143
147
|
"application stability or performance. This does not happen if Ractors are not used."
|
144
148
|
)
|
@@ -155,7 +159,7 @@ module Datadog
|
|
155
159
|
heap_sample_rate
|
156
160
|
end
|
157
161
|
|
158
|
-
private_class_method def self.enable_allocation_profiling?(settings)
|
162
|
+
private_class_method def self.enable_allocation_profiling?(settings, logger)
|
159
163
|
return false unless settings.profiling.allocation_enabled
|
160
164
|
|
161
165
|
# Allocation sampling is safe and supported on Ruby 2.x, but has a few caveats on Ruby 3.x.
|
@@ -165,7 +169,7 @@ module Datadog
|
|
165
169
|
# https://github.com/ruby/ruby/pull/7464) that makes this crash in any configuration. This bug is
|
166
170
|
# fixed on Ruby versions 3.2.3 and 3.3.0.
|
167
171
|
if RUBY_VERSION.start_with?("3.2.") && RUBY_VERSION < "3.2.3"
|
168
|
-
|
172
|
+
logger.warn(
|
169
173
|
"Allocation profiling is not supported in Ruby versions 3.2.0, 3.2.1 and 3.2.2 and will be forcibly " \
|
170
174
|
"disabled. This is due to a VM bug that can lead to crashes (https://bugs.ruby-lang.org/issues/19482). " \
|
171
175
|
"Other Ruby versions do not suffer from this issue."
|
@@ -181,7 +185,7 @@ module Datadog
|
|
181
185
|
if RUBY_VERSION.start_with?("3.0.") ||
|
182
186
|
(RUBY_VERSION.start_with?("3.1.") && RUBY_VERSION < "3.1.4") ||
|
183
187
|
(RUBY_VERSION.start_with?("3.2.") && RUBY_VERSION < "3.2.3")
|
184
|
-
|
188
|
+
logger.warn(
|
185
189
|
"Current Ruby version (#{RUBY_VERSION}) has a VM bug where enabling allocation profiling while using " \
|
186
190
|
"Ractors may cause unexpected issues, including crashes (https://bugs.ruby-lang.org/issues/18464). " \
|
187
191
|
"This does not happen if Ractors are not used."
|
@@ -190,74 +194,59 @@ module Datadog
|
|
190
194
|
# On all known versions of Ruby 3.x, due to https://bugs.ruby-lang.org/issues/19112, when a ractor gets
|
191
195
|
# garbage collected, Ruby will disable all active tracepoints, which this feature internally relies on.
|
192
196
|
elsif RUBY_VERSION.start_with?("3.")
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
197
|
+
ALLOCATION_WITH_RACTORS_ONLY_ONCE.run do
|
198
|
+
logger.info(
|
199
|
+
"Using Ractors may result in allocation profiling " \
|
200
|
+
"stopping (https://bugs.ruby-lang.org/issues/19112). Note that this stop has no impact in your " \
|
201
|
+
"application stability or performance. This does not happen if Ractors are not used."
|
202
|
+
)
|
203
|
+
end
|
198
204
|
end
|
199
205
|
|
200
|
-
|
206
|
+
logger.debug("Enabled allocation profiling")
|
201
207
|
|
202
208
|
true
|
203
209
|
end
|
204
210
|
|
205
|
-
private_class_method def self.enable_heap_profiling?(settings, allocation_profiling_enabled, heap_sample_rate)
|
211
|
+
private_class_method def self.enable_heap_profiling?(settings, allocation_profiling_enabled, heap_sample_rate, logger)
|
206
212
|
heap_profiling_enabled = settings.profiling.advanced.experimental_heap_enabled
|
207
213
|
|
208
214
|
return false unless heap_profiling_enabled
|
209
215
|
|
210
|
-
if RUBY_VERSION.start_with?("2.") && RUBY_VERSION < "2.7"
|
211
|
-
Datadog.logger.warn(
|
212
|
-
"Heap profiling currently relies on features introduced in Ruby 2.7 and will be forcibly disabled. " \
|
213
|
-
"Please upgrade to Ruby >= 2.7 in order to use this feature."
|
214
|
-
)
|
215
|
-
return false
|
216
|
-
end
|
217
|
-
|
218
216
|
if RUBY_VERSION < "3.1"
|
219
|
-
|
220
|
-
"Current Ruby version (#{RUBY_VERSION})
|
221
|
-
"
|
222
|
-
"the SEEN_OBJ_ID flag on objects that should have it but don't. Full details can be found in " \
|
223
|
-
"https://github.com/DataDog/dd-trace-rb/pull/3360. This workaround should be safe but can be " \
|
224
|
-
"bypassed by disabling the heap profiler or upgrading to Ruby >= 3.1 where forced object recycling " \
|
225
|
-
"was completely removed (https://bugs.ruby-lang.org/issues/18290)."
|
217
|
+
logger.warn(
|
218
|
+
"Current Ruby version (#{RUBY_VERSION}) cannot support heap profiling due to VM limitations. " \
|
219
|
+
"Please upgrade to Ruby >= 3.1 in order to use this feature. Heap profiling has been disabled."
|
226
220
|
)
|
221
|
+
return false
|
227
222
|
end
|
228
223
|
|
229
224
|
unless allocation_profiling_enabled
|
230
|
-
|
231
|
-
"Heap profiling
|
225
|
+
logger.warn(
|
226
|
+
"Heap profiling was requested but allocation profiling is not enabled. " \
|
227
|
+
"Heap profiling has been disabled."
|
228
|
+
)
|
229
|
+
return false
|
232
230
|
end
|
233
231
|
|
234
|
-
|
235
|
-
"Enabled experimental heap profiling: heap_sample_rate=#{heap_sample_rate}. This is experimental, not " \
|
236
|
-
"recommended, and will increase overhead!"
|
237
|
-
)
|
232
|
+
logger.debug("Enabled heap profiling: heap_sample_rate=#{heap_sample_rate}")
|
238
233
|
|
239
234
|
true
|
240
235
|
end
|
241
236
|
|
242
|
-
private_class_method def self.enable_heap_size_profiling?(settings, heap_profiling_enabled)
|
237
|
+
private_class_method def self.enable_heap_size_profiling?(settings, heap_profiling_enabled, logger)
|
243
238
|
heap_size_profiling_enabled = settings.profiling.advanced.experimental_heap_size_enabled
|
244
239
|
|
245
240
|
return false unless heap_profiling_enabled && heap_size_profiling_enabled
|
246
241
|
|
247
|
-
Datadog.logger.warn(
|
248
|
-
"Enabled experimental heap size profiling. This is experimental, not recommended, and will increase overhead!"
|
249
|
-
)
|
250
|
-
|
251
242
|
true
|
252
243
|
end
|
253
244
|
|
254
|
-
private_class_method def self.no_signals_workaround_enabled?(settings) # rubocop:disable Metrics/MethodLength
|
245
|
+
private_class_method def self.no_signals_workaround_enabled?(settings, logger) # rubocop:disable Metrics/MethodLength
|
255
246
|
setting_value = settings.profiling.advanced.no_signals_workaround_enabled
|
256
|
-
legacy_ruby_that_should_use_workaround = RUBY_VERSION.start_with?("2.5.")
|
257
247
|
|
258
248
|
unless [true, false, :auto].include?(setting_value)
|
259
|
-
|
260
|
-
Datadog.logger.error(
|
249
|
+
logger.warn(
|
261
250
|
"Ignoring invalid value for profiling no_signals_workaround_enabled setting: #{setting_value.inspect}. " \
|
262
251
|
"Valid options are `true`, `false` or (default) `:auto`."
|
263
252
|
)
|
@@ -266,23 +255,23 @@ module Datadog
|
|
266
255
|
end
|
267
256
|
|
268
257
|
if setting_value == false
|
269
|
-
if
|
270
|
-
|
271
|
-
'The profiling "no signals" workaround has been disabled via configuration on
|
272
|
-
"
|
273
|
-
"in production environments, as due to limitations in Ruby APIs, we suspect it may lead to crashes " \
|
274
|
-
"
|
258
|
+
if RUBY_VERSION.start_with?("2.5.")
|
259
|
+
logger.warn(
|
260
|
+
'The profiling "no signals" workaround has been disabled via configuration on Ruby 2.5. ' \
|
261
|
+
"This is not recommended " \
|
262
|
+
"in production environments, as due to limitations in Ruby APIs, we suspect it may lead to rare crashes " \
|
263
|
+
"Please report any issues you run into to Datadog support or " \
|
275
264
|
"via <https://github.com/datadog/dd-trace-rb/issues/new>!"
|
276
265
|
)
|
277
266
|
else
|
278
|
-
|
267
|
+
logger.warn('Profiling "no signals" workaround disabled via configuration')
|
279
268
|
end
|
280
269
|
|
281
270
|
return false
|
282
271
|
end
|
283
272
|
|
284
273
|
if setting_value == true
|
285
|
-
|
274
|
+
logger.warn(
|
286
275
|
'Profiling "no signals" workaround enabled via configuration. Profiling data will have lower quality.'
|
287
276
|
)
|
288
277
|
|
@@ -292,10 +281,10 @@ module Datadog
|
|
292
281
|
# Setting is in auto mode. Let's probe to see if we should enable it:
|
293
282
|
|
294
283
|
# We don't warn users in this situation because "upgrade your Ruby" is not a great warning
|
295
|
-
return true if
|
284
|
+
return true if RUBY_VERSION.start_with?("2.5.")
|
296
285
|
|
297
|
-
if Gem.loaded_specs["mysql2"] && incompatible_libmysqlclient_version?(settings)
|
298
|
-
|
286
|
+
if Gem.loaded_specs["mysql2"] && incompatible_libmysqlclient_version?(settings, logger)
|
287
|
+
logger.warn(
|
299
288
|
'Enabling the profiling "no signals" workaround because an incompatible version of the mysql2 gem is ' \
|
300
289
|
"installed. Profiling data will have lower quality. " \
|
301
290
|
"To fix this, upgrade the libmysqlclient in your OS image to version 8.0.0 or above."
|
@@ -304,7 +293,7 @@ module Datadog
|
|
304
293
|
end
|
305
294
|
|
306
295
|
if Gem.loaded_specs["rugged"]
|
307
|
-
|
296
|
+
logger.warn(
|
308
297
|
'Enabling the profiling "no signals" workaround because the rugged gem is installed. ' \
|
309
298
|
"This is needed because some operations on this gem are currently incompatible with the normal working mode " \
|
310
299
|
"of the profiler, as detailed in <https://github.com/datadog/dd-trace-rb/issues/2721>. " \
|
@@ -314,7 +303,7 @@ module Datadog
|
|
314
303
|
end
|
315
304
|
|
316
305
|
if (defined?(::PhusionPassenger) || Gem.loaded_specs["passenger"]) && incompatible_passenger_version?
|
317
|
-
|
306
|
+
logger.warn(
|
318
307
|
'Enabling the profiling "no signals" workaround because an incompatible version of the passenger gem is ' \
|
319
308
|
"installed. Profiling data will have lower quality." \
|
320
309
|
"To fix this, upgrade the passenger gem to version 6.0.19 or above."
|
@@ -334,10 +323,10 @@ module Datadog
|
|
334
323
|
#
|
335
324
|
# The `mysql2` gem's `info` method can be used to determine which `libmysqlclient` version is in use, and thus to
|
336
325
|
# detect if it's safe for the profiler to use signals or if we need to employ a fallback.
|
337
|
-
private_class_method def self.incompatible_libmysqlclient_version?(settings)
|
326
|
+
private_class_method def self.incompatible_libmysqlclient_version?(settings, logger)
|
338
327
|
return true if settings.profiling.advanced.skip_mysql2_check
|
339
328
|
|
340
|
-
|
329
|
+
logger.debug(
|
341
330
|
"Requiring `mysql2` to check if the `libmysqlclient` version it uses is compatible with profiling"
|
342
331
|
)
|
343
332
|
|
@@ -366,14 +355,14 @@ module Datadog
|
|
366
355
|
libmysqlclient_version >= Gem::Version.new("8.0.0") ||
|
367
356
|
looks_like_mariadb?(info, libmysqlclient_version)
|
368
357
|
|
369
|
-
|
358
|
+
logger.debug(
|
370
359
|
"The `mysql2` gem is using #{compatible ? "a compatible" : "an incompatible"} version of " \
|
371
360
|
"the `libmysqlclient` library (#{libmysqlclient_version})"
|
372
361
|
)
|
373
362
|
|
374
363
|
!compatible
|
375
364
|
rescue StandardError, LoadError => e
|
376
|
-
|
365
|
+
logger.warn(
|
377
366
|
"Failed to probe `mysql2` gem information. " \
|
378
367
|
"Cause: #{e.class.name} #{e.message} Location: #{Array(e.backtrace).first}"
|
379
368
|
)
|
@@ -395,12 +384,11 @@ module Datadog
|
|
395
384
|
end
|
396
385
|
end
|
397
386
|
|
398
|
-
private_class_method def self.valid_overhead_target(overhead_target_percentage)
|
387
|
+
private_class_method def self.valid_overhead_target(overhead_target_percentage, logger)
|
399
388
|
if overhead_target_percentage > 0 && overhead_target_percentage <= 20
|
400
389
|
overhead_target_percentage
|
401
390
|
else
|
402
|
-
|
403
|
-
Datadog.logger.error(
|
391
|
+
logger.warn(
|
404
392
|
"Ignoring invalid value for profiling overhead_target_percentage setting: " \
|
405
393
|
"#{overhead_target_percentage.inspect}. Falling back to default value."
|
406
394
|
)
|
@@ -444,18 +432,12 @@ module Datadog
|
|
444
432
|
settings.profiling.advanced.dir_interruption_workaround_enabled
|
445
433
|
end
|
446
434
|
|
447
|
-
private_class_method def self.enable_gvl_profiling?(settings)
|
448
|
-
if RUBY_VERSION < "3.2"
|
449
|
-
if settings.profiling.advanced.preview_gvl_enabled
|
450
|
-
Datadog.logger.warn("GVL profiling is currently not supported in Ruby < 3.2 and will not be enabled.")
|
451
|
-
end
|
452
|
-
|
453
|
-
return false
|
454
|
-
end
|
435
|
+
private_class_method def self.enable_gvl_profiling?(settings, logger)
|
436
|
+
return false if RUBY_VERSION < "3.2"
|
455
437
|
|
456
438
|
# GVL profiling only makes sense in the context of timeline. We could emit a warning here, but not sure how
|
457
439
|
# useful it is -- if a customer disables timeline, there's nowhere to look for GVL profiling anyway!
|
458
|
-
settings.profiling.advanced.timeline_enabled && settings.profiling.advanced.
|
440
|
+
settings.profiling.advanced.timeline_enabled && settings.profiling.advanced.gvl_enabled
|
459
441
|
end
|
460
442
|
end
|
461
443
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Datadog
|
4
|
+
module Profiling
|
5
|
+
# This class exists to wrap a ddog_prof_EncodedProfile into a Ruby object
|
6
|
+
#
|
7
|
+
# This class is not empty; all of this class is implemented as native code.
|
8
|
+
class EncodedProfile # rubocop:disable Lint/EmptyClass
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -49,7 +49,7 @@ module Datadog
|
|
49
49
|
@internal_metadata = internal_metadata
|
50
50
|
# NOTE: At the time of this comment collected info does not change over time so we'll hardcode
|
51
51
|
# it on startup to prevent serializing the same info on every flush.
|
52
|
-
@info_json = JSON.
|
52
|
+
@info_json = JSON.generate(info_collector.info).freeze
|
53
53
|
end
|
54
54
|
|
55
55
|
def flush
|
@@ -57,7 +57,7 @@ module Datadog
|
|
57
57
|
serialization_result = pprof_recorder.serialize
|
58
58
|
return if serialization_result.nil?
|
59
59
|
|
60
|
-
start, finish,
|
60
|
+
start, finish, encoded_profile, profile_stats = serialization_result
|
61
61
|
@last_flush_finish_at = finish
|
62
62
|
|
63
63
|
if duration_below_threshold?(start, finish)
|
@@ -70,8 +70,7 @@ module Datadog
|
|
70
70
|
Flush.new(
|
71
71
|
start: start,
|
72
72
|
finish: finish,
|
73
|
-
|
74
|
-
pprof_data: compressed_pprof.to_s,
|
73
|
+
encoded_profile: encoded_profile,
|
75
74
|
code_provenance_file_name: Datadog::Profiling::Ext::Transport::HTTP::CODE_PROVENANCE_FILENAME,
|
76
75
|
code_provenance_data: uncompressed_code_provenance,
|
77
76
|
tags_as_array: Datadog::Profiling::TagBuilder.call(settings: Datadog.configuration).to_a,
|
@@ -11,22 +11,8 @@ module Datadog
|
|
11
11
|
|
12
12
|
module Transport
|
13
13
|
module HTTP
|
14
|
-
FORM_FIELD_TAG_ENV = "env"
|
15
|
-
FORM_FIELD_TAG_HOST = "host"
|
16
|
-
FORM_FIELD_TAG_LANGUAGE = "language"
|
17
|
-
FORM_FIELD_TAG_PID = "process_id"
|
18
14
|
FORM_FIELD_TAG_PROFILER_VERSION = "profiler_version"
|
19
|
-
FORM_FIELD_TAG_RUNTIME = "runtime"
|
20
|
-
FORM_FIELD_TAG_RUNTIME_ENGINE = "runtime_engine"
|
21
|
-
FORM_FIELD_TAG_RUNTIME_ID = "runtime-id"
|
22
|
-
FORM_FIELD_TAG_RUNTIME_PLATFORM = "runtime_platform"
|
23
|
-
FORM_FIELD_TAG_RUNTIME_VERSION = "runtime_version"
|
24
|
-
FORM_FIELD_TAG_SERVICE = "service"
|
25
|
-
FORM_FIELD_TAG_VERSION = "version"
|
26
|
-
TAG_GIT_REPOSITORY_URL = "git.repository_url"
|
27
|
-
TAG_GIT_COMMIT_SHA = "git.commit.sha"
|
28
15
|
|
29
|
-
PPROF_DEFAULT_FILENAME = "rubyprofile.pprof"
|
30
16
|
CODE_PROVENANCE_FILENAME = "code-provenance.json"
|
31
17
|
end
|
32
18
|
end
|
@@ -9,10 +9,9 @@ module Datadog
|
|
9
9
|
attr_reader \
|
10
10
|
:start,
|
11
11
|
:finish,
|
12
|
-
:
|
13
|
-
:pprof_data, # gzipped pprof bytes
|
12
|
+
:encoded_profile,
|
14
13
|
:code_provenance_file_name,
|
15
|
-
:code_provenance_data,
|
14
|
+
:code_provenance_data,
|
16
15
|
:tags_as_array,
|
17
16
|
:internal_metadata_json,
|
18
17
|
:info_json
|
@@ -20,8 +19,7 @@ module Datadog
|
|
20
19
|
def initialize(
|
21
20
|
start:,
|
22
21
|
finish:,
|
23
|
-
|
24
|
-
pprof_data:,
|
22
|
+
encoded_profile:,
|
25
23
|
code_provenance_file_name:,
|
26
24
|
code_provenance_data:,
|
27
25
|
tags_as_array:,
|
@@ -30,12 +28,11 @@ module Datadog
|
|
30
28
|
)
|
31
29
|
@start = start
|
32
30
|
@finish = finish
|
33
|
-
@
|
34
|
-
@pprof_data = pprof_data
|
31
|
+
@encoded_profile = encoded_profile
|
35
32
|
@code_provenance_file_name = code_provenance_file_name
|
36
33
|
@code_provenance_data = code_provenance_data
|
37
34
|
@tags_as_array = tags_as_array
|
38
|
-
@internal_metadata_json = JSON.
|
35
|
+
@internal_metadata_json = JSON.generate(internal_metadata)
|
39
36
|
@info_json = info_json
|
40
37
|
end
|
41
38
|
end
|