ddtrace 1.12.1 → 1.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 +388 -10
- data/ext/ddtrace_profiling_native_extension/NativeExtensionDesign.md +3 -5
- data/ext/ddtrace_profiling_native_extension/clock_id.h +0 -3
- data/ext/ddtrace_profiling_native_extension/clock_id_from_pthread.c +3 -22
- data/ext/ddtrace_profiling_native_extension/clock_id_noop.c +0 -1
- data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +41 -6
- data/ext/ddtrace_profiling_native_extension/collectors_idle_sampling_helper.c +3 -0
- data/ext/ddtrace_profiling_native_extension/collectors_stack.c +76 -24
- data/ext/ddtrace_profiling_native_extension/collectors_stack.h +1 -1
- data/ext/ddtrace_profiling_native_extension/collectors_thread_context.c +292 -27
- data/ext/ddtrace_profiling_native_extension/collectors_thread_context.h +1 -1
- data/ext/ddtrace_profiling_native_extension/extconf.rb +40 -10
- data/ext/ddtrace_profiling_native_extension/http_transport.c +48 -16
- data/ext/ddtrace_profiling_native_extension/libdatadog_helpers.c +42 -0
- data/ext/ddtrace_profiling_native_extension/libdatadog_helpers.h +6 -0
- data/ext/ddtrace_profiling_native_extension/native_extension_helpers.rb +1 -1
- data/ext/ddtrace_profiling_native_extension/pid_controller.c +57 -0
- data/ext/ddtrace_profiling_native_extension/pid_controller.h +45 -0
- data/ext/ddtrace_profiling_native_extension/private_vm_api_access.c +136 -32
- data/ext/ddtrace_profiling_native_extension/private_vm_api_access.h +12 -0
- data/ext/ddtrace_profiling_native_extension/profiling.c +1 -2
- data/ext/ddtrace_profiling_native_extension/stack_recorder.c +81 -50
- data/ext/ddtrace_profiling_native_extension/stack_recorder.h +13 -3
- data/ext/ddtrace_profiling_native_extension/time_helpers.c +40 -4
- data/ext/ddtrace_profiling_native_extension/time_helpers.h +14 -0
- data/lib/datadog/appsec/assets/waf_rules/processors.json +92 -0
- data/lib/datadog/appsec/assets/waf_rules/recommended.json +698 -75
- data/lib/datadog/appsec/assets/waf_rules/scanners.json +114 -0
- data/lib/datadog/appsec/assets/waf_rules/strict.json +98 -8
- data/lib/datadog/appsec/assets.rb +8 -0
- data/lib/datadog/appsec/component.rb +21 -2
- data/lib/datadog/appsec/configuration/settings.rb +167 -189
- data/lib/datadog/appsec/configuration.rb +0 -79
- data/lib/datadog/appsec/contrib/auto_instrument.rb +2 -4
- data/lib/datadog/appsec/contrib/devise/event.rb +57 -0
- data/lib/datadog/appsec/contrib/devise/ext.rb +13 -0
- data/lib/datadog/appsec/contrib/devise/integration.rb +42 -0
- data/lib/datadog/appsec/contrib/devise/patcher/authenticatable_patch.rb +76 -0
- data/lib/datadog/appsec/contrib/devise/patcher/registration_controller_patch.rb +54 -0
- data/lib/datadog/appsec/contrib/devise/patcher.rb +45 -0
- data/lib/datadog/appsec/contrib/devise/resource.rb +35 -0
- data/lib/datadog/appsec/contrib/devise/tracking.rb +49 -0
- data/lib/datadog/appsec/contrib/rack/ext.rb +2 -1
- data/lib/datadog/appsec/contrib/rack/gateway/request.rb +6 -2
- data/lib/datadog/appsec/contrib/rack/gateway/watcher.rb +8 -6
- data/lib/datadog/appsec/contrib/rack/reactive/request.rb +3 -8
- data/lib/datadog/appsec/contrib/rack/reactive/request_body.rb +3 -6
- data/lib/datadog/appsec/contrib/rack/reactive/response.rb +3 -6
- data/lib/datadog/appsec/contrib/rack/request_body_middleware.rb +3 -2
- data/lib/datadog/appsec/contrib/rack/request_middleware.rb +36 -17
- data/lib/datadog/appsec/contrib/rails/ext.rb +3 -2
- data/lib/datadog/appsec/contrib/rails/framework.rb +1 -3
- data/lib/datadog/appsec/contrib/rails/gateway/watcher.rb +3 -2
- data/lib/datadog/appsec/contrib/rails/patcher.rb +17 -11
- data/lib/datadog/appsec/contrib/rails/reactive/action.rb +3 -6
- data/lib/datadog/appsec/contrib/sinatra/ext.rb +2 -1
- data/lib/datadog/appsec/contrib/sinatra/framework.rb +1 -3
- data/lib/datadog/appsec/contrib/sinatra/gateway/watcher.rb +6 -4
- data/lib/datadog/appsec/contrib/sinatra/patcher.rb +13 -7
- data/lib/datadog/appsec/contrib/sinatra/reactive/routed.rb +3 -6
- data/lib/datadog/appsec/event.rb +106 -50
- data/lib/datadog/appsec/extensions.rb +1 -130
- data/lib/datadog/appsec/monitor/gateway/watcher.rb +3 -3
- data/lib/datadog/appsec/monitor/reactive/set_user.rb +3 -6
- data/lib/datadog/appsec/processor/actions.rb +49 -0
- data/lib/datadog/appsec/processor/rule_loader.rb +60 -0
- data/lib/datadog/appsec/processor/rule_merger.rb +22 -2
- data/lib/datadog/appsec/processor.rb +35 -7
- data/lib/datadog/appsec/rate_limiter.rb +1 -1
- data/lib/datadog/appsec/remote.rb +17 -11
- data/lib/datadog/appsec/response.rb +82 -4
- data/lib/datadog/appsec/sample_rate.rb +21 -0
- data/lib/datadog/appsec.rb +3 -4
- data/lib/datadog/core/backport.rb +51 -0
- data/lib/datadog/core/configuration/agent_settings_resolver.rb +38 -29
- data/lib/datadog/core/configuration/base.rb +6 -16
- data/lib/datadog/core/configuration/components.rb +15 -3
- data/lib/datadog/core/configuration/ext.rb +28 -5
- data/lib/datadog/core/configuration/option.rb +269 -21
- data/lib/datadog/core/configuration/option_definition.rb +73 -32
- data/lib/datadog/core/configuration/options.rb +27 -15
- data/lib/datadog/core/configuration/settings.rb +182 -102
- data/lib/datadog/core/configuration.rb +4 -0
- data/lib/datadog/core/diagnostics/environment_logger.rb +130 -234
- data/lib/datadog/core/environment/execution.rb +103 -0
- data/lib/datadog/core/environment/ext.rb +13 -11
- data/lib/datadog/core/environment/variable_helpers.rb +0 -69
- data/lib/datadog/core/environment/yjit.rb +58 -0
- data/lib/datadog/core/error.rb +1 -0
- data/lib/datadog/core/git/ext.rb +26 -22
- data/lib/datadog/core/logging/ext.rb +3 -1
- data/lib/datadog/core/metrics/ext.rb +7 -5
- data/lib/datadog/core/remote/client/capabilities.rb +6 -1
- data/lib/datadog/core/remote/client.rb +3 -0
- data/lib/datadog/core/remote/component.rb +27 -36
- data/lib/datadog/core/remote/configuration/content.rb +28 -1
- data/lib/datadog/core/remote/configuration/repository.rb +3 -1
- data/lib/datadog/core/remote/ext.rb +1 -1
- data/lib/datadog/core/remote/negotiation.rb +19 -6
- data/lib/datadog/core/remote/transport/config.rb +60 -0
- data/lib/datadog/core/remote/transport/http/api/instance.rb +39 -0
- data/lib/datadog/core/remote/transport/http/api/spec.rb +21 -0
- data/lib/datadog/core/remote/transport/http/api.rb +58 -0
- data/lib/datadog/core/remote/transport/http/builder.rb +219 -0
- data/lib/datadog/core/remote/transport/http/client.rb +48 -0
- data/lib/datadog/core/remote/transport/http/config.rb +280 -0
- data/lib/datadog/core/remote/transport/http/negotiation.rb +146 -0
- data/lib/datadog/core/remote/transport/http.rb +179 -0
- data/lib/datadog/core/{transport → remote/transport}/negotiation.rb +25 -23
- data/lib/datadog/core/remote/worker.rb +4 -1
- data/lib/datadog/core/runtime/ext.rb +22 -12
- data/lib/datadog/core/runtime/metrics.rb +43 -0
- data/lib/datadog/core/telemetry/client.rb +12 -2
- data/lib/datadog/core/telemetry/collector.rb +13 -4
- data/lib/datadog/core/telemetry/emitter.rb +4 -2
- data/lib/datadog/core/telemetry/event.rb +19 -4
- data/lib/datadog/core/telemetry/ext.rb +4 -1
- data/lib/datadog/core/telemetry/heartbeat.rb +2 -4
- data/lib/datadog/core/telemetry/http/ext.rb +10 -8
- data/lib/datadog/core/telemetry/http/transport.rb +2 -0
- data/lib/datadog/core/telemetry/v2/app_client_configuration_change.rb +41 -0
- data/lib/datadog/core/telemetry/v2/request.rb +29 -0
- data/lib/datadog/core/transport/ext.rb +47 -0
- data/lib/datadog/core/transport/http/adapters/net.rb +168 -0
- data/lib/datadog/core/transport/http/adapters/registry.rb +29 -0
- data/lib/datadog/core/transport/http/adapters/test.rb +89 -0
- data/lib/datadog/core/transport/http/adapters/unix_socket.rb +83 -0
- data/lib/datadog/core/transport/http/api/endpoint.rb +31 -0
- data/lib/datadog/core/transport/http/api/fallbacks.rb +26 -0
- data/lib/datadog/core/transport/http/api/map.rb +18 -0
- data/lib/datadog/core/transport/http/env.rb +62 -0
- data/lib/datadog/core/transport/http/response.rb +60 -0
- data/lib/datadog/core/transport/parcel.rb +22 -0
- data/lib/datadog/core/transport/request.rb +17 -0
- data/lib/datadog/core/transport/response.rb +64 -0
- data/lib/datadog/core/utils/duration.rb +52 -0
- data/lib/datadog/core/utils/hash.rb +47 -0
- data/lib/datadog/core/utils/network.rb +1 -1
- data/lib/datadog/core/utils/safe_dup.rb +27 -20
- data/lib/datadog/core/utils.rb +1 -1
- data/lib/datadog/core/workers/async.rb +3 -2
- data/lib/datadog/core/workers/polling.rb +2 -2
- data/lib/datadog/kit/appsec/events.rb +139 -89
- data/lib/datadog/kit/enable_core_dumps.rb +5 -6
- data/lib/datadog/kit/identity.rb +80 -65
- data/lib/datadog/opentelemetry/api/context.rb +10 -3
- data/lib/datadog/opentelemetry/sdk/propagator.rb +2 -1
- data/lib/datadog/opentelemetry/sdk/span_processor.rb +48 -5
- data/lib/datadog/opentelemetry/sdk/trace/span.rb +167 -0
- data/lib/datadog/opentelemetry/trace.rb +58 -0
- data/lib/datadog/opentelemetry.rb +1 -0
- data/lib/datadog/opentracer/text_map_propagator.rb +2 -1
- data/lib/datadog/opentracer.rb +9 -0
- data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +16 -17
- data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +3 -1
- data/lib/datadog/profiling/collectors/thread_context.rb +17 -2
- data/lib/datadog/profiling/component.rb +69 -94
- data/lib/datadog/profiling/diagnostics/environment_logger.rb +39 -0
- data/lib/datadog/profiling/exporter.rb +5 -1
- data/lib/datadog/profiling/ext.rb +0 -12
- data/lib/datadog/profiling/flush.rb +7 -5
- data/lib/datadog/profiling/http_transport.rb +19 -6
- data/lib/datadog/profiling/load_native_extension.rb +7 -1
- data/lib/datadog/profiling/native_extension.rb +0 -21
- data/lib/datadog/profiling/profiler.rb +36 -13
- data/lib/datadog/profiling/scheduler.rb +16 -9
- data/lib/datadog/profiling.rb +16 -78
- data/lib/datadog/tracing/component.rb +70 -11
- data/lib/datadog/tracing/configuration/agent_settings_resolver.rb +13 -0
- data/lib/datadog/tracing/configuration/dynamic/option.rb +71 -0
- data/lib/datadog/tracing/configuration/dynamic.rb +64 -0
- data/lib/datadog/tracing/configuration/ext.rb +40 -32
- data/lib/datadog/tracing/configuration/http.rb +74 -0
- data/lib/datadog/tracing/configuration/settings.rb +134 -98
- data/lib/datadog/tracing/contrib/action_cable/configuration/settings.rb +9 -6
- data/lib/datadog/tracing/contrib/action_cable/ext.rb +20 -18
- data/lib/datadog/tracing/contrib/action_mailer/configuration/settings.rb +9 -6
- data/lib/datadog/tracing/contrib/action_mailer/ext.rb +20 -18
- data/lib/datadog/tracing/contrib/action_pack/configuration/settings.rb +9 -7
- data/lib/datadog/tracing/contrib/action_pack/ext.rb +10 -8
- data/lib/datadog/tracing/contrib/action_view/configuration/settings.rb +9 -6
- data/lib/datadog/tracing/contrib/action_view/ext.rb +12 -10
- data/lib/datadog/tracing/contrib/active_job/configuration/settings.rb +13 -7
- data/lib/datadog/tracing/contrib/active_job/ext.rb +25 -23
- data/lib/datadog/tracing/contrib/active_job/log_injection.rb +1 -1
- data/lib/datadog/tracing/contrib/active_job/patcher.rb +1 -1
- data/lib/datadog/tracing/contrib/active_model_serializers/configuration/settings.rb +9 -6
- data/lib/datadog/tracing/contrib/active_model_serializers/ext.rb +12 -10
- data/lib/datadog/tracing/contrib/active_record/configuration/resolver.rb +18 -11
- data/lib/datadog/tracing/contrib/active_record/configuration/settings.rb +9 -7
- data/lib/datadog/tracing/contrib/active_record/events/sql.rb +2 -6
- data/lib/datadog/tracing/contrib/active_record/ext.rb +17 -15
- data/lib/datadog/tracing/contrib/active_record/utils.rb +1 -1
- data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +106 -202
- data/lib/datadog/tracing/contrib/active_support/cache/patcher.rb +3 -0
- data/lib/datadog/tracing/contrib/active_support/configuration/settings.rb +9 -7
- data/lib/datadog/tracing/contrib/active_support/ext.rb +18 -16
- data/lib/datadog/tracing/contrib/aws/configuration/settings.rb +14 -7
- data/lib/datadog/tracing/contrib/aws/ext.rb +37 -24
- data/lib/datadog/tracing/contrib/aws/instrumentation.rb +16 -5
- data/lib/datadog/tracing/contrib/concurrent_ruby/configuration/settings.rb +3 -2
- data/lib/datadog/tracing/contrib/concurrent_ruby/context_composite_executor_service.rb +14 -14
- data/lib/datadog/tracing/contrib/concurrent_ruby/ext.rb +4 -2
- data/lib/datadog/tracing/contrib/concurrent_ruby/future_patch.rb +3 -10
- data/lib/datadog/tracing/contrib/concurrent_ruby/integration.rb +2 -1
- data/lib/datadog/tracing/contrib/concurrent_ruby/patcher.rb +8 -1
- data/lib/datadog/tracing/contrib/concurrent_ruby/promises_future_patch.rb +22 -0
- data/lib/datadog/tracing/contrib/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/dalli/configuration/settings.rb +20 -7
- data/lib/datadog/tracing/contrib/dalli/ext.rb +26 -11
- data/lib/datadog/tracing/contrib/dalli/instrumentation.rb +17 -8
- data/lib/datadog/tracing/contrib/delayed_job/configuration/settings.rb +13 -7
- data/lib/datadog/tracing/contrib/delayed_job/ext.rb +16 -14
- data/lib/datadog/tracing/contrib/elasticsearch/configuration/settings.rb +14 -7
- data/lib/datadog/tracing/contrib/elasticsearch/ext.rb +21 -15
- data/lib/datadog/tracing/contrib/elasticsearch/patcher.rb +104 -99
- data/lib/datadog/tracing/contrib/ethon/configuration/settings.rb +16 -9
- data/lib/datadog/tracing/contrib/ethon/easy_patch.rb +48 -3
- data/lib/datadog/tracing/contrib/ethon/ext.rb +19 -11
- data/lib/datadog/tracing/contrib/ethon/multi_patch.rb +6 -3
- data/lib/datadog/tracing/contrib/excon/configuration/settings.rb +19 -10
- data/lib/datadog/tracing/contrib/excon/ext.rb +16 -8
- data/lib/datadog/tracing/contrib/excon/middleware.rb +25 -5
- data/lib/datadog/tracing/contrib/ext.rb +26 -1
- data/lib/datadog/tracing/contrib/extensions.rb +32 -0
- data/lib/datadog/tracing/contrib/faraday/configuration/settings.rb +20 -10
- data/lib/datadog/tracing/contrib/faraday/ext.rb +16 -8
- data/lib/datadog/tracing/contrib/faraday/middleware.rb +21 -5
- data/lib/datadog/tracing/contrib/grape/configuration/settings.rb +8 -6
- data/lib/datadog/tracing/contrib/grape/ext.rb +16 -14
- data/lib/datadog/tracing/contrib/graphql/configuration/settings.rb +8 -6
- data/lib/datadog/tracing/contrib/graphql/ext.rb +7 -5
- data/lib/datadog/tracing/contrib/grpc/configuration/settings.rb +39 -9
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb +39 -20
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/server.rb +37 -18
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor.rb +0 -4
- data/lib/datadog/tracing/contrib/grpc/ext.rb +16 -13
- data/lib/datadog/tracing/contrib/grpc/formatting.rb +127 -0
- data/lib/datadog/tracing/contrib/hanami/configuration/settings.rb +3 -2
- data/lib/datadog/tracing/contrib/hanami/ext.rb +10 -8
- data/lib/datadog/tracing/contrib/http/circuit_breaker.rb +5 -8
- data/lib/datadog/tracing/contrib/http/configuration/settings.rb +33 -11
- data/lib/datadog/tracing/contrib/http/ext.rb +16 -9
- data/lib/datadog/tracing/contrib/http/instrumentation.rb +27 -7
- data/lib/datadog/tracing/contrib/httpclient/configuration/settings.rb +33 -11
- data/lib/datadog/tracing/contrib/httpclient/ext.rb +17 -9
- data/lib/datadog/tracing/contrib/httpclient/instrumentation.rb +22 -5
- data/lib/datadog/tracing/contrib/httprb/configuration/settings.rb +33 -11
- data/lib/datadog/tracing/contrib/httprb/ext.rb +16 -9
- data/lib/datadog/tracing/contrib/httprb/instrumentation.rb +22 -5
- data/lib/datadog/tracing/contrib/kafka/configuration/settings.rb +9 -6
- data/lib/datadog/tracing/contrib/kafka/ext.rb +42 -39
- data/lib/datadog/tracing/contrib/lograge/configuration/settings.rb +3 -2
- data/lib/datadog/tracing/contrib/lograge/ext.rb +3 -1
- data/lib/datadog/tracing/contrib/lograge/instrumentation.rb +2 -17
- data/lib/datadog/tracing/contrib/mongodb/configuration/settings.rb +14 -7
- data/lib/datadog/tracing/contrib/mongodb/ext.rb +20 -16
- data/lib/datadog/tracing/contrib/mongodb/subscribers.rb +16 -5
- data/lib/datadog/tracing/contrib/mysql2/configuration/settings.rb +17 -14
- data/lib/datadog/tracing/contrib/mysql2/ext.rb +15 -10
- data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +20 -6
- data/lib/datadog/tracing/contrib/opensearch/configuration/settings.rb +52 -0
- data/lib/datadog/tracing/contrib/opensearch/ext.rb +37 -0
- data/lib/datadog/tracing/contrib/opensearch/integration.rb +44 -0
- data/lib/datadog/tracing/contrib/opensearch/patcher.rb +135 -0
- data/lib/datadog/tracing/contrib/opensearch/quantize.rb +81 -0
- data/lib/datadog/tracing/contrib/pg/configuration/settings.rb +22 -14
- data/lib/datadog/tracing/contrib/pg/ext.rb +22 -19
- data/lib/datadog/tracing/contrib/pg/instrumentation.rb +38 -5
- data/lib/datadog/tracing/contrib/presto/configuration/settings.rb +14 -7
- data/lib/datadog/tracing/contrib/presto/ext.rb +25 -20
- data/lib/datadog/tracing/contrib/presto/instrumentation.rb +14 -5
- data/lib/datadog/tracing/contrib/propagation/sql_comment/ext.rb +12 -10
- data/lib/datadog/tracing/contrib/propagation/sql_comment.rb +1 -1
- data/lib/datadog/tracing/contrib/qless/configuration/settings.rb +12 -8
- data/lib/datadog/tracing/contrib/qless/ext.rb +14 -12
- data/lib/datadog/tracing/contrib/que/configuration/settings.rb +21 -12
- data/lib/datadog/tracing/contrib/racecar/configuration/settings.rb +9 -7
- data/lib/datadog/tracing/contrib/racecar/event.rb +5 -5
- data/lib/datadog/tracing/contrib/racecar/ext.rb +20 -18
- data/lib/datadog/tracing/contrib/rack/configuration/settings.rb +16 -12
- data/lib/datadog/tracing/contrib/rack/ext.rb +18 -16
- data/lib/datadog/tracing/contrib/rack/header_collection.rb +3 -0
- data/lib/datadog/tracing/contrib/rack/header_tagging.rb +63 -0
- data/lib/datadog/tracing/contrib/rack/middlewares.rb +8 -49
- data/lib/datadog/tracing/contrib/rails/configuration/settings.rb +19 -15
- data/lib/datadog/tracing/contrib/rails/ext.rb +7 -5
- data/lib/datadog/tracing/contrib/rails/log_injection.rb +7 -10
- data/lib/datadog/tracing/contrib/rails/patcher.rb +10 -41
- data/lib/datadog/tracing/contrib/rails/railtie.rb +3 -3
- data/lib/datadog/tracing/contrib/rake/configuration/settings.rb +13 -10
- data/lib/datadog/tracing/contrib/rake/ext.rb +14 -12
- data/lib/datadog/tracing/contrib/redis/configuration/settings.rb +17 -9
- data/lib/datadog/tracing/contrib/redis/ext.rb +22 -15
- data/lib/datadog/tracing/contrib/redis/instrumentation.rb +3 -38
- data/lib/datadog/tracing/contrib/redis/tags.rb +16 -7
- data/lib/datadog/tracing/contrib/redis/trace_middleware.rb +46 -33
- data/lib/datadog/tracing/contrib/resque/configuration/settings.rb +13 -7
- data/lib/datadog/tracing/contrib/resque/ext.rb +9 -7
- data/lib/datadog/tracing/contrib/rest_client/configuration/settings.rb +16 -9
- data/lib/datadog/tracing/contrib/rest_client/ext.rb +15 -8
- data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +25 -5
- data/lib/datadog/tracing/contrib/roda/configuration/settings.rb +9 -6
- data/lib/datadog/tracing/contrib/semantic_logger/configuration/settings.rb +3 -2
- data/lib/datadog/tracing/contrib/semantic_logger/ext.rb +3 -1
- data/lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb +4 -20
- data/lib/datadog/tracing/contrib/sequel/configuration/settings.rb +9 -6
- data/lib/datadog/tracing/contrib/sequel/ext.rb +10 -8
- data/lib/datadog/tracing/contrib/sequel/utils.rb +7 -7
- data/lib/datadog/tracing/contrib/shoryuken/configuration/settings.rb +14 -8
- data/lib/datadog/tracing/contrib/shoryuken/ext.rb +14 -12
- data/lib/datadog/tracing/contrib/sidekiq/configuration/settings.rb +18 -11
- data/lib/datadog/tracing/contrib/sidekiq/ext.rb +32 -30
- data/lib/datadog/tracing/contrib/sinatra/configuration/settings.rb +11 -9
- data/lib/datadog/tracing/contrib/sinatra/env.rb +0 -17
- data/lib/datadog/tracing/contrib/sinatra/ext.rb +21 -19
- data/lib/datadog/tracing/contrib/sinatra/tracer_middleware.rb +3 -14
- data/lib/datadog/tracing/contrib/sneakers/configuration/settings.rb +14 -8
- data/lib/datadog/tracing/contrib/sneakers/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/sneakers/tracer.rb +1 -1
- data/lib/datadog/tracing/contrib/span_attribute_schema.rb +74 -10
- data/lib/datadog/tracing/contrib/stripe/configuration/settings.rb +9 -6
- data/lib/datadog/tracing/contrib/sucker_punch/configuration/settings.rb +9 -6
- data/lib/datadog/tracing/contrib/sucker_punch/ext.rb +15 -13
- data/lib/datadog/tracing/contrib/utils/database.rb +5 -3
- data/lib/datadog/tracing/contrib/utils/quantization/http.rb +11 -11
- data/lib/datadog/tracing/contrib.rb +1 -0
- data/lib/datadog/tracing/correlation.rb +29 -12
- data/lib/datadog/tracing/diagnostics/environment_logger.rb +165 -0
- data/lib/datadog/tracing/diagnostics/ext.rb +21 -19
- data/lib/datadog/tracing/distributed/b3_multi.rb +2 -2
- data/lib/datadog/tracing/distributed/b3_single.rb +1 -1
- data/lib/datadog/tracing/distributed/datadog.rb +0 -1
- data/lib/datadog/tracing/distributed/propagation.rb +35 -34
- data/lib/datadog/tracing/distributed/trace_context.rb +52 -17
- data/lib/datadog/tracing/metadata/ext.rb +9 -6
- data/lib/datadog/tracing/metadata/tagging.rb +3 -3
- data/lib/datadog/tracing/remote.rb +78 -0
- data/lib/datadog/tracing/sampling/rule_sampler.rb +29 -0
- data/lib/datadog/tracing/span_operation.rb +3 -15
- data/lib/datadog/tracing/sync_writer.rb +3 -3
- data/lib/datadog/tracing/trace_digest.rb +31 -0
- data/lib/datadog/tracing/trace_operation.rb +16 -3
- data/lib/datadog/tracing/trace_segment.rb +5 -2
- data/lib/datadog/tracing/tracer.rb +12 -1
- data/lib/datadog/{core → tracing}/transport/http/api/instance.rb +1 -1
- data/lib/datadog/{core → tracing}/transport/http/api/spec.rb +1 -1
- data/lib/datadog/tracing/transport/http/api.rb +43 -0
- data/lib/datadog/{core → tracing}/transport/http/builder.rb +13 -68
- data/lib/datadog/tracing/transport/http/client.rb +57 -0
- data/lib/datadog/tracing/transport/http/statistics.rb +47 -0
- data/lib/datadog/tracing/transport/http/traces.rb +152 -0
- data/lib/datadog/tracing/transport/http.rb +124 -0
- data/lib/datadog/tracing/transport/io/client.rb +89 -0
- data/lib/datadog/tracing/transport/io/response.rb +27 -0
- data/lib/datadog/tracing/transport/io/traces.rb +101 -0
- data/lib/datadog/tracing/transport/io.rb +30 -0
- data/lib/datadog/tracing/transport/serializable_trace.rb +126 -0
- data/lib/datadog/tracing/transport/statistics.rb +77 -0
- data/lib/datadog/tracing/transport/trace_formatter.rb +209 -0
- data/lib/datadog/tracing/transport/traces.rb +224 -0
- data/lib/datadog/tracing/workers/trace_writer.rb +6 -4
- data/lib/datadog/tracing/workers.rb +4 -2
- data/lib/datadog/tracing/writer.rb +5 -2
- data/lib/ddtrace/transport/ext.rb +22 -14
- data/lib/ddtrace/version.rb +9 -12
- data/lib/ddtrace.rb +1 -1
- metadata +101 -93
- data/lib/datadog/ci/configuration/components.rb +0 -32
- data/lib/datadog/ci/configuration/settings.rb +0 -53
- data/lib/datadog/ci/contrib/cucumber/configuration/settings.rb +0 -33
- data/lib/datadog/ci/contrib/cucumber/ext.rb +0 -20
- data/lib/datadog/ci/contrib/cucumber/formatter.rb +0 -94
- data/lib/datadog/ci/contrib/cucumber/instrumentation.rb +0 -28
- data/lib/datadog/ci/contrib/cucumber/integration.rb +0 -47
- data/lib/datadog/ci/contrib/cucumber/patcher.rb +0 -27
- data/lib/datadog/ci/contrib/rspec/configuration/settings.rb +0 -33
- data/lib/datadog/ci/contrib/rspec/example.rb +0 -68
- data/lib/datadog/ci/contrib/rspec/ext.rb +0 -19
- data/lib/datadog/ci/contrib/rspec/integration.rb +0 -48
- data/lib/datadog/ci/contrib/rspec/patcher.rb +0 -27
- data/lib/datadog/ci/ext/app_types.rb +0 -9
- data/lib/datadog/ci/ext/environment.rb +0 -575
- data/lib/datadog/ci/ext/settings.rb +0 -10
- data/lib/datadog/ci/ext/test.rb +0 -35
- data/lib/datadog/ci/extensions.rb +0 -19
- data/lib/datadog/ci/flush.rb +0 -38
- data/lib/datadog/ci/test.rb +0 -81
- data/lib/datadog/ci.rb +0 -20
- data/lib/datadog/core/configuration/dependency_resolver.rb +0 -28
- data/lib/datadog/core/configuration/option_definition_set.rb +0 -22
- data/lib/datadog/core/configuration/option_set.rb +0 -10
- data/lib/datadog/core/transport/config.rb +0 -58
- data/lib/datadog/core/transport/http/api.rb +0 -57
- data/lib/datadog/core/transport/http/client.rb +0 -45
- data/lib/datadog/core/transport/http/config.rb +0 -268
- data/lib/datadog/core/transport/http/negotiation.rb +0 -144
- data/lib/datadog/core/transport/http.rb +0 -169
- data/lib/datadog/core/utils/object_set.rb +0 -43
- data/lib/datadog/core/utils/string_table.rb +0 -47
- data/lib/datadog/profiling/backtrace_location.rb +0 -34
- data/lib/datadog/profiling/buffer.rb +0 -43
- data/lib/datadog/profiling/collectors/old_stack.rb +0 -301
- data/lib/datadog/profiling/encoding/profile.rb +0 -41
- data/lib/datadog/profiling/event.rb +0 -15
- data/lib/datadog/profiling/events/stack.rb +0 -82
- data/lib/datadog/profiling/old_recorder.rb +0 -107
- data/lib/datadog/profiling/pprof/builder.rb +0 -125
- data/lib/datadog/profiling/pprof/converter.rb +0 -102
- data/lib/datadog/profiling/pprof/message_set.rb +0 -16
- data/lib/datadog/profiling/pprof/payload.rb +0 -20
- data/lib/datadog/profiling/pprof/pprof.proto +0 -212
- data/lib/datadog/profiling/pprof/pprof_pb.rb +0 -81
- data/lib/datadog/profiling/pprof/stack_sample.rb +0 -139
- data/lib/datadog/profiling/pprof/string_table.rb +0 -12
- data/lib/datadog/profiling/pprof/template.rb +0 -118
- data/lib/datadog/profiling/trace_identifiers/ddtrace.rb +0 -43
- data/lib/datadog/profiling/trace_identifiers/helper.rb +0 -45
- data/lib/datadog/tracing/contrib/sinatra/headers.rb +0 -35
- data/lib/ddtrace/transport/http/adapters/net.rb +0 -168
- data/lib/ddtrace/transport/http/adapters/registry.rb +0 -27
- data/lib/ddtrace/transport/http/adapters/test.rb +0 -85
- data/lib/ddtrace/transport/http/adapters/unix_socket.rb +0 -77
- data/lib/ddtrace/transport/http/api/endpoint.rb +0 -29
- data/lib/ddtrace/transport/http/api/fallbacks.rb +0 -24
- data/lib/ddtrace/transport/http/api/instance.rb +0 -35
- data/lib/ddtrace/transport/http/api/map.rb +0 -16
- data/lib/ddtrace/transport/http/api/spec.rb +0 -17
- data/lib/ddtrace/transport/http/api.rb +0 -39
- data/lib/ddtrace/transport/http/builder.rb +0 -176
- data/lib/ddtrace/transport/http/client.rb +0 -52
- data/lib/ddtrace/transport/http/env.rb +0 -58
- data/lib/ddtrace/transport/http/response.rb +0 -58
- data/lib/ddtrace/transport/http/statistics.rb +0 -43
- data/lib/ddtrace/transport/http/traces.rb +0 -144
- data/lib/ddtrace/transport/http.rb +0 -117
- data/lib/ddtrace/transport/io/client.rb +0 -85
- data/lib/ddtrace/transport/io/response.rb +0 -25
- data/lib/ddtrace/transport/io/traces.rb +0 -99
- data/lib/ddtrace/transport/io.rb +0 -28
- data/lib/ddtrace/transport/parcel.rb +0 -20
- data/lib/ddtrace/transport/request.rb +0 -15
- data/lib/ddtrace/transport/response.rb +0 -60
- data/lib/ddtrace/transport/serializable_trace.rb +0 -122
- data/lib/ddtrace/transport/statistics.rb +0 -75
- data/lib/ddtrace/transport/trace_formatter.rb +0 -198
- data/lib/ddtrace/transport/traces.rb +0 -216
|
@@ -14,9 +14,24 @@ module Datadog
|
|
|
14
14
|
#
|
|
15
15
|
# Methods prefixed with _native_ are implemented in `collectors_thread_context.c`
|
|
16
16
|
class ThreadContext
|
|
17
|
-
def initialize(
|
|
17
|
+
def initialize(
|
|
18
|
+
recorder:,
|
|
19
|
+
max_frames:,
|
|
20
|
+
tracer:,
|
|
21
|
+
endpoint_collection_enabled:,
|
|
22
|
+
timeline_enabled:,
|
|
23
|
+
allocation_type_enabled: true
|
|
24
|
+
)
|
|
18
25
|
tracer_context_key = safely_extract_context_key_from(tracer)
|
|
19
|
-
self.class._native_initialize(
|
|
26
|
+
self.class._native_initialize(
|
|
27
|
+
self,
|
|
28
|
+
recorder,
|
|
29
|
+
max_frames,
|
|
30
|
+
tracer_context_key,
|
|
31
|
+
endpoint_collection_enabled,
|
|
32
|
+
timeline_enabled,
|
|
33
|
+
allocation_type_enabled,
|
|
34
|
+
)
|
|
20
35
|
end
|
|
21
36
|
|
|
22
37
|
def inspect
|
|
@@ -8,6 +8,10 @@ module Datadog
|
|
|
8
8
|
# * Code Hotspots panel in the trace viewer, as well as scoping a profile down to a span
|
|
9
9
|
# * Endpoint aggregation in the profiler UX, including normalization (resource per endpoint call)
|
|
10
10
|
def self.build_profiler_component(settings:, agent_settings:, optional_tracer:)
|
|
11
|
+
require_relative '../profiling/diagnostics/environment_logger'
|
|
12
|
+
|
|
13
|
+
Profiling::Diagnostics::EnvironmentLogger.collect_and_log!
|
|
14
|
+
|
|
11
15
|
return unless settings.profiling.enabled
|
|
12
16
|
|
|
13
17
|
# Workaround for weird dependency direction: the Core::Configuration::Components class currently has a
|
|
@@ -30,89 +34,53 @@ module Datadog
|
|
|
30
34
|
require_relative '../profiling'
|
|
31
35
|
return unless Profiling.supported?
|
|
32
36
|
|
|
33
|
-
|
|
34
|
-
# In #1545 a user reported a NameError due to this constant being uninitialized
|
|
35
|
-
# I've documented my suspicion on why that happened in
|
|
36
|
-
# https://github.com/DataDog/dd-trace-rb/issues/1545#issuecomment-856049025
|
|
37
|
-
#
|
|
38
|
-
# > Thanks for the info! It seems to feed into my theory: there's two moments in the code where we check if
|
|
39
|
-
# > profiler is "supported": 1) when loading ddtrace (inside preload) and 2) when starting the profile
|
|
40
|
-
# > after Datadog.configure gets run.
|
|
41
|
-
# > The problem is that the code assumes that both checks 1) and 2) will always reach the same conclusion:
|
|
42
|
-
# > either profiler is supported, or profiler is not supported.
|
|
43
|
-
# > In the problematic case, it looks like in your case check 1 decides that profiler is not
|
|
44
|
-
# > supported => doesn't load it, and then check 2 decides that it is => assumes it is loaded and tries to
|
|
45
|
-
# > start it.
|
|
46
|
-
#
|
|
47
|
-
# I was never able to validate if this was the issue or why exactly .supported? would change its mind BUT
|
|
48
|
-
# just in case it happens again, I've left this check which avoids breaking the user's application AND
|
|
49
|
-
# would instead direct them to report it to us instead, so that we can investigate what's wrong.
|
|
50
|
-
#
|
|
51
|
-
# TODO: As of June 2021, most checks in .supported? are related to the google-protobuf gem; so it's
|
|
52
|
-
# very likely that it was the origin of the issue we saw. Thus, if, as planned we end up moving away from
|
|
53
|
-
# protobuf OR enough time has passed and no users saw the issue again, we can remove this check altogether.
|
|
54
|
-
Datadog.logger.error(
|
|
55
|
-
'Profiling was marked as supported and enabled, but setup task was not loaded properly. ' \
|
|
56
|
-
'Please report this at https://github.com/DataDog/dd-trace-rb/blob/master/CONTRIBUTING.md#found-a-bug'
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
return
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
# Load extensions needed to support some of the Profiling features
|
|
37
|
+
# Activate forking extensions
|
|
63
38
|
Profiling::Tasks::Setup.new.run
|
|
64
39
|
|
|
65
40
|
# NOTE: Please update the Initialization section of ProfilingDevelopment.md with any changes to this method
|
|
66
41
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
cpu_time_enabled: RUBY_PLATFORM.include?('linux'), # Only supported on Linux currently
|
|
70
|
-
alloc_samples_enabled: false, # Always disabled for now -- work in progress
|
|
71
|
-
)
|
|
72
|
-
collector = Datadog::Profiling::Collectors::CpuAndWallTimeWorker.new(
|
|
73
|
-
recorder: recorder,
|
|
74
|
-
max_frames: settings.profiling.advanced.max_frames,
|
|
75
|
-
tracer: optional_tracer,
|
|
76
|
-
endpoint_collection_enabled: settings.profiling.advanced.endpoint.collection.enabled,
|
|
77
|
-
gc_profiling_enabled: enable_gc_profiling?(settings),
|
|
78
|
-
allocation_counting_enabled: settings.profiling.advanced.allocation_counting_enabled,
|
|
79
|
-
no_signals_workaround_enabled: no_signals_workaround_enabled?(settings),
|
|
80
|
-
)
|
|
81
|
-
else
|
|
82
|
-
load_pprof_support
|
|
42
|
+
no_signals_workaround_enabled = no_signals_workaround_enabled?(settings)
|
|
43
|
+
timeline_enabled = settings.profiling.advanced.experimental_timeline_enabled
|
|
83
44
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
45
|
+
recorder = Datadog::Profiling::StackRecorder.new(
|
|
46
|
+
cpu_time_enabled: RUBY_PLATFORM.include?('linux'), # Only supported on Linux currently
|
|
47
|
+
alloc_samples_enabled: false, # Always disabled for now -- work in progress
|
|
48
|
+
)
|
|
49
|
+
thread_context_collector = Datadog::Profiling::Collectors::ThreadContext.new(
|
|
50
|
+
recorder: recorder,
|
|
51
|
+
max_frames: settings.profiling.advanced.max_frames,
|
|
52
|
+
tracer: optional_tracer,
|
|
53
|
+
endpoint_collection_enabled: settings.profiling.advanced.endpoint.collection.enabled,
|
|
54
|
+
timeline_enabled: timeline_enabled,
|
|
55
|
+
)
|
|
56
|
+
worker = Datadog::Profiling::Collectors::CpuAndWallTimeWorker.new(
|
|
57
|
+
gc_profiling_enabled: enable_gc_profiling?(settings),
|
|
58
|
+
allocation_counting_enabled: settings.profiling.advanced.allocation_counting_enabled,
|
|
59
|
+
no_signals_workaround_enabled: no_signals_workaround_enabled,
|
|
60
|
+
thread_context_collector: thread_context_collector,
|
|
61
|
+
allocation_sample_every: 0,
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
internal_metadata = {
|
|
65
|
+
no_signals_workaround_enabled: no_signals_workaround_enabled,
|
|
66
|
+
timeline_enabled: timeline_enabled,
|
|
67
|
+
}.freeze
|
|
87
68
|
|
|
88
|
-
exporter = build_profiler_exporter(settings, recorder)
|
|
69
|
+
exporter = build_profiler_exporter(settings, recorder, internal_metadata: internal_metadata)
|
|
89
70
|
transport = build_profiler_transport(settings, agent_settings)
|
|
90
71
|
scheduler = Profiling::Scheduler.new(exporter: exporter, transport: transport)
|
|
91
72
|
|
|
92
|
-
Profiling::Profiler.new(
|
|
73
|
+
Profiling::Profiler.new(worker: worker, scheduler: scheduler)
|
|
93
74
|
end
|
|
94
75
|
|
|
95
|
-
private_class_method def self.
|
|
96
|
-
Profiling::OldRecorder.new([Profiling::Events::StackSample], settings.profiling.advanced.max_events)
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
private_class_method def self.build_profiler_exporter(settings, recorder)
|
|
76
|
+
private_class_method def self.build_profiler_exporter(settings, recorder, internal_metadata:)
|
|
100
77
|
code_provenance_collector =
|
|
101
78
|
(Profiling::Collectors::CodeProvenance.new if settings.profiling.advanced.code_provenance_enabled)
|
|
102
79
|
|
|
103
|
-
Profiling::Exporter.new(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
trace_identifiers_helper = Profiling::TraceIdentifiers::Helper.new(
|
|
108
|
-
tracer: tracer,
|
|
109
|
-
endpoint_collection_enabled: settings.profiling.advanced.endpoint.collection.enabled
|
|
110
|
-
)
|
|
111
|
-
|
|
112
|
-
Profiling::Collectors::OldStack.new(
|
|
113
|
-
old_recorder,
|
|
114
|
-
trace_identifiers_helper: trace_identifiers_helper,
|
|
115
|
-
max_frames: settings.profiling.advanced.max_frames
|
|
80
|
+
Profiling::Exporter.new(
|
|
81
|
+
pprof_recorder: recorder,
|
|
82
|
+
code_provenance_collector: code_provenance_collector,
|
|
83
|
+
internal_metadata: internal_metadata,
|
|
116
84
|
)
|
|
117
85
|
end
|
|
118
86
|
|
|
@@ -142,17 +110,6 @@ module Datadog
|
|
|
142
110
|
end
|
|
143
111
|
end
|
|
144
112
|
|
|
145
|
-
private_class_method def self.enable_new_profiler?(settings)
|
|
146
|
-
if settings.profiling.advanced.force_enable_legacy_profiler
|
|
147
|
-
Datadog.logger.warn(
|
|
148
|
-
'Legacy profiler has been force-enabled via configuration. Do not use unless instructed to by support.'
|
|
149
|
-
)
|
|
150
|
-
return false
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
true
|
|
154
|
-
end
|
|
155
|
-
|
|
156
113
|
private_class_method def self.no_signals_workaround_enabled?(settings) # rubocop:disable Metrics/MethodLength
|
|
157
114
|
setting_value = settings.profiling.advanced.no_signals_workaround_enabled
|
|
158
115
|
legacy_ruby_that_should_use_workaround = RUBY_VERSION.start_with?('2.3.', '2.4.', '2.5.')
|
|
@@ -198,7 +155,7 @@ module Datadog
|
|
|
198
155
|
if Gem.loaded_specs['mysql2'] && incompatible_libmysqlclient_version?(settings)
|
|
199
156
|
Datadog.logger.warn(
|
|
200
157
|
'Enabling the profiling "no signals" workaround because an incompatible version of the mysql2 gem is ' \
|
|
201
|
-
'installed. Profiling data will have lower quality.' \
|
|
158
|
+
'installed. Profiling data will have lower quality. ' \
|
|
202
159
|
'To fix this, upgrade the libmysqlclient in your OS image to version 8.0.0 or above.'
|
|
203
160
|
)
|
|
204
161
|
return true
|
|
@@ -214,6 +171,15 @@ module Datadog
|
|
|
214
171
|
return true
|
|
215
172
|
end
|
|
216
173
|
|
|
174
|
+
if (defined?(::PhusionPassenger) || Gem.loaded_specs['passenger']) && incompatible_passenger_version?
|
|
175
|
+
Datadog.logger.warn(
|
|
176
|
+
'Enabling the profiling "no signals" workaround because an incompatible version of the passenger gem is ' \
|
|
177
|
+
'installed. Profiling data will have lower quality.' \
|
|
178
|
+
'To fix this, upgrade the passenger gem to version 6.0.19 or above.'
|
|
179
|
+
)
|
|
180
|
+
return true
|
|
181
|
+
end
|
|
182
|
+
|
|
217
183
|
false
|
|
218
184
|
end
|
|
219
185
|
|
|
@@ -236,9 +202,22 @@ module Datadog
|
|
|
236
202
|
begin
|
|
237
203
|
require 'mysql2'
|
|
238
204
|
|
|
239
|
-
|
|
205
|
+
# The mysql2-aurora gem likes to monkey patch itself in replacement of Mysql2::Client, and uses
|
|
206
|
+
# `method_missing` to delegate to the original BUT unfortunately does not implement `respond_to_missing?` and
|
|
207
|
+
# thus our `respond_to?(:info)` below was failing.
|
|
208
|
+
#
|
|
209
|
+
# But on the bright side, the gem does stash a reference to the original Mysql2::Client class in a constant,
|
|
210
|
+
# so if that constant exists, we use that for our probing.
|
|
211
|
+
mysql2_client_class =
|
|
212
|
+
if defined?(Mysql2::Aurora::ORIGINAL_CLIENT_CLASS)
|
|
213
|
+
Mysql2::Aurora::ORIGINAL_CLIENT_CLASS
|
|
214
|
+
elsif defined?(Mysql2::Client)
|
|
215
|
+
Mysql2::Client
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
return true unless mysql2_client_class && mysql2_client_class.respond_to?(:info)
|
|
240
219
|
|
|
241
|
-
libmysqlclient_version = Gem::Version.new(
|
|
220
|
+
libmysqlclient_version = Gem::Version.new(mysql2_client_class.info[:version])
|
|
242
221
|
|
|
243
222
|
compatible = libmysqlclient_version >= Gem::Version.new('8.0.0')
|
|
244
223
|
|
|
@@ -258,17 +237,13 @@ module Datadog
|
|
|
258
237
|
end
|
|
259
238
|
end
|
|
260
239
|
|
|
261
|
-
#
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
# pprof support code, we only load the conflicting file when the old profiler is in use. This way customers using
|
|
269
|
-
# the new profiler will not be affected by the issue any longer.
|
|
270
|
-
private_class_method def self.load_pprof_support
|
|
271
|
-
require_relative 'pprof/pprof_pb'
|
|
240
|
+
# See https://github.com/datadog/dd-trace-rb/issues/2976 for details.
|
|
241
|
+
private_class_method def self.incompatible_passenger_version?
|
|
242
|
+
if Gem.loaded_specs['passenger']
|
|
243
|
+
Gem.loaded_specs['passenger'].version < Gem::Version.new('6.0.19')
|
|
244
|
+
else
|
|
245
|
+
true
|
|
246
|
+
end
|
|
272
247
|
end
|
|
273
248
|
end
|
|
274
249
|
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'date'
|
|
4
|
+
require 'json'
|
|
5
|
+
require 'rbconfig'
|
|
6
|
+
require_relative '../../core/diagnostics/environment_logger'
|
|
7
|
+
|
|
8
|
+
module Datadog
|
|
9
|
+
module Profiling
|
|
10
|
+
module Diagnostics
|
|
11
|
+
# Collects and logs Profiling diagnostic information
|
|
12
|
+
module EnvironmentLogger
|
|
13
|
+
extend Core::Diagnostics::EnvironmentLogging
|
|
14
|
+
|
|
15
|
+
def self.collect_and_log!
|
|
16
|
+
log_once! do
|
|
17
|
+
data = EnvironmentCollector.collect_config!
|
|
18
|
+
log_configuration!('PROFILING', data.to_json)
|
|
19
|
+
end
|
|
20
|
+
rescue => e
|
|
21
|
+
logger.warn("Failed to collect profiling environment information: #{e} Location: #{Array(e.backtrace).first}")
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Collects environment information for Profiling diagnostic logging
|
|
26
|
+
module EnvironmentCollector
|
|
27
|
+
def self.collect_config!(*args)
|
|
28
|
+
{
|
|
29
|
+
profiling_enabled: profiling_enabled
|
|
30
|
+
}
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def self.profiling_enabled
|
|
34
|
+
!!Datadog.configuration.profiling.enabled
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -22,13 +22,15 @@ module Datadog
|
|
|
22
22
|
:minimum_duration_seconds,
|
|
23
23
|
:time_provider,
|
|
24
24
|
:last_flush_finish_at,
|
|
25
|
-
:created_at
|
|
25
|
+
:created_at,
|
|
26
|
+
:internal_metadata
|
|
26
27
|
|
|
27
28
|
public
|
|
28
29
|
|
|
29
30
|
def initialize(
|
|
30
31
|
pprof_recorder:,
|
|
31
32
|
code_provenance_collector:,
|
|
33
|
+
internal_metadata:,
|
|
32
34
|
minimum_duration_seconds: PROFILE_DURATION_THRESHOLD_SECONDS,
|
|
33
35
|
time_provider: Time
|
|
34
36
|
)
|
|
@@ -38,6 +40,7 @@ module Datadog
|
|
|
38
40
|
@time_provider = time_provider
|
|
39
41
|
@last_flush_finish_at = nil
|
|
40
42
|
@created_at = time_provider.now.utc
|
|
43
|
+
@internal_metadata = internal_metadata
|
|
41
44
|
end
|
|
42
45
|
|
|
43
46
|
def flush
|
|
@@ -61,6 +64,7 @@ module Datadog
|
|
|
61
64
|
code_provenance_file_name: Datadog::Profiling::Ext::Transport::HTTP::CODE_PROVENANCE_FILENAME,
|
|
62
65
|
code_provenance_data: uncompressed_code_provenance,
|
|
63
66
|
tags_as_array: Datadog::Profiling::TagBuilder.call(settings: Datadog.configuration).to_a,
|
|
67
|
+
internal_metadata: internal_metadata,
|
|
64
68
|
)
|
|
65
69
|
end
|
|
66
70
|
|
|
@@ -9,18 +9,6 @@ module Datadog
|
|
|
9
9
|
ENV_AGENTLESS = 'DD_PROFILING_AGENTLESS'
|
|
10
10
|
ENV_ENDPOINT_COLLECTION_ENABLED = 'DD_PROFILING_ENDPOINT_COLLECTION_ENABLED'
|
|
11
11
|
|
|
12
|
-
# TODO: Consider removing this once the Ruby-based pprof encoding is removed and replaced by libdatadog
|
|
13
|
-
module Pprof
|
|
14
|
-
LABEL_KEY_LOCAL_ROOT_SPAN_ID = 'local root span id'
|
|
15
|
-
LABEL_KEY_SPAN_ID = 'span id'
|
|
16
|
-
LABEL_KEY_THREAD_ID = 'thread id'
|
|
17
|
-
LABEL_KEY_TRACE_ENDPOINT = 'trace endpoint'
|
|
18
|
-
SAMPLE_VALUE_NO_VALUE = 0
|
|
19
|
-
VALUE_TYPE_CPU = 'cpu-time'
|
|
20
|
-
VALUE_TYPE_WALL = 'wall-time'
|
|
21
|
-
VALUE_UNIT_NANOSECONDS = 'nanoseconds'
|
|
22
|
-
end
|
|
23
|
-
|
|
24
12
|
module Transport
|
|
25
13
|
module HTTP
|
|
26
14
|
FORM_FIELD_TAG_ENV = 'env'
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'json'
|
|
4
|
+
|
|
3
5
|
module Datadog
|
|
4
6
|
module Profiling
|
|
5
|
-
# Represents a collection of events of a specific type being flushed.
|
|
6
|
-
EventGroup = Struct.new(:event_class, :events)
|
|
7
|
-
|
|
8
7
|
# Entity class used to represent metadata for a given profile
|
|
9
8
|
class Flush
|
|
10
9
|
attr_reader \
|
|
@@ -14,7 +13,8 @@ module Datadog
|
|
|
14
13
|
:pprof_data, # gzipped pprof bytes
|
|
15
14
|
:code_provenance_file_name,
|
|
16
15
|
:code_provenance_data, # gzipped json bytes
|
|
17
|
-
:tags_as_array
|
|
16
|
+
:tags_as_array,
|
|
17
|
+
:internal_metadata_json
|
|
18
18
|
|
|
19
19
|
def initialize(
|
|
20
20
|
start:,
|
|
@@ -23,7 +23,8 @@ module Datadog
|
|
|
23
23
|
pprof_data:,
|
|
24
24
|
code_provenance_file_name:,
|
|
25
25
|
code_provenance_data:,
|
|
26
|
-
tags_as_array
|
|
26
|
+
tags_as_array:,
|
|
27
|
+
internal_metadata:
|
|
27
28
|
)
|
|
28
29
|
@start = start
|
|
29
30
|
@finish = finish
|
|
@@ -32,6 +33,7 @@ module Datadog
|
|
|
32
33
|
@code_provenance_file_name = code_provenance_file_name
|
|
33
34
|
@code_provenance_data = code_provenance_data
|
|
34
35
|
@tags_as_array = tags_as_array
|
|
36
|
+
@internal_metadata_json = JSON.fast_generate(internal_metadata.map { |k, v| [k, v.to_s] }.to_h)
|
|
35
37
|
end
|
|
36
38
|
end
|
|
37
39
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require_relative '../core/transport/ext'
|
|
2
|
+
|
|
1
3
|
module Datadog
|
|
2
4
|
module Profiling
|
|
3
5
|
# Used to report profiling data to Datadog.
|
|
@@ -40,6 +42,7 @@ module Datadog
|
|
|
40
42
|
code_provenance_data: flush.code_provenance_data,
|
|
41
43
|
|
|
42
44
|
tags_as_array: flush.tags_as_array,
|
|
45
|
+
internal_metadata_json: flush.internal_metadata_json,
|
|
43
46
|
)
|
|
44
47
|
|
|
45
48
|
if status == :ok
|
|
@@ -47,11 +50,14 @@ module Datadog
|
|
|
47
50
|
Datadog.logger.debug('Successfully reported profiling data')
|
|
48
51
|
true
|
|
49
52
|
else
|
|
50
|
-
Datadog.logger.error(
|
|
53
|
+
Datadog.logger.error(
|
|
54
|
+
"Failed to report profiling data (#{config_without_api_key}): " \
|
|
55
|
+
"server returned unexpected HTTP #{result} status code"
|
|
56
|
+
)
|
|
51
57
|
false
|
|
52
58
|
end
|
|
53
59
|
else
|
|
54
|
-
Datadog.logger.error("Failed to report profiling data: #{result}")
|
|
60
|
+
Datadog.logger.error("Failed to report profiling data (#{config_without_api_key}): #{result}")
|
|
55
61
|
false
|
|
56
62
|
end
|
|
57
63
|
end
|
|
@@ -66,9 +72,9 @@ module Datadog
|
|
|
66
72
|
|
|
67
73
|
def base_url_from(agent_settings)
|
|
68
74
|
case agent_settings.adapter
|
|
69
|
-
when Datadog::Transport::Ext::HTTP::ADAPTER
|
|
75
|
+
when Datadog::Core::Transport::Ext::HTTP::ADAPTER
|
|
70
76
|
"#{agent_settings.ssl ? 'https' : 'http'}://#{agent_settings.hostname}:#{agent_settings.port}/"
|
|
71
|
-
when Datadog::Transport::Ext::UnixSocket::ADAPTER
|
|
77
|
+
when Datadog::Core::Transport::Ext::UnixSocket::ADAPTER
|
|
72
78
|
"unix://#{agent_settings.uds_path}"
|
|
73
79
|
else
|
|
74
80
|
raise ArgumentError, "Unexpected adapter: #{agent_settings.adapter}"
|
|
@@ -76,7 +82,8 @@ module Datadog
|
|
|
76
82
|
end
|
|
77
83
|
|
|
78
84
|
def validate_agent_settings(agent_settings)
|
|
79
|
-
supported_adapters = [Datadog::Transport::Ext::HTTP::ADAPTER,
|
|
85
|
+
supported_adapters = [Datadog::Core::Transport::Ext::HTTP::ADAPTER,
|
|
86
|
+
Datadog::Core::Transport::Ext::UnixSocket::ADAPTER]
|
|
80
87
|
unless supported_adapters.include?(agent_settings.adapter)
|
|
81
88
|
raise ArgumentError,
|
|
82
89
|
"Unsupported transport configuration for profiling: Adapter #{agent_settings.adapter} " \
|
|
@@ -109,7 +116,8 @@ module Datadog
|
|
|
109
116
|
pprof_data:,
|
|
110
117
|
code_provenance_file_name:,
|
|
111
118
|
code_provenance_data:,
|
|
112
|
-
tags_as_array
|
|
119
|
+
tags_as_array:,
|
|
120
|
+
internal_metadata_json:
|
|
113
121
|
)
|
|
114
122
|
self.class._native_do_export(
|
|
115
123
|
exporter_configuration,
|
|
@@ -123,8 +131,13 @@ module Datadog
|
|
|
123
131
|
code_provenance_file_name,
|
|
124
132
|
code_provenance_data,
|
|
125
133
|
tags_as_array,
|
|
134
|
+
internal_metadata_json,
|
|
126
135
|
)
|
|
127
136
|
end
|
|
137
|
+
|
|
138
|
+
def config_without_api_key
|
|
139
|
+
[@exporter_configuration[0..1]].to_h
|
|
140
|
+
end
|
|
128
141
|
end
|
|
129
142
|
end
|
|
130
143
|
end
|
|
@@ -9,7 +9,13 @@
|
|
|
9
9
|
# All code on this file is on-purpose at the top-level; this makes it so this file is executed only once,
|
|
10
10
|
# the first time it gets required, to avoid any issues with the native extension being initialized more than once.
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
begin
|
|
13
|
+
require "ddtrace_profiling_loader.#{RUBY_VERSION}_#{RUBY_PLATFORM}"
|
|
14
|
+
rescue LoadError => e
|
|
15
|
+
raise LoadError,
|
|
16
|
+
'Failed to load the profiling loader extension. To fix this, please remove and then reinstall ddtrace ' \
|
|
17
|
+
"(Details: #{e.message})"
|
|
18
|
+
end
|
|
13
19
|
|
|
14
20
|
extension_name = "ddtrace_profiling_native_extension.#{RUBY_VERSION}_#{RUBY_PLATFORM}"
|
|
15
21
|
full_file_path = "#{__dir__}/../../#{extension_name}.#{RbConfig::CONFIG['DLEXT']}"
|
|
@@ -15,27 +15,6 @@ module Datadog
|
|
|
15
15
|
false
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
|
-
|
|
19
|
-
unless singleton_class.method_defined?(:clock_id_for)
|
|
20
|
-
def self.clock_id_for(_)
|
|
21
|
-
nil
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def self.cpu_time_ns_for(thread)
|
|
26
|
-
clock_id =
|
|
27
|
-
begin
|
|
28
|
-
clock_id_for(thread)
|
|
29
|
-
rescue Errno::ESRCH
|
|
30
|
-
nil
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
begin
|
|
34
|
-
::Process.clock_gettime(clock_id, :nanosecond) if clock_id
|
|
35
|
-
rescue Errno::EINVAL
|
|
36
|
-
nil
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
18
|
end
|
|
40
19
|
end
|
|
41
20
|
end
|
|
@@ -1,39 +1,62 @@
|
|
|
1
1
|
module Datadog
|
|
2
2
|
module Profiling
|
|
3
|
-
# Profiling entry point, which coordinates
|
|
3
|
+
# Profiling entry point, which coordinates the worker and scheduler threads
|
|
4
4
|
class Profiler
|
|
5
5
|
include Datadog::Core::Utils::Forking
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
:collectors,
|
|
9
|
-
:scheduler
|
|
7
|
+
private
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
attr_reader :worker, :scheduler
|
|
10
|
+
|
|
11
|
+
public
|
|
12
|
+
|
|
13
|
+
def initialize(worker:, scheduler:)
|
|
14
|
+
@worker = worker
|
|
13
15
|
@scheduler = scheduler
|
|
14
16
|
end
|
|
15
17
|
|
|
16
18
|
def start
|
|
17
19
|
after_fork! do
|
|
18
|
-
|
|
20
|
+
worker.reset_after_fork
|
|
19
21
|
scheduler.reset_after_fork
|
|
20
22
|
end
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
scheduler.start
|
|
24
|
+
worker.start(on_failure_proc: proc { component_failed(:worker) })
|
|
25
|
+
scheduler.start(on_failure_proc: proc { component_failed(:scheduler) })
|
|
24
26
|
end
|
|
25
27
|
|
|
26
28
|
def shutdown!
|
|
27
29
|
Datadog.logger.debug('Shutting down profiler')
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
stop_worker
|
|
32
|
+
stop_scheduler
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
private
|
|
33
36
|
|
|
37
|
+
def stop_worker
|
|
38
|
+
worker.stop
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def stop_scheduler
|
|
34
42
|
scheduler.enabled = false
|
|
35
43
|
scheduler.stop(true)
|
|
36
44
|
end
|
|
45
|
+
|
|
46
|
+
def component_failed(failed_component)
|
|
47
|
+
Datadog.logger.warn(
|
|
48
|
+
"Detected issue with profiler (#{failed_component} component), stopping profiling. " \
|
|
49
|
+
'See previous log messages for details.'
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
if failed_component == :worker
|
|
53
|
+
stop_scheduler
|
|
54
|
+
elsif failed_component == :scheduler
|
|
55
|
+
stop_worker
|
|
56
|
+
else
|
|
57
|
+
raise ArgumentError, "Unexpected failed_component: #{failed_component.inspect}"
|
|
58
|
+
end
|
|
59
|
+
end
|
|
37
60
|
end
|
|
38
61
|
end
|
|
39
62
|
end
|
|
@@ -45,20 +45,27 @@ module Datadog
|
|
|
45
45
|
self.enabled = enabled
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
-
def start
|
|
49
|
-
perform
|
|
48
|
+
def start(on_failure_proc: nil)
|
|
49
|
+
perform(on_failure_proc)
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
-
def perform
|
|
53
|
-
# A profiling flush may be called while the VM is shutting down, to report the last profile. When we do so,
|
|
54
|
-
# we impose a strict timeout. This means this last profile may or may not be sent, depending on if the flush can
|
|
55
|
-
# successfully finish in the strict timeout.
|
|
56
|
-
# This can be somewhat confusing (why did it not get reported?), so let's at least log what happened.
|
|
57
|
-
interrupted = true
|
|
58
|
-
|
|
52
|
+
def perform(on_failure_proc)
|
|
59
53
|
begin
|
|
54
|
+
# A profiling flush may be called while the VM is shutting down, to report the last profile. When we do so,
|
|
55
|
+
# we impose a strict timeout. This means this last profile may or may not be sent, depending on if the flush can
|
|
56
|
+
# successfully finish in the strict timeout.
|
|
57
|
+
# This can be somewhat confusing (why did it not get reported?), so let's at least log what happened.
|
|
58
|
+
interrupted = true
|
|
59
|
+
|
|
60
60
|
flush_and_wait
|
|
61
61
|
interrupted = false
|
|
62
|
+
rescue Exception => e # rubocop:disable Lint/RescueException
|
|
63
|
+
Datadog.logger.warn(
|
|
64
|
+
'Profiling::Scheduler thread error. ' \
|
|
65
|
+
"Cause: #{e.class.name} #{e.message} Location: #{Array(e.backtrace).first}"
|
|
66
|
+
)
|
|
67
|
+
on_failure_proc&.call
|
|
68
|
+
raise
|
|
62
69
|
ensure
|
|
63
70
|
Datadog.logger.debug('#flush was interrupted or failed before it could complete') if interrupted
|
|
64
71
|
end
|