ddtrace 1.12.1 → 1.23.2
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 +613 -9
- data/LICENSE-3rdparty.csv +1 -1
- data/bin/ddprofrb +15 -0
- data/bin/ddtracerb +3 -1
- data/ext/{ddtrace_profiling_loader/ddtrace_profiling_loader.c → datadog_profiling_loader/datadog_profiling_loader.c} +2 -2
- data/ext/{ddtrace_profiling_loader → datadog_profiling_loader}/extconf.rb +3 -3
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/NativeExtensionDesign.md +3 -5
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/clock_id.h +0 -3
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/clock_id_from_pthread.c +3 -22
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/clock_id_noop.c +0 -1
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_cpu_and_wall_time_worker.c +338 -108
- data/ext/datadog_profiling_native_extension/collectors_discrete_dynamic_sampler.c +422 -0
- data/ext/datadog_profiling_native_extension/collectors_discrete_dynamic_sampler.h +101 -0
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_dynamic_sampling_rate.c +22 -14
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_dynamic_sampling_rate.h +4 -0
- data/ext/datadog_profiling_native_extension/collectors_gc_profiling_helper.c +156 -0
- data/ext/datadog_profiling_native_extension/collectors_gc_profiling_helper.h +5 -0
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_idle_sampling_helper.c +3 -0
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_stack.c +111 -118
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_stack.h +11 -4
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_thread_context.c +545 -144
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_thread_context.h +3 -2
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/extconf.rb +68 -17
- data/ext/datadog_profiling_native_extension/heap_recorder.c +1047 -0
- data/ext/datadog_profiling_native_extension/heap_recorder.h +166 -0
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/helpers.h +6 -0
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/http_transport.c +60 -32
- data/ext/datadog_profiling_native_extension/libdatadog_helpers.c +62 -0
- data/ext/datadog_profiling_native_extension/libdatadog_helpers.h +42 -0
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/native_extension_helpers.rb +50 -4
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/private_vm_api_access.c +155 -32
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/private_vm_api_access.h +16 -0
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/profiling.c +19 -3
- data/ext/datadog_profiling_native_extension/ruby_helpers.c +267 -0
- data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/ruby_helpers.h +33 -0
- data/ext/datadog_profiling_native_extension/stack_recorder.c +1040 -0
- data/ext/datadog_profiling_native_extension/stack_recorder.h +27 -0
- data/ext/datadog_profiling_native_extension/time_helpers.c +53 -0
- data/ext/datadog_profiling_native_extension/time_helpers.h +26 -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 +57 -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 +77 -27
- 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/auto_instrument.rb +3 -0
- 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 +20 -7
- data/lib/datadog/core/configuration/ext.rb +28 -5
- data/lib/datadog/core/configuration/option.rb +271 -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 +398 -119
- data/lib/datadog/core/configuration.rb +24 -4
- data/lib/datadog/core/diagnostics/environment_logger.rb +132 -235
- data/lib/datadog/core/environment/class_count.rb +6 -6
- data/lib/datadog/core/environment/execution.rb +103 -0
- data/lib/datadog/core/environment/ext.rb +13 -11
- data/lib/datadog/core/environment/git.rb +25 -0
- data/lib/datadog/core/environment/identity.rb +18 -48
- data/lib/datadog/core/environment/platform.rb +7 -1
- 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 +6 -23
- 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 +7 -2
- data/lib/datadog/core/remote/client.rb +3 -0
- data/lib/datadog/core/remote/component.rb +52 -48
- 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 +2 -1
- data/lib/datadog/core/remote/negotiation.rb +20 -7
- data/lib/datadog/core/remote/tie/tracing.rb +39 -0
- data/lib/datadog/core/remote/tie.rb +27 -0
- 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 +11 -5
- 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 +28 -10
- data/lib/datadog/core/telemetry/emitter.rb +9 -11
- data/lib/datadog/core/telemetry/event.rb +250 -44
- data/lib/datadog/core/telemetry/ext.rb +8 -1
- data/lib/datadog/core/telemetry/heartbeat.rb +3 -7
- data/lib/datadog/core/telemetry/http/ext.rb +13 -8
- data/lib/datadog/core/telemetry/http/response.rb +4 -0
- data/lib/datadog/core/telemetry/http/transport.rb +10 -3
- data/lib/datadog/core/telemetry/request.rb +59 -0
- data/lib/datadog/core/transport/ext.rb +49 -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/url.rb +25 -0
- 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 +5 -3
- 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 +4 -0
- data/lib/datadog/opentracer/text_map_propagator.rb +2 -1
- data/lib/datadog/opentracer.rb +9 -0
- data/lib/datadog/profiling/collectors/code_provenance.rb +10 -4
- data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +43 -20
- data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +3 -1
- data/lib/datadog/profiling/collectors/info.rb +101 -0
- data/lib/datadog/profiling/collectors/thread_context.rb +17 -2
- data/lib/datadog/profiling/component.rb +248 -97
- data/lib/datadog/profiling/exporter.rb +26 -5
- data/lib/datadog/profiling/ext.rb +2 -12
- data/lib/datadog/profiling/flush.rb +10 -5
- data/lib/datadog/profiling/http_transport.rb +23 -6
- data/lib/datadog/profiling/load_native_extension.rb +25 -6
- data/lib/datadog/profiling/native_extension.rb +1 -22
- data/lib/datadog/profiling/profiler.rb +36 -13
- data/lib/datadog/profiling/scheduler.rb +20 -15
- data/lib/datadog/profiling/stack_recorder.rb +19 -4
- data/lib/datadog/profiling/tag_builder.rb +5 -0
- data/lib/datadog/profiling/tasks/exec.rb +3 -3
- data/lib/datadog/profiling/tasks/help.rb +3 -3
- data/lib/datadog/profiling.rb +28 -79
- 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 -33
- data/lib/datadog/tracing/configuration/http.rb +74 -0
- data/lib/datadog/tracing/configuration/settings.rb +136 -99
- data/lib/datadog/tracing/contrib/action_cable/configuration/settings.rb +10 -6
- data/lib/datadog/tracing/contrib/action_cable/ext.rb +21 -18
- data/lib/datadog/tracing/contrib/action_mailer/configuration/settings.rb +10 -6
- data/lib/datadog/tracing/contrib/action_mailer/events/deliver.rb +1 -1
- data/lib/datadog/tracing/contrib/action_mailer/ext.rb +21 -18
- data/lib/datadog/tracing/contrib/action_pack/configuration/settings.rb +10 -7
- data/lib/datadog/tracing/contrib/action_pack/ext.rb +11 -8
- data/lib/datadog/tracing/contrib/action_view/configuration/settings.rb +10 -6
- data/lib/datadog/tracing/contrib/action_view/ext.rb +13 -10
- data/lib/datadog/tracing/contrib/active_job/configuration/settings.rb +14 -7
- data/lib/datadog/tracing/contrib/active_job/ext.rb +26 -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 +10 -6
- data/lib/datadog/tracing/contrib/active_model_serializers/ext.rb +13 -10
- data/lib/datadog/tracing/contrib/active_record/configuration/resolver.rb +29 -15
- data/lib/datadog/tracing/contrib/active_record/configuration/settings.rb +10 -7
- data/lib/datadog/tracing/contrib/active_record/events/sql.rb +2 -6
- data/lib/datadog/tracing/contrib/active_record/ext.rb +18 -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 +10 -7
- data/lib/datadog/tracing/contrib/active_support/ext.rb +19 -16
- data/lib/datadog/tracing/contrib/analytics.rb +0 -1
- data/lib/datadog/tracing/contrib/aws/configuration/settings.rb +15 -7
- data/lib/datadog/tracing/contrib/aws/ext.rb +38 -24
- data/lib/datadog/tracing/contrib/aws/instrumentation.rb +16 -5
- data/lib/datadog/tracing/contrib/concurrent_ruby/async_patch.rb +20 -0
- 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 +19 -2
- data/lib/datadog/tracing/contrib/concurrent_ruby/promises_future_patch.rb +22 -0
- data/lib/datadog/tracing/contrib/configurable.rb +1 -1
- data/lib/datadog/tracing/contrib/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/dalli/configuration/settings.rb +21 -7
- data/lib/datadog/tracing/contrib/dalli/ext.rb +27 -11
- data/lib/datadog/tracing/contrib/dalli/instrumentation.rb +17 -8
- data/lib/datadog/tracing/contrib/delayed_job/configuration/settings.rb +14 -7
- data/lib/datadog/tracing/contrib/delayed_job/ext.rb +17 -14
- data/lib/datadog/tracing/contrib/elasticsearch/configuration/settings.rb +15 -7
- data/lib/datadog/tracing/contrib/elasticsearch/ext.rb +22 -15
- data/lib/datadog/tracing/contrib/elasticsearch/patcher.rb +104 -99
- data/lib/datadog/tracing/contrib/ethon/configuration/settings.rb +17 -9
- data/lib/datadog/tracing/contrib/ethon/easy_patch.rb +48 -3
- data/lib/datadog/tracing/contrib/ethon/ext.rb +20 -11
- data/lib/datadog/tracing/contrib/ethon/multi_patch.rb +6 -3
- data/lib/datadog/tracing/contrib/excon/configuration/settings.rb +20 -10
- data/lib/datadog/tracing/contrib/excon/ext.rb +17 -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 +38 -2
- data/lib/datadog/tracing/contrib/faraday/configuration/settings.rb +27 -10
- data/lib/datadog/tracing/contrib/faraday/ext.rb +17 -8
- data/lib/datadog/tracing/contrib/faraday/middleware.rb +22 -6
- data/lib/datadog/tracing/contrib/grape/configuration/settings.rb +9 -6
- data/lib/datadog/tracing/contrib/grape/ext.rb +17 -14
- data/lib/datadog/tracing/contrib/graphql/configuration/settings.rb +9 -6
- data/lib/datadog/tracing/contrib/graphql/ext.rb +8 -5
- data/lib/datadog/tracing/contrib/grpc/configuration/settings.rb +40 -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 +17 -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 +34 -11
- data/lib/datadog/tracing/contrib/http/distributed/fetcher.rb +2 -2
- data/lib/datadog/tracing/contrib/http/ext.rb +17 -9
- data/lib/datadog/tracing/contrib/http/instrumentation.rb +27 -7
- data/lib/datadog/tracing/contrib/httpclient/configuration/settings.rb +34 -11
- data/lib/datadog/tracing/contrib/httpclient/ext.rb +18 -9
- data/lib/datadog/tracing/contrib/httpclient/instrumentation.rb +22 -5
- data/lib/datadog/tracing/contrib/httprb/configuration/settings.rb +34 -11
- data/lib/datadog/tracing/contrib/httprb/ext.rb +17 -9
- data/lib/datadog/tracing/contrib/httprb/instrumentation.rb +22 -5
- data/lib/datadog/tracing/contrib/kafka/configuration/settings.rb +10 -6
- data/lib/datadog/tracing/contrib/kafka/ext.rb +43 -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 +15 -7
- data/lib/datadog/tracing/contrib/mongodb/ext.rb +21 -16
- data/lib/datadog/tracing/contrib/mongodb/subscribers.rb +16 -5
- data/lib/datadog/tracing/contrib/mysql2/configuration/settings.rb +22 -14
- data/lib/datadog/tracing/contrib/mysql2/ext.rb +16 -10
- data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +22 -7
- data/lib/datadog/tracing/contrib/opensearch/configuration/settings.rb +53 -0
- data/lib/datadog/tracing/contrib/opensearch/ext.rb +38 -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 +23 -14
- data/lib/datadog/tracing/contrib/pg/ext.rb +23 -19
- data/lib/datadog/tracing/contrib/pg/instrumentation.rb +49 -9
- data/lib/datadog/tracing/contrib/presto/configuration/settings.rb +15 -7
- data/lib/datadog/tracing/contrib/presto/ext.rb +26 -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 +13 -8
- data/lib/datadog/tracing/contrib/qless/ext.rb +15 -12
- data/lib/datadog/tracing/contrib/que/configuration/settings.rb +22 -12
- data/lib/datadog/tracing/contrib/que/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/racecar/configuration/settings.rb +10 -7
- data/lib/datadog/tracing/contrib/racecar/event.rb +5 -5
- data/lib/datadog/tracing/contrib/racecar/ext.rb +21 -18
- data/lib/datadog/tracing/contrib/rack/configuration/settings.rb +17 -12
- data/lib/datadog/tracing/contrib/rack/ext.rb +19 -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 +16 -50
- data/lib/datadog/tracing/contrib/rails/auto_instrument_railtie.rb +0 -2
- data/lib/datadog/tracing/contrib/rails/configuration/settings.rb +20 -15
- data/lib/datadog/tracing/contrib/rails/ext.rb +8 -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 +14 -10
- data/lib/datadog/tracing/contrib/rake/ext.rb +15 -12
- data/lib/datadog/tracing/contrib/redis/configuration/settings.rb +18 -9
- data/lib/datadog/tracing/contrib/redis/ext.rb +23 -15
- data/lib/datadog/tracing/contrib/redis/instrumentation.rb +5 -40
- data/lib/datadog/tracing/contrib/redis/patcher.rb +34 -21
- 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 +14 -7
- data/lib/datadog/tracing/contrib/resque/ext.rb +10 -7
- data/lib/datadog/tracing/contrib/rest_client/configuration/settings.rb +17 -9
- data/lib/datadog/tracing/contrib/rest_client/ext.rb +16 -8
- data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +25 -5
- data/lib/datadog/tracing/contrib/roda/configuration/settings.rb +10 -6
- data/lib/datadog/tracing/contrib/roda/ext.rb +1 -0
- 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 +10 -6
- data/lib/datadog/tracing/contrib/sequel/ext.rb +11 -8
- data/lib/datadog/tracing/contrib/sequel/utils.rb +7 -7
- data/lib/datadog/tracing/contrib/shoryuken/configuration/settings.rb +15 -8
- data/lib/datadog/tracing/contrib/shoryuken/ext.rb +15 -12
- data/lib/datadog/tracing/contrib/sidekiq/configuration/settings.rb +19 -11
- data/lib/datadog/tracing/contrib/sidekiq/ext.rb +33 -30
- data/lib/datadog/tracing/contrib/sinatra/configuration/settings.rb +12 -9
- data/lib/datadog/tracing/contrib/sinatra/env.rb +0 -17
- data/lib/datadog/tracing/contrib/sinatra/ext.rb +22 -19
- data/lib/datadog/tracing/contrib/sinatra/tracer_middleware.rb +3 -14
- data/lib/datadog/tracing/contrib/sneakers/configuration/settings.rb +15 -8
- data/lib/datadog/tracing/contrib/sneakers/ext.rb +2 -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 +10 -6
- data/lib/datadog/tracing/contrib/stripe/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/sucker_punch/configuration/settings.rb +10 -6
- data/lib/datadog/tracing/contrib/sucker_punch/ext.rb +16 -13
- data/lib/datadog/tracing/contrib/trilogy/configuration/settings.rb +58 -0
- data/lib/datadog/tracing/contrib/trilogy/ext.rb +27 -0
- data/lib/datadog/tracing/contrib/trilogy/instrumentation.rb +94 -0
- data/lib/datadog/tracing/contrib/trilogy/integration.rb +43 -0
- data/lib/datadog/{ci/contrib/cucumber → tracing/contrib/trilogy}/patcher.rb +10 -6
- 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 +2 -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/matcher.rb +23 -3
- data/lib/datadog/tracing/sampling/rule.rb +7 -2
- data/lib/datadog/tracing/sampling/rule_sampler.rb +31 -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 +17 -5
- 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 +125 -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 +240 -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/datadog/tracing.rb +8 -2
- data/lib/ddtrace/transport/ext.rb +22 -14
- data/lib/ddtrace/version.rb +9 -12
- data/lib/ddtrace.rb +1 -1
- metadata +157 -139
- data/ext/ddtrace_profiling_native_extension/libdatadog_helpers.h +0 -25
- data/ext/ddtrace_profiling_native_extension/ruby_helpers.c +0 -110
- data/ext/ddtrace_profiling_native_extension/stack_recorder.c +0 -591
- data/ext/ddtrace_profiling_native_extension/stack_recorder.h +0 -14
- data/ext/ddtrace_profiling_native_extension/time_helpers.c +0 -17
- data/ext/ddtrace_profiling_native_extension/time_helpers.h +0 -10
- 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/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/telemetry/collector.rb +0 -231
- data/lib/datadog/core/telemetry/v1/app_event.rb +0 -52
- data/lib/datadog/core/telemetry/v1/application.rb +0 -92
- data/lib/datadog/core/telemetry/v1/configuration.rb +0 -25
- data/lib/datadog/core/telemetry/v1/dependency.rb +0 -43
- data/lib/datadog/core/telemetry/v1/host.rb +0 -59
- data/lib/datadog/core/telemetry/v1/integration.rb +0 -64
- data/lib/datadog/core/telemetry/v1/product.rb +0 -36
- data/lib/datadog/core/telemetry/v1/telemetry_request.rb +0 -106
- 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
- /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/collectors_idle_sampling_helper.h +0 -0
- /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/setup_signal_handler.c +0 -0
- /data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/setup_signal_handler.h +0 -0
|
@@ -1,18 +1,37 @@
|
|
|
1
1
|
# This file is used to load the profiling native extension. It works in two steps:
|
|
2
2
|
#
|
|
3
|
-
# 1. Load the
|
|
4
|
-
# a special way that avoids exposing native-level code symbols. See `
|
|
3
|
+
# 1. Load the datadog_profiling_loader extension. This extension will be used to load the actual extension, but in
|
|
4
|
+
# a special way that avoids exposing native-level code symbols. See `datadog_profiling_loader.c` for more details.
|
|
5
5
|
#
|
|
6
|
-
# 2. Use the Datadog::Profiling::Loader exposed by the
|
|
6
|
+
# 2. Use the Datadog::Profiling::Loader exposed by the datadog_profiling_loader extension to load the actual
|
|
7
7
|
# profiling native extension.
|
|
8
8
|
#
|
|
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 "datadog_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
|
|
19
|
+
|
|
20
|
+
extension_name = "datadog_profiling_native_extension.#{RUBY_VERSION}_#{RUBY_PLATFORM}"
|
|
21
|
+
file_name = "#{extension_name}.#{RbConfig::CONFIG['DLEXT']}"
|
|
22
|
+
full_file_path = "#{__dir__}/../../#{file_name}"
|
|
23
|
+
|
|
24
|
+
unless File.exist?(full_file_path)
|
|
25
|
+
extension_dir = Gem.loaded_specs['ddtrace'].extension_dir
|
|
26
|
+
candidate_path = "#{extension_dir}/#{file_name}"
|
|
27
|
+
if File.exist?(candidate_path)
|
|
28
|
+
full_file_path = candidate_path
|
|
29
|
+
else # rubocop:disable Style/EmptyElse
|
|
30
|
+
# We found none of the files. This is unexpected. Let's go ahead anyway, the error is going to be reported further
|
|
31
|
+
# down anyway.
|
|
32
|
+
end
|
|
33
|
+
end
|
|
13
34
|
|
|
14
|
-
extension_name = "ddtrace_profiling_native_extension.#{RUBY_VERSION}_#{RUBY_PLATFORM}"
|
|
15
|
-
full_file_path = "#{__dir__}/../../#{extension_name}.#{RbConfig::CONFIG['DLEXT']}"
|
|
16
35
|
init_function_name = "Init_#{extension_name.split('.').first}"
|
|
17
36
|
|
|
18
37
|
status, result = Datadog::Profiling::Loader._native_load(full_file_path, init_function_name)
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module Datadog
|
|
4
4
|
module Profiling
|
|
5
5
|
# This module contains classes and methods which are implemented using native code in the
|
|
6
|
-
# ext/
|
|
6
|
+
# ext/datadog_profiling_native_extension folder, as well as some Ruby-level utilities that don't make sense to
|
|
7
7
|
# write using C
|
|
8
8
|
module NativeExtension
|
|
9
9
|
private_class_method def self.working?
|
|
@@ -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
|
|
@@ -5,12 +5,11 @@ require_relative '../core/workers/polling'
|
|
|
5
5
|
|
|
6
6
|
module Datadog
|
|
7
7
|
module Profiling
|
|
8
|
-
# Periodically (every
|
|
8
|
+
# Periodically (every interval, 60 seconds by default) takes a profile from the `Exporter` and reports it using the
|
|
9
9
|
# configured transport. Runs on its own background thread.
|
|
10
10
|
class Scheduler < Core::Worker
|
|
11
11
|
include Core::Workers::Polling
|
|
12
12
|
|
|
13
|
-
DEFAULT_INTERVAL_SECONDS = 60
|
|
14
13
|
MINIMUM_INTERVAL_SECONDS = 0
|
|
15
14
|
|
|
16
15
|
# We sleep for at most this duration seconds before reporting data to avoid multi-process applications all
|
|
@@ -28,8 +27,7 @@ module Datadog
|
|
|
28
27
|
def initialize(
|
|
29
28
|
exporter:,
|
|
30
29
|
transport:,
|
|
31
|
-
fork_policy: Core::Workers::Async::Thread::FORK_POLICY_RESTART, # Restart in forks by default
|
|
32
|
-
interval: DEFAULT_INTERVAL_SECONDS,
|
|
30
|
+
interval:, fork_policy: Core::Workers::Async::Thread::FORK_POLICY_RESTART, # Restart in forks by default, # seconds
|
|
33
31
|
enabled: true
|
|
34
32
|
)
|
|
35
33
|
@exporter = exporter
|
|
@@ -45,20 +43,27 @@ module Datadog
|
|
|
45
43
|
self.enabled = enabled
|
|
46
44
|
end
|
|
47
45
|
|
|
48
|
-
def start
|
|
49
|
-
perform
|
|
46
|
+
def start(on_failure_proc: nil)
|
|
47
|
+
perform(on_failure_proc)
|
|
50
48
|
end
|
|
51
49
|
|
|
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
|
-
|
|
50
|
+
def perform(on_failure_proc)
|
|
59
51
|
begin
|
|
52
|
+
# A profiling flush may be called while the VM is shutting down, to report the last profile. When we do so,
|
|
53
|
+
# we impose a strict timeout. This means this last profile may or may not be sent, depending on if the flush can
|
|
54
|
+
# successfully finish in the strict timeout.
|
|
55
|
+
# This can be somewhat confusing (why did it not get reported?), so let's at least log what happened.
|
|
56
|
+
interrupted = true
|
|
57
|
+
|
|
60
58
|
flush_and_wait
|
|
61
59
|
interrupted = false
|
|
60
|
+
rescue Exception => e # rubocop:disable Lint/RescueException
|
|
61
|
+
Datadog.logger.warn(
|
|
62
|
+
'Profiling::Scheduler thread error. ' \
|
|
63
|
+
"Cause: #{e.class.name} #{e.message} Location: #{Array(e.backtrace).first}"
|
|
64
|
+
)
|
|
65
|
+
on_failure_proc&.call
|
|
66
|
+
raise
|
|
62
67
|
ensure
|
|
63
68
|
Datadog.logger.debug('#flush was interrupted or failed before it could complete') if interrupted
|
|
64
69
|
end
|
|
@@ -108,8 +113,8 @@ module Datadog
|
|
|
108
113
|
#
|
|
109
114
|
# During PR review (https://github.com/DataDog/dd-trace-rb/pull/1807) we discussed the possible alternative of
|
|
110
115
|
# just sleeping before starting the scheduler loop. We ended up not going with that option to avoid the first
|
|
111
|
-
# profile containing up to
|
|
112
|
-
# usual
|
|
116
|
+
# profile containing up to interval + DEFAULT_FLUSH_JITTER_MAXIMUM_SECONDS instead of the
|
|
117
|
+
# usual interval seconds.
|
|
113
118
|
if run_loop?
|
|
114
119
|
jitter_seconds = rand * DEFAULT_FLUSH_JITTER_MAXIMUM_SECONDS # floating point number between (0.0...maximum)
|
|
115
120
|
sleep(jitter_seconds)
|
|
@@ -4,7 +4,10 @@ module Datadog
|
|
|
4
4
|
# Note that `record_sample` is only accessible from native code.
|
|
5
5
|
# Methods prefixed with _native_ are implemented in `stack_recorder.c`
|
|
6
6
|
class StackRecorder
|
|
7
|
-
def initialize(
|
|
7
|
+
def initialize(
|
|
8
|
+
cpu_time_enabled:, alloc_samples_enabled:, heap_samples_enabled:, heap_size_enabled:,
|
|
9
|
+
heap_sample_every:, timeline_enabled:
|
|
10
|
+
)
|
|
8
11
|
# This mutex works in addition to the fancy C-level mutexes we have in the native side (see the docs there).
|
|
9
12
|
# It prevents multiple Ruby threads calling serialize at the same time -- something like
|
|
10
13
|
# `10.times { Thread.new { stack_recorder.serialize } }`.
|
|
@@ -13,18 +16,26 @@ module Datadog
|
|
|
13
16
|
# accidentally happening.
|
|
14
17
|
@no_concurrent_synchronize_mutex = Mutex.new
|
|
15
18
|
|
|
16
|
-
self.class._native_initialize(
|
|
19
|
+
self.class._native_initialize(
|
|
20
|
+
self,
|
|
21
|
+
cpu_time_enabled,
|
|
22
|
+
alloc_samples_enabled,
|
|
23
|
+
heap_samples_enabled,
|
|
24
|
+
heap_size_enabled,
|
|
25
|
+
heap_sample_every,
|
|
26
|
+
timeline_enabled,
|
|
27
|
+
)
|
|
17
28
|
end
|
|
18
29
|
|
|
19
30
|
def serialize
|
|
20
31
|
status, result = @no_concurrent_synchronize_mutex.synchronize { self.class._native_serialize(self) }
|
|
21
32
|
|
|
22
33
|
if status == :ok
|
|
23
|
-
start, finish, encoded_pprof = result
|
|
34
|
+
start, finish, encoded_pprof, profile_stats = result
|
|
24
35
|
|
|
25
36
|
Datadog.logger.debug { "Encoded profile covering #{start.iso8601} to #{finish.iso8601}" }
|
|
26
37
|
|
|
27
|
-
[start, finish, encoded_pprof]
|
|
38
|
+
[start, finish, encoded_pprof, profile_stats]
|
|
28
39
|
else
|
|
29
40
|
error_message = result
|
|
30
41
|
|
|
@@ -51,6 +62,10 @@ module Datadog
|
|
|
51
62
|
def reset_after_fork
|
|
52
63
|
self.class._native_reset_after_fork(self)
|
|
53
64
|
end
|
|
65
|
+
|
|
66
|
+
def stats
|
|
67
|
+
self.class._native_stats(self)
|
|
68
|
+
end
|
|
54
69
|
end
|
|
55
70
|
end
|
|
56
71
|
end
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative '../core/utils'
|
|
4
|
+
require_relative '../core/environment/git'
|
|
4
5
|
|
|
5
6
|
module Datadog
|
|
6
7
|
module Profiling
|
|
@@ -23,6 +24,8 @@ module Datadog
|
|
|
23
24
|
runtime_id: Core::Environment::Identity.id,
|
|
24
25
|
runtime_platform: Core::Environment::Identity.lang_platform,
|
|
25
26
|
runtime_version: Core::Environment::Identity.lang_version,
|
|
27
|
+
git_repository_url: Core::Environment::Git.git_repository_url,
|
|
28
|
+
git_commit_sha: Core::Environment::Git.git_commit_sha,
|
|
26
29
|
# User-provided tags
|
|
27
30
|
user_tags: settings.tags
|
|
28
31
|
)
|
|
@@ -42,6 +45,8 @@ module Datadog
|
|
|
42
45
|
tags[FORM_FIELD_TAG_ENV] = env if env
|
|
43
46
|
tags[FORM_FIELD_TAG_SERVICE] = service if service
|
|
44
47
|
tags[FORM_FIELD_TAG_VERSION] = version if version
|
|
48
|
+
tags[TAG_GIT_REPOSITORY_URL] = git_repository_url if git_repository_url
|
|
49
|
+
tags[TAG_GIT_COMMIT_SHA] = git_commit_sha if git_commit_sha
|
|
45
50
|
|
|
46
51
|
# Make sure everything is an utf-8 string, to avoid encoding issues in native code/libddprof/further downstream
|
|
47
52
|
user_tags.merge(tags).map do |key, value|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module Datadog
|
|
2
2
|
module Profiling
|
|
3
3
|
module Tasks
|
|
4
|
-
# Wraps command with Datadog
|
|
4
|
+
# Wraps command with Datadog profiling
|
|
5
5
|
class Exec
|
|
6
6
|
attr_reader :args
|
|
7
7
|
|
|
@@ -36,10 +36,10 @@ module Datadog
|
|
|
36
36
|
def exec_with_error_handling(args)
|
|
37
37
|
Kernel.exec(*args)
|
|
38
38
|
rescue Errno::ENOENT => e
|
|
39
|
-
Kernel.warn "
|
|
39
|
+
Kernel.warn "ddprofrb exec failed: #{e.class.name} #{e.message} (command was '#{args.join(' ')}')"
|
|
40
40
|
Kernel.exit 127
|
|
41
41
|
rescue Errno::EACCES, Errno::ENOEXEC => e
|
|
42
|
-
Kernel.warn "
|
|
42
|
+
Kernel.warn "ddprofrb exec failed: #{e.class.name} #{e.message} (command was '#{args.join(' ')}')"
|
|
43
43
|
Kernel.exit 126
|
|
44
44
|
end
|
|
45
45
|
end
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
module Datadog
|
|
2
2
|
module Profiling
|
|
3
3
|
module Tasks
|
|
4
|
-
# Prints help message for usage of `
|
|
4
|
+
# Prints help message for usage of `ddprofrb`
|
|
5
5
|
class Help
|
|
6
6
|
def run
|
|
7
7
|
puts %(
|
|
8
|
-
Usage:
|
|
9
|
-
exec [command]: Executes command with
|
|
8
|
+
Usage: ddprofrb [command] [arguments]
|
|
9
|
+
exec [command]: Executes command with profiling preloaded.
|
|
10
10
|
help: Prints this help message.
|
|
11
11
|
)
|
|
12
12
|
end
|
data/lib/datadog/profiling.rb
CHANGED
|
@@ -5,22 +5,15 @@ require_relative 'core/utils/only_once'
|
|
|
5
5
|
module Datadog
|
|
6
6
|
# Datadog Continuous Profiler implementation: https://docs.datadoghq.com/profiler/
|
|
7
7
|
module Profiling
|
|
8
|
-
GOOGLE_PROTOBUF_MINIMUM_VERSION = Gem::Version.new('3.0')
|
|
9
|
-
private_constant :GOOGLE_PROTOBUF_MINIMUM_VERSION
|
|
10
|
-
|
|
11
8
|
def self.supported?
|
|
12
9
|
unsupported_reason.nil?
|
|
13
10
|
end
|
|
14
11
|
|
|
15
12
|
def self.unsupported_reason
|
|
16
13
|
# NOTE: Only the first matching reason is returned, so try to keep a nice order on reasons -- e.g. tell users
|
|
17
|
-
# first that they can't use this on JRuby before telling them that
|
|
14
|
+
# first that they can't use this on JRuby before telling them that something else failed
|
|
18
15
|
|
|
19
|
-
native_library_compilation_skipped? ||
|
|
20
|
-
native_library_failed_to_load? ||
|
|
21
|
-
protobuf_gem_unavailable? ||
|
|
22
|
-
protobuf_version_unsupported? ||
|
|
23
|
-
protobuf_failed_to_load?
|
|
16
|
+
native_library_compilation_skipped? || native_library_failed_to_load?
|
|
24
17
|
end
|
|
25
18
|
|
|
26
19
|
# Starts the profiler, if the profiler is supported by in
|
|
@@ -53,9 +46,7 @@ module Datadog
|
|
|
53
46
|
#
|
|
54
47
|
# Note 2: All fibers in the same thread will share the same counter values.
|
|
55
48
|
#
|
|
56
|
-
# Only available when the profiler is running,
|
|
57
|
-
# features are not disabled via configuration.
|
|
58
|
-
# For instructions on enabling CPU Profiling 2.0 see the ddtrace release notes.
|
|
49
|
+
# Only available when the profiler is running, and allocation-related features are not disabled via configuration.
|
|
59
50
|
#
|
|
60
51
|
# @return [Integer] number of allocations observed in the current thread.
|
|
61
52
|
# @return [nil] when not available.
|
|
@@ -66,8 +57,25 @@ module Datadog
|
|
|
66
57
|
nil
|
|
67
58
|
end
|
|
68
59
|
|
|
60
|
+
def self.enabled?
|
|
61
|
+
profiler = Datadog.send(:components).profiler
|
|
62
|
+
# Use .send(...) to avoid exposing the attr_reader as an API to the outside
|
|
63
|
+
!!(profiler.send(:scheduler).running? if profiler)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def self.wait_until_running(timeout_seconds: 5)
|
|
67
|
+
profiler = Datadog.send(:components).profiler
|
|
68
|
+
if profiler
|
|
69
|
+
# Use .send(...) to avoid exposing the attr_reader as an API to the outside
|
|
70
|
+
worker = profiler.send(:worker)
|
|
71
|
+
worker.wait_until_running(timeout_seconds: timeout_seconds)
|
|
72
|
+
else
|
|
73
|
+
raise 'Profiler not enabled or available'
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
69
77
|
private_class_method def self.replace_noop_allocation_count
|
|
70
|
-
def self.allocation_count # rubocop:disable Lint/
|
|
78
|
+
def self.allocation_count # rubocop:disable Lint/NestedMethodDefinition (On purpose!)
|
|
71
79
|
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_allocation_count
|
|
72
80
|
end
|
|
73
81
|
end
|
|
@@ -80,7 +88,7 @@ module Datadog
|
|
|
80
88
|
|
|
81
89
|
private_class_method def self.try_reading_skipped_reason_file(file_api = File)
|
|
82
90
|
# This file, if it exists, is recorded by extconf.rb during compilation of the native extension
|
|
83
|
-
skipped_reason_file = "#{__dir__}/../../ext/
|
|
91
|
+
skipped_reason_file = "#{__dir__}/../../ext/datadog_profiling_native_extension/skipped_reason.txt"
|
|
84
92
|
|
|
85
93
|
begin
|
|
86
94
|
return unless file_api.exist?(skipped_reason_file)
|
|
@@ -92,66 +100,6 @@ module Datadog
|
|
|
92
100
|
end
|
|
93
101
|
end
|
|
94
102
|
|
|
95
|
-
private_class_method def self.protobuf_gem_unavailable?
|
|
96
|
-
# NOTE: On environments where protobuf is already loaded, we skip the check. This allows us to support environments
|
|
97
|
-
# where no Gem.loaded_version is NOT available but customers are able to load protobuf; see for instance
|
|
98
|
-
# https://github.com/teamcapybara/capybara/commit/caf3bcd7664f4f2691d0ca9ef3be9a2a954fecfb
|
|
99
|
-
if !protobuf_already_loaded? && Gem.loaded_specs['google-protobuf'].nil?
|
|
100
|
-
"Missing google-protobuf dependency; please add `gem 'google-protobuf', '~> 3.0'` to your Gemfile or gems.rb file"
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
private_class_method def self.protobuf_version_unsupported?
|
|
105
|
-
# See above for why we skip the check when protobuf is already loaded; note that when protobuf was already loaded
|
|
106
|
-
# we skip the version check to avoid the call to Gem.loaded_specs. Unfortunately, protobuf does not seem to
|
|
107
|
-
# expose the gem version constant elsewhere, so in that setup we are not able to check the version.
|
|
108
|
-
if !protobuf_already_loaded? && Gem.loaded_specs['google-protobuf'].version < GOOGLE_PROTOBUF_MINIMUM_VERSION
|
|
109
|
-
'Your google-protobuf is too old; ensure that you have google-protobuf >= 3.0 by ' \
|
|
110
|
-
"adding `gem 'google-protobuf', '~> 3.0'` to your Gemfile or gems.rb file"
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
private_class_method def self.protobuf_already_loaded?
|
|
115
|
-
defined?(::Google::Protobuf) && !defined?(::Protobuf)
|
|
116
|
-
!!(defined?(::Google::Protobuf) && !defined?(::Protobuf))
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
private_class_method def self.protobuf_failed_to_load?
|
|
120
|
-
unless protobuf_loaded_successfully?
|
|
121
|
-
'There was an error loading the google-protobuf library; see previous warning message for details'
|
|
122
|
-
end
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
# The `google-protobuf` gem depends on a native component, and its creators helpfully tried to provide precompiled
|
|
126
|
-
# versions of this extension on rubygems.org.
|
|
127
|
-
#
|
|
128
|
-
# Unfortunately, for a long time, the supported Ruby versions metadata on these precompiled versions of the extension
|
|
129
|
-
# was not correctly set. (This is fixed in newer versions -- but not all Ruby versions we want to support can use
|
|
130
|
-
# these.)
|
|
131
|
-
#
|
|
132
|
-
# Thus, the gem can still be installed, but can be in a broken state. To avoid breaking customer applications, we
|
|
133
|
-
# use this helper to load it and gracefully handle failures.
|
|
134
|
-
private_class_method def self.protobuf_loaded_successfully?
|
|
135
|
-
return @protobuf_loaded if defined?(@protobuf_loaded)
|
|
136
|
-
|
|
137
|
-
begin
|
|
138
|
-
require 'google/protobuf'
|
|
139
|
-
@protobuf_loaded = true
|
|
140
|
-
rescue LoadError => e
|
|
141
|
-
# NOTE: We use Kernel#warn here because this code gets run BEFORE Datadog.logger is actually set up.
|
|
142
|
-
# In the future it'd be nice to shuffle the logger startup to happen first to avoid this special case.
|
|
143
|
-
Kernel.warn(
|
|
144
|
-
'[ddtrace] Error while loading google-protobuf gem. ' \
|
|
145
|
-
"Cause: '#{e.class.name} #{e.message}' Location: '#{Array(e.backtrace).first}'. " \
|
|
146
|
-
'This can happen when google-protobuf is missing its native components. ' \
|
|
147
|
-
'To fix this, try removing and reinstalling the gem, forcing it to recompile the components: ' \
|
|
148
|
-
'`gem uninstall google-protobuf -a; BUNDLE_FORCE_RUBY_PLATFORM=true bundle install`. ' \
|
|
149
|
-
'If the error persists, please contact Datadog support at <https://docs.datadoghq.com/help/>.'
|
|
150
|
-
)
|
|
151
|
-
@protobuf_loaded = false
|
|
152
|
-
end
|
|
153
|
-
end
|
|
154
|
-
|
|
155
103
|
private_class_method def self.native_library_failed_to_load?
|
|
156
104
|
success, exception = try_loading_native_library
|
|
157
105
|
|
|
@@ -178,27 +126,28 @@ module Datadog
|
|
|
178
126
|
end
|
|
179
127
|
end
|
|
180
128
|
|
|
129
|
+
# All requires for the profiler should be directly added here; and everything should be loaded eagerly.
|
|
130
|
+
# (Currently there's a leftovers that need to be cleaned up, but we should avoid other exceptions.)
|
|
131
|
+
#
|
|
132
|
+
# All of the profiler should be loaded and ready to go when this method returns `true`.
|
|
181
133
|
private_class_method def self.load_profiling
|
|
182
134
|
return false unless supported?
|
|
183
135
|
|
|
184
136
|
require_relative 'profiling/ext/forking'
|
|
137
|
+
require_relative 'profiling/collectors/info'
|
|
185
138
|
require_relative 'profiling/collectors/code_provenance'
|
|
186
139
|
require_relative 'profiling/collectors/cpu_and_wall_time_worker'
|
|
187
140
|
require_relative 'profiling/collectors/dynamic_sampling_rate'
|
|
188
141
|
require_relative 'profiling/collectors/idle_sampling_helper'
|
|
189
|
-
require_relative 'profiling/collectors/old_stack'
|
|
190
142
|
require_relative 'profiling/collectors/stack'
|
|
191
143
|
require_relative 'profiling/collectors/thread_context'
|
|
192
144
|
require_relative 'profiling/stack_recorder'
|
|
193
|
-
require_relative 'profiling/old_recorder'
|
|
194
145
|
require_relative 'profiling/exporter'
|
|
146
|
+
require_relative 'profiling/flush'
|
|
195
147
|
require_relative 'profiling/scheduler'
|
|
196
148
|
require_relative 'profiling/tasks/setup'
|
|
197
149
|
require_relative 'profiling/profiler'
|
|
198
150
|
require_relative 'profiling/native_extension'
|
|
199
|
-
require_relative 'profiling/trace_identifiers/helper'
|
|
200
|
-
# This file is loaded in Profiling::Component#load_pprof_support; see notes there for why
|
|
201
|
-
# require_relative 'profiling/pprof/pprof_pb'
|
|
202
151
|
require_relative 'profiling/tag_builder'
|
|
203
152
|
require_relative 'profiling/http_transport'
|
|
204
153
|
|