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
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <datadog/profiling.h>
|
|
4
|
+
#include <ruby.h>
|
|
5
|
+
|
|
6
|
+
// A heap recorder keeps track of a collection of live heap objects.
|
|
7
|
+
//
|
|
8
|
+
// All allocations observed by this recorder for which a corresponding free was
|
|
9
|
+
// not yet observed are deemed as alive and can be iterated on to produce a
|
|
10
|
+
// live heap profile.
|
|
11
|
+
//
|
|
12
|
+
// NOTE: All public APIs of heap_recorder support receiving a NULL heap_recorder
|
|
13
|
+
// in which case the behaviour will be a noop.
|
|
14
|
+
//
|
|
15
|
+
// WARN: Unless otherwise stated the heap recorder APIs assume calls are done
|
|
16
|
+
// under the GVL.
|
|
17
|
+
typedef struct heap_recorder heap_recorder;
|
|
18
|
+
|
|
19
|
+
// Extra data associated with each live object being tracked.
|
|
20
|
+
typedef struct live_object_data {
|
|
21
|
+
// The weight of this object from a sampling perspective.
|
|
22
|
+
//
|
|
23
|
+
// A notion of weight is preserved for each tracked object to allow for an approximate
|
|
24
|
+
// extrapolation to an unsampled view.
|
|
25
|
+
//
|
|
26
|
+
// Example: If we were sampling every 50 objects, then each sampled object
|
|
27
|
+
// could be seen as being representative of 50 objects.
|
|
28
|
+
unsigned int weight;
|
|
29
|
+
|
|
30
|
+
// Size of this object in memory.
|
|
31
|
+
// NOTE: This only gets updated during heap_recorder_prepare_iteration and only
|
|
32
|
+
// for those objects that meet the minimum iteration age requirements.
|
|
33
|
+
size_t size;
|
|
34
|
+
|
|
35
|
+
// The class of the object that we're tracking.
|
|
36
|
+
// NOTE: This is optional and will be set to NULL if not set.
|
|
37
|
+
char* class;
|
|
38
|
+
|
|
39
|
+
// The GC allocation gen in which we saw this object being allocated.
|
|
40
|
+
//
|
|
41
|
+
// This enables us to calculate the age of this object in terms of GC executions.
|
|
42
|
+
size_t alloc_gen;
|
|
43
|
+
|
|
44
|
+
// The age of this object in terms of GC generations.
|
|
45
|
+
// NOTE: This only gets updated during heap_recorder_prepare_iteration
|
|
46
|
+
size_t gen_age;
|
|
47
|
+
|
|
48
|
+
// Whether this object was previously seen as being frozen. If this is the case,
|
|
49
|
+
// we'll skip any further size updates since frozen objects are supposed to be
|
|
50
|
+
// immutable.
|
|
51
|
+
bool is_frozen;
|
|
52
|
+
} live_object_data;
|
|
53
|
+
|
|
54
|
+
// Data that is made available to iterators of heap recorder data for each live object
|
|
55
|
+
// tracked therein.
|
|
56
|
+
typedef struct {
|
|
57
|
+
ddog_prof_Slice_Location locations;
|
|
58
|
+
live_object_data object_data;
|
|
59
|
+
} heap_recorder_iteration_data;
|
|
60
|
+
|
|
61
|
+
// Initialize a new heap recorder.
|
|
62
|
+
heap_recorder* heap_recorder_new(void);
|
|
63
|
+
|
|
64
|
+
// Free a previously initialized heap recorder.
|
|
65
|
+
void heap_recorder_free(heap_recorder *heap_recorder);
|
|
66
|
+
|
|
67
|
+
// Sets whether this heap recorder should keep track of sizes or not.
|
|
68
|
+
//
|
|
69
|
+
// If set to true, the heap recorder will attempt to determine the approximate sizes of
|
|
70
|
+
// tracked objects and wield them during iteration.
|
|
71
|
+
// If set to false, sizes returned during iteration should not be used/relied on (they
|
|
72
|
+
// may be 0 or the last determined size before disabling the tracking of sizes).
|
|
73
|
+
//
|
|
74
|
+
// NOTE: Default is true, i.e., it will attempt to determine approximate sizes of tracked
|
|
75
|
+
// objects.
|
|
76
|
+
void heap_recorder_set_size_enabled(heap_recorder *heap_recorder, bool size_enabled);
|
|
77
|
+
|
|
78
|
+
// Set sample rate used by this heap recorder.
|
|
79
|
+
//
|
|
80
|
+
// Controls how many recordings will be ignored before committing a heap allocation and
|
|
81
|
+
// the weight of the committed heap allocation.
|
|
82
|
+
//
|
|
83
|
+
// A value of 1 will effectively track all objects that are passed through
|
|
84
|
+
// start/end_heap_allocation_recording pairs. A value of 10 will only track every 10th
|
|
85
|
+
// object passed through such calls and its effective weight for the purposes of heap
|
|
86
|
+
// profiling will be multiplied by 10.
|
|
87
|
+
//
|
|
88
|
+
// NOTE: Default is 1, i.e., track all heap allocation recordings.
|
|
89
|
+
//
|
|
90
|
+
// WARN: Non-positive values will lead to an exception being thrown.
|
|
91
|
+
void heap_recorder_set_sample_rate(heap_recorder *heap_recorder, int sample_rate);
|
|
92
|
+
|
|
93
|
+
// Do any cleanup needed after forking.
|
|
94
|
+
// WARN: Assumes this gets called before profiler is reinitialized on the fork
|
|
95
|
+
void heap_recorder_after_fork(heap_recorder *heap_recorder);
|
|
96
|
+
|
|
97
|
+
// Start a heap allocation recording on the heap recorder for a new object.
|
|
98
|
+
//
|
|
99
|
+
// This heap allocation recording needs to be ended via ::end_heap_allocation_recording
|
|
100
|
+
// before it will become fully committed and able to be iterated on.
|
|
101
|
+
//
|
|
102
|
+
// @param new_obj
|
|
103
|
+
// The newly allocated Ruby object/value.
|
|
104
|
+
// @param weight
|
|
105
|
+
// The sampling weight of this object.
|
|
106
|
+
//
|
|
107
|
+
// WARN: It needs to be paired with a ::end_heap_allocation_recording call.
|
|
108
|
+
void start_heap_allocation_recording(heap_recorder *heap_recorder, VALUE new_obj, unsigned int weight, ddog_CharSlice *alloc_class);
|
|
109
|
+
|
|
110
|
+
// End a previously started heap allocation recording on the heap recorder.
|
|
111
|
+
//
|
|
112
|
+
// It is at this point that an allocated object will become fully tracked and able to be iterated on.
|
|
113
|
+
//
|
|
114
|
+
// @param locations The stacktrace representing the location of the allocation.
|
|
115
|
+
//
|
|
116
|
+
// WARN: It is illegal to call this without previously having called ::start_heap_allocation_recording.
|
|
117
|
+
void end_heap_allocation_recording(heap_recorder *heap_recorder, ddog_prof_Slice_Location locations);
|
|
118
|
+
|
|
119
|
+
// Update the heap recorder to reflect the latest state of the VM and prepare internal structures
|
|
120
|
+
// for efficient iteration.
|
|
121
|
+
//
|
|
122
|
+
// WARN: This must be called strictly before iteration. Failing to do so will result in exceptions.
|
|
123
|
+
void heap_recorder_prepare_iteration(heap_recorder *heap_recorder);
|
|
124
|
+
|
|
125
|
+
// Optimize the heap recorder by cleaning up any data that might have been prepared specifically
|
|
126
|
+
// for the purpose of iterating over the heap recorder data.
|
|
127
|
+
//
|
|
128
|
+
// WARN: This must be called strictly after iteration to ensure proper cleanup and to keep the memory
|
|
129
|
+
// profile of the heap recorder low.
|
|
130
|
+
void heap_recorder_finish_iteration(heap_recorder *heap_recorder);
|
|
131
|
+
|
|
132
|
+
// Iterate over each live object being tracked by the heap recorder.
|
|
133
|
+
//
|
|
134
|
+
// NOTE: Iteration can be called without holding the Ruby Global VM lock.
|
|
135
|
+
// WARN: This must be called strictly after heap_recorder_prepare_iteration and before
|
|
136
|
+
// heap_recorder_finish_iteration.
|
|
137
|
+
//
|
|
138
|
+
// @param for_each_callback
|
|
139
|
+
// A callback function that shall be called for each live object being tracked
|
|
140
|
+
// by the heap recorder. Alongside the iteration_data for each live object,
|
|
141
|
+
// a second argument will be forwarded with the contents of the optional
|
|
142
|
+
// for_each_callback_extra_arg. Iteration will continue until the callback
|
|
143
|
+
// returns false or we run out of objects.
|
|
144
|
+
// @param for_each_callback_extra_arg
|
|
145
|
+
// Optional (NULL if empty) extra data that should be passed to the
|
|
146
|
+
// callback function alongside the data for each live tracked object.
|
|
147
|
+
// @return true if iteration ran, false if something prevented it from running.
|
|
148
|
+
bool heap_recorder_for_each_live_object(
|
|
149
|
+
heap_recorder *heap_recorder,
|
|
150
|
+
bool (*for_each_callback)(heap_recorder_iteration_data data, void* extra_arg),
|
|
151
|
+
void *for_each_callback_extra_arg);
|
|
152
|
+
|
|
153
|
+
// Return a Ruby hash containing a snapshot of this recorder's interesting state at calling time.
|
|
154
|
+
// WARN: This allocates in the Ruby VM and therefore should not be called without the
|
|
155
|
+
// VM lock or during GC.
|
|
156
|
+
VALUE heap_recorder_state_snapshot(heap_recorder *heap_recorder);
|
|
157
|
+
|
|
158
|
+
// v--- TEST-ONLY APIs ---v
|
|
159
|
+
|
|
160
|
+
// Assert internal hashing logic is valid for the provided locations and its
|
|
161
|
+
// corresponding internal representations in heap recorder.
|
|
162
|
+
void heap_recorder_testonly_assert_hash_matches(ddog_prof_Slice_Location locations);
|
|
163
|
+
|
|
164
|
+
// Returns a Ruby string with a representation of internal data helpful to
|
|
165
|
+
// troubleshoot issues such as unexpected test failures.
|
|
166
|
+
VALUE heap_recorder_testonly_debug(heap_recorder *heap_recorder);
|
data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/helpers.h
RENAMED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
+
#include <stdint.h>
|
|
4
|
+
|
|
3
5
|
// Used to mark symbols to be exported to the outside of the extension.
|
|
4
6
|
// Consider very carefully before tagging a function with this.
|
|
5
7
|
#define DDTRACE_EXPORT __attribute__ ((visibility ("default")))
|
|
@@ -15,3 +17,7 @@
|
|
|
15
17
|
// don't like C and I just implemented this as a function.
|
|
16
18
|
inline static uint64_t uint64_max_of(uint64_t a, uint64_t b) { return a > b ? a : b; }
|
|
17
19
|
inline static uint64_t uint64_min_of(uint64_t a, uint64_t b) { return a > b ? b : a; }
|
|
20
|
+
inline static long long_max_of(long a, long b) { return a > b ? a : b; }
|
|
21
|
+
inline static long long_min_of(long a, long b) { return a > b ? b : a; }
|
|
22
|
+
inline static double double_max_of(double a, double b) { return a > b ? a : b; }
|
|
23
|
+
inline static double double_min_of(double a, double b) { return a > b ? b : a; }
|
data/ext/{ddtrace_profiling_native_extension → datadog_profiling_native_extension}/http_transport.c
RENAMED
|
@@ -16,7 +16,6 @@ static ID agent_id; // id of :agent in Ruby
|
|
|
16
16
|
|
|
17
17
|
static ID log_failure_to_process_tag_id; // id of :log_failure_to_process_tag in Ruby
|
|
18
18
|
|
|
19
|
-
static VALUE http_transport_class = Qnil;
|
|
20
19
|
static VALUE library_version_string = Qnil;
|
|
21
20
|
|
|
22
21
|
struct call_exporter_without_gvl_arguments {
|
|
@@ -31,7 +30,7 @@ inline static ddog_ByteSlice byte_slice_from_ruby_string(VALUE string);
|
|
|
31
30
|
static VALUE _native_validate_exporter(VALUE self, VALUE exporter_configuration);
|
|
32
31
|
static ddog_prof_Exporter_NewResult create_exporter(VALUE exporter_configuration, VALUE tags_as_array);
|
|
33
32
|
static VALUE handle_exporter_failure(ddog_prof_Exporter_NewResult exporter_result);
|
|
34
|
-
static
|
|
33
|
+
static ddog_prof_Endpoint endpoint_from(VALUE exporter_configuration);
|
|
35
34
|
static ddog_Vec_Tag convert_tags(VALUE tags_as_array);
|
|
36
35
|
static void safely_log_failure_to_process_tag(ddog_Vec_Tag tags, VALUE err_details);
|
|
37
36
|
static VALUE _native_do_export(
|
|
@@ -46,17 +45,18 @@ static VALUE _native_do_export(
|
|
|
46
45
|
VALUE pprof_data,
|
|
47
46
|
VALUE code_provenance_file_name,
|
|
48
47
|
VALUE code_provenance_data,
|
|
49
|
-
VALUE tags_as_array
|
|
48
|
+
VALUE tags_as_array,
|
|
49
|
+
VALUE internal_metadata_json,
|
|
50
|
+
VALUE info_json
|
|
50
51
|
);
|
|
51
52
|
static void *call_exporter_without_gvl(void *call_args);
|
|
52
53
|
static void interrupt_exporter_call(void *cancel_token);
|
|
53
|
-
static VALUE ddtrace_version(void);
|
|
54
54
|
|
|
55
55
|
void http_transport_init(VALUE profiling_module) {
|
|
56
|
-
http_transport_class = rb_define_class_under(profiling_module, "HttpTransport", rb_cObject);
|
|
56
|
+
VALUE http_transport_class = rb_define_class_under(profiling_module, "HttpTransport", rb_cObject);
|
|
57
57
|
|
|
58
58
|
rb_define_singleton_method(http_transport_class, "_native_validate_exporter", _native_validate_exporter, 1);
|
|
59
|
-
rb_define_singleton_method(http_transport_class, "_native_do_export", _native_do_export,
|
|
59
|
+
rb_define_singleton_method(http_transport_class, "_native_do_export", _native_do_export, 13);
|
|
60
60
|
|
|
61
61
|
ok_symbol = ID2SYM(rb_intern_const("ok"));
|
|
62
62
|
error_symbol = ID2SYM(rb_intern_const("error"));
|
|
@@ -94,7 +94,7 @@ static ddog_prof_Exporter_NewResult create_exporter(VALUE exporter_configuration
|
|
|
94
94
|
|
|
95
95
|
// This needs to be called BEFORE convert_tags since it can raise an exception and thus cause the ddog_Vec_Tag
|
|
96
96
|
// to be leaked.
|
|
97
|
-
|
|
97
|
+
ddog_prof_Endpoint endpoint = endpoint_from(exporter_configuration);
|
|
98
98
|
|
|
99
99
|
ddog_Vec_Tag tags = convert_tags(tags_as_array);
|
|
100
100
|
|
|
@@ -116,7 +116,7 @@ static VALUE handle_exporter_failure(ddog_prof_Exporter_NewResult exporter_resul
|
|
|
116
116
|
rb_ary_new_from_args(2, error_symbol, get_error_details_and_drop(&exporter_result.err));
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
static
|
|
119
|
+
static ddog_prof_Endpoint endpoint_from(VALUE exporter_configuration) {
|
|
120
120
|
ENFORCE_TYPE(exporter_configuration, T_ARRAY);
|
|
121
121
|
|
|
122
122
|
ID working_mode = SYM2ID(rb_ary_entry(exporter_configuration, 0)); // SYM2ID verifies its input so we can do this safely
|
|
@@ -131,12 +131,12 @@ static ddog_Endpoint endpoint_from(VALUE exporter_configuration) {
|
|
|
131
131
|
ENFORCE_TYPE(site, T_STRING);
|
|
132
132
|
ENFORCE_TYPE(api_key, T_STRING);
|
|
133
133
|
|
|
134
|
-
return
|
|
134
|
+
return ddog_prof_Endpoint_agentless(char_slice_from_ruby_string(site), char_slice_from_ruby_string(api_key));
|
|
135
135
|
} else { // agent_id
|
|
136
136
|
VALUE base_url = rb_ary_entry(exporter_configuration, 1);
|
|
137
137
|
ENFORCE_TYPE(base_url, T_STRING);
|
|
138
138
|
|
|
139
|
-
return
|
|
139
|
+
return ddog_prof_Endpoint_agent(char_slice_from_ruby_string(base_url));
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
|
|
@@ -179,6 +179,10 @@ static ddog_Vec_Tag convert_tags(VALUE tags_as_array) {
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
static VALUE log_failure_to_process_tag(VALUE err_details) {
|
|
182
|
+
VALUE datadog_module = rb_const_get(rb_cObject, rb_intern("Datadog"));
|
|
183
|
+
VALUE profiling_module = rb_const_get(datadog_module, rb_intern("Profiling"));
|
|
184
|
+
VALUE http_transport_class = rb_const_get(profiling_module, rb_intern("HttpTransport"));
|
|
185
|
+
|
|
182
186
|
return rb_funcall(http_transport_class, log_failure_to_process_tag_id, 1, err_details);
|
|
183
187
|
}
|
|
184
188
|
|
|
@@ -200,13 +204,26 @@ static VALUE perform_export(
|
|
|
200
204
|
ddog_prof_Exporter *exporter,
|
|
201
205
|
ddog_Timespec start,
|
|
202
206
|
ddog_Timespec finish,
|
|
203
|
-
ddog_prof_Exporter_Slice_File
|
|
207
|
+
ddog_prof_Exporter_Slice_File files_to_compress_and_export,
|
|
208
|
+
ddog_prof_Exporter_Slice_File files_to_export_unmodified,
|
|
204
209
|
ddog_Vec_Tag *additional_tags,
|
|
210
|
+
ddog_CharSlice internal_metadata,
|
|
211
|
+
ddog_CharSlice info,
|
|
205
212
|
uint64_t timeout_milliseconds
|
|
206
213
|
) {
|
|
207
214
|
ddog_prof_ProfiledEndpointsStats *endpoints_stats = NULL; // Not in use yet
|
|
208
|
-
ddog_prof_Exporter_Request_BuildResult build_result =
|
|
209
|
-
|
|
215
|
+
ddog_prof_Exporter_Request_BuildResult build_result = ddog_prof_Exporter_Request_build(
|
|
216
|
+
exporter,
|
|
217
|
+
start,
|
|
218
|
+
finish,
|
|
219
|
+
files_to_compress_and_export,
|
|
220
|
+
files_to_export_unmodified,
|
|
221
|
+
additional_tags,
|
|
222
|
+
endpoints_stats,
|
|
223
|
+
&internal_metadata,
|
|
224
|
+
&info,
|
|
225
|
+
timeout_milliseconds
|
|
226
|
+
);
|
|
210
227
|
|
|
211
228
|
if (build_result.tag == DDOG_PROF_EXPORTER_REQUEST_BUILD_RESULT_ERR) {
|
|
212
229
|
ddog_prof_Exporter_drop(exporter);
|
|
@@ -274,7 +291,9 @@ static VALUE _native_do_export(
|
|
|
274
291
|
VALUE pprof_data,
|
|
275
292
|
VALUE code_provenance_file_name,
|
|
276
293
|
VALUE code_provenance_data,
|
|
277
|
-
VALUE tags_as_array
|
|
294
|
+
VALUE tags_as_array,
|
|
295
|
+
VALUE internal_metadata_json,
|
|
296
|
+
VALUE info_json
|
|
278
297
|
) {
|
|
279
298
|
ENFORCE_TYPE(upload_timeout_milliseconds, T_FIXNUM);
|
|
280
299
|
ENFORCE_TYPE(start_timespec_seconds, T_FIXNUM);
|
|
@@ -284,6 +303,8 @@ static VALUE _native_do_export(
|
|
|
284
303
|
ENFORCE_TYPE(pprof_file_name, T_STRING);
|
|
285
304
|
ENFORCE_TYPE(pprof_data, T_STRING);
|
|
286
305
|
ENFORCE_TYPE(code_provenance_file_name, T_STRING);
|
|
306
|
+
ENFORCE_TYPE(internal_metadata_json, T_STRING);
|
|
307
|
+
ENFORCE_TYPE(info_json, T_STRING);
|
|
287
308
|
|
|
288
309
|
// Code provenance can be disabled and in that case will be set to nil
|
|
289
310
|
bool have_code_provenance = !NIL_P(code_provenance_data);
|
|
@@ -296,22 +317,29 @@ static VALUE _native_do_export(
|
|
|
296
317
|
ddog_Timespec finish =
|
|
297
318
|
{.seconds = NUM2LONG(finish_timespec_seconds), .nanoseconds = NUM2UINT(finish_timespec_nanoseconds)};
|
|
298
319
|
|
|
299
|
-
int
|
|
300
|
-
ddog_prof_Exporter_File
|
|
301
|
-
|
|
320
|
+
int to_compress_length = have_code_provenance ? 1 : 0;
|
|
321
|
+
ddog_prof_Exporter_File to_compress[to_compress_length];
|
|
322
|
+
int already_compressed_length = 1; // pprof
|
|
323
|
+
ddog_prof_Exporter_File already_compressed[already_compressed_length];
|
|
324
|
+
|
|
325
|
+
ddog_prof_Exporter_Slice_File files_to_compress_and_export = {.ptr = to_compress, .len = to_compress_length};
|
|
326
|
+
ddog_prof_Exporter_Slice_File files_to_export_unmodified = {.ptr = already_compressed, .len = already_compressed_length};
|
|
302
327
|
|
|
303
|
-
|
|
328
|
+
already_compressed[0] = (ddog_prof_Exporter_File) {
|
|
304
329
|
.name = char_slice_from_ruby_string(pprof_file_name),
|
|
305
|
-
.file = byte_slice_from_ruby_string(pprof_data)
|
|
330
|
+
.file = byte_slice_from_ruby_string(pprof_data),
|
|
306
331
|
};
|
|
332
|
+
|
|
307
333
|
if (have_code_provenance) {
|
|
308
|
-
|
|
334
|
+
to_compress[0] = (ddog_prof_Exporter_File) {
|
|
309
335
|
.name = char_slice_from_ruby_string(code_provenance_file_name),
|
|
310
|
-
.file = byte_slice_from_ruby_string(code_provenance_data)
|
|
336
|
+
.file = byte_slice_from_ruby_string(code_provenance_data),
|
|
311
337
|
};
|
|
312
338
|
}
|
|
313
339
|
|
|
314
340
|
ddog_Vec_Tag *null_additional_tags = NULL;
|
|
341
|
+
ddog_CharSlice internal_metadata = char_slice_from_ruby_string(internal_metadata_json);
|
|
342
|
+
ddog_CharSlice info = char_slice_from_ruby_string(info_json);
|
|
315
343
|
|
|
316
344
|
ddog_prof_Exporter_NewResult exporter_result = create_exporter(exporter_configuration, tags_as_array);
|
|
317
345
|
// Note: Do not add anything that can raise exceptions after this line, as otherwise the exporter memory will leak
|
|
@@ -319,7 +347,17 @@ static VALUE _native_do_export(
|
|
|
319
347
|
VALUE failure_tuple = handle_exporter_failure(exporter_result);
|
|
320
348
|
if (!NIL_P(failure_tuple)) return failure_tuple;
|
|
321
349
|
|
|
322
|
-
return perform_export(
|
|
350
|
+
return perform_export(
|
|
351
|
+
exporter_result.ok,
|
|
352
|
+
start,
|
|
353
|
+
finish,
|
|
354
|
+
files_to_compress_and_export,
|
|
355
|
+
files_to_export_unmodified,
|
|
356
|
+
null_additional_tags,
|
|
357
|
+
internal_metadata,
|
|
358
|
+
info,
|
|
359
|
+
timeout_milliseconds
|
|
360
|
+
);
|
|
323
361
|
}
|
|
324
362
|
|
|
325
363
|
static void *call_exporter_without_gvl(void *call_args) {
|
|
@@ -335,13 +373,3 @@ static void *call_exporter_without_gvl(void *call_args) {
|
|
|
335
373
|
static void interrupt_exporter_call(void *cancel_token) {
|
|
336
374
|
ddog_CancellationToken_cancel((ddog_CancellationToken *) cancel_token);
|
|
337
375
|
}
|
|
338
|
-
|
|
339
|
-
static VALUE ddtrace_version(void) {
|
|
340
|
-
VALUE ddtrace_module = rb_const_get(rb_cObject, rb_intern("DDTrace"));
|
|
341
|
-
ENFORCE_TYPE(ddtrace_module, T_MODULE);
|
|
342
|
-
VALUE version_module = rb_const_get(ddtrace_module, rb_intern("VERSION"));
|
|
343
|
-
ENFORCE_TYPE(version_module, T_MODULE);
|
|
344
|
-
VALUE version_string = rb_const_get(version_module, rb_intern("STRING"));
|
|
345
|
-
ENFORCE_TYPE(version_string, T_STRING);
|
|
346
|
-
return version_string;
|
|
347
|
-
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#include "libdatadog_helpers.h"
|
|
2
|
+
|
|
3
|
+
#include <ruby.h>
|
|
4
|
+
|
|
5
|
+
const char *ruby_value_type_to_string(enum ruby_value_type type) {
|
|
6
|
+
return ruby_value_type_to_char_slice(type).ptr;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
ddog_CharSlice ruby_value_type_to_char_slice(enum ruby_value_type type) {
|
|
10
|
+
switch (type) {
|
|
11
|
+
case(RUBY_T_NONE ): return DDOG_CHARSLICE_C("T_NONE");
|
|
12
|
+
case(RUBY_T_OBJECT ): return DDOG_CHARSLICE_C("T_OBJECT");
|
|
13
|
+
case(RUBY_T_CLASS ): return DDOG_CHARSLICE_C("T_CLASS");
|
|
14
|
+
case(RUBY_T_MODULE ): return DDOG_CHARSLICE_C("T_MODULE");
|
|
15
|
+
case(RUBY_T_FLOAT ): return DDOG_CHARSLICE_C("T_FLOAT");
|
|
16
|
+
case(RUBY_T_STRING ): return DDOG_CHARSLICE_C("T_STRING");
|
|
17
|
+
case(RUBY_T_REGEXP ): return DDOG_CHARSLICE_C("T_REGEXP");
|
|
18
|
+
case(RUBY_T_ARRAY ): return DDOG_CHARSLICE_C("T_ARRAY");
|
|
19
|
+
case(RUBY_T_HASH ): return DDOG_CHARSLICE_C("T_HASH");
|
|
20
|
+
case(RUBY_T_STRUCT ): return DDOG_CHARSLICE_C("T_STRUCT");
|
|
21
|
+
case(RUBY_T_BIGNUM ): return DDOG_CHARSLICE_C("T_BIGNUM");
|
|
22
|
+
case(RUBY_T_FILE ): return DDOG_CHARSLICE_C("T_FILE");
|
|
23
|
+
case(RUBY_T_DATA ): return DDOG_CHARSLICE_C("T_DATA");
|
|
24
|
+
case(RUBY_T_MATCH ): return DDOG_CHARSLICE_C("T_MATCH");
|
|
25
|
+
case(RUBY_T_COMPLEX ): return DDOG_CHARSLICE_C("T_COMPLEX");
|
|
26
|
+
case(RUBY_T_RATIONAL): return DDOG_CHARSLICE_C("T_RATIONAL");
|
|
27
|
+
case(RUBY_T_NIL ): return DDOG_CHARSLICE_C("T_NIL");
|
|
28
|
+
case(RUBY_T_TRUE ): return DDOG_CHARSLICE_C("T_TRUE");
|
|
29
|
+
case(RUBY_T_FALSE ): return DDOG_CHARSLICE_C("T_FALSE");
|
|
30
|
+
case(RUBY_T_SYMBOL ): return DDOG_CHARSLICE_C("T_SYMBOL");
|
|
31
|
+
case(RUBY_T_FIXNUM ): return DDOG_CHARSLICE_C("T_FIXNUM");
|
|
32
|
+
case(RUBY_T_UNDEF ): return DDOG_CHARSLICE_C("T_UNDEF");
|
|
33
|
+
case(RUBY_T_IMEMO ): return DDOG_CHARSLICE_C("T_IMEMO");
|
|
34
|
+
case(RUBY_T_NODE ): return DDOG_CHARSLICE_C("T_NODE");
|
|
35
|
+
case(RUBY_T_ICLASS ): return DDOG_CHARSLICE_C("T_ICLASS");
|
|
36
|
+
case(RUBY_T_ZOMBIE ): return DDOG_CHARSLICE_C("T_ZOMBIE");
|
|
37
|
+
#ifndef NO_T_MOVED
|
|
38
|
+
case(RUBY_T_MOVED ): return DDOG_CHARSLICE_C("T_MOVED");
|
|
39
|
+
#endif
|
|
40
|
+
default: return DDOG_CHARSLICE_C("BUG: Unknown value for ruby_value_type");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
size_t read_ddogerr_string_and_drop(ddog_Error *error, char *string, size_t capacity) {
|
|
45
|
+
if (capacity == 0 || string == NULL) {
|
|
46
|
+
// short-circuit, we can't write anything
|
|
47
|
+
ddog_Error_drop(error);
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
ddog_CharSlice error_msg_slice = ddog_Error_message(error);
|
|
52
|
+
size_t error_msg_size = error_msg_slice.len;
|
|
53
|
+
// Account for extra null char for proper cstring
|
|
54
|
+
if (error_msg_size >= capacity) {
|
|
55
|
+
// Error message too big, lets truncate it to capacity - 1 to allow for extra null at end
|
|
56
|
+
error_msg_size = capacity - 1;
|
|
57
|
+
}
|
|
58
|
+
strncpy(string, error_msg_slice.ptr, error_msg_size);
|
|
59
|
+
string[error_msg_size] = '\0';
|
|
60
|
+
ddog_Error_drop(error);
|
|
61
|
+
return error_msg_size;
|
|
62
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <datadog/profiling.h>
|
|
4
|
+
#include "ruby_helpers.h"
|
|
5
|
+
|
|
6
|
+
inline static ddog_CharSlice char_slice_from_ruby_string(VALUE string) {
|
|
7
|
+
ENFORCE_TYPE(string, T_STRING);
|
|
8
|
+
ddog_CharSlice char_slice = {.ptr = StringValuePtr(string), .len = RSTRING_LEN(string)};
|
|
9
|
+
return char_slice;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
inline static VALUE ruby_string_from_vec_u8(ddog_Vec_U8 string) {
|
|
13
|
+
return rb_str_new((char *) string.ptr, string.len);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
inline static VALUE ruby_string_from_error(const ddog_Error *error) {
|
|
17
|
+
ddog_CharSlice char_slice = ddog_Error_message(error);
|
|
18
|
+
return rb_str_new(char_slice.ptr, char_slice.len);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
inline static VALUE get_error_details_and_drop(ddog_Error *error) {
|
|
22
|
+
VALUE result = ruby_string_from_error(error);
|
|
23
|
+
ddog_Error_drop(error);
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Utility function to be able to extract an error cstring from a ddog_Error.
|
|
28
|
+
// Returns the amount of characters written to string (which are necessarily
|
|
29
|
+
// bounded by capacity - 1 since the string will be null-terminated).
|
|
30
|
+
size_t read_ddogerr_string_and_drop(ddog_Error *error, char *string, size_t capacity);
|
|
31
|
+
|
|
32
|
+
// Used for pretty printing this Ruby enum. Returns "T_UNKNOWN_OR_MISSING_RUBY_VALUE_TYPE_ENTRY" for unknown elements.
|
|
33
|
+
// In practice, there's a few types that the profiler will probably never encounter, but I've added all entries of
|
|
34
|
+
// ruby_value_type that Ruby uses so that we can also use this for debugging.
|
|
35
|
+
const char *ruby_value_type_to_string(enum ruby_value_type type);
|
|
36
|
+
ddog_CharSlice ruby_value_type_to_char_slice(enum ruby_value_type type);
|
|
37
|
+
|
|
38
|
+
// Returns a dynamically allocated string from the provided char slice.
|
|
39
|
+
// WARN: The returned string must be explicitly freed with ruby_xfree.
|
|
40
|
+
inline static char* string_from_char_slice(ddog_CharSlice slice) {
|
|
41
|
+
return ruby_strndup(slice.ptr, slice.len);
|
|
42
|
+
}
|
|
@@ -15,7 +15,7 @@ module Datadog
|
|
|
15
15
|
# The MJIT header was introduced on 2.6 and removed on 3.3; for other Rubies we rely on debase-ruby_core_source
|
|
16
16
|
CAN_USE_MJIT_HEADER = RUBY_VERSION.start_with?('2.6', '2.7', '3.0.', '3.1.', '3.2.')
|
|
17
17
|
|
|
18
|
-
LIBDATADOG_VERSION = '~>
|
|
18
|
+
LIBDATADOG_VERSION = '~> 7.0.0.1.0'
|
|
19
19
|
|
|
20
20
|
def self.fail_install_if_missing_extension?
|
|
21
21
|
ENV[ENV_FAIL_INSTALL_IF_MISSING_EXTENSION].to_s.strip.downcase == 'true'
|
|
@@ -29,7 +29,7 @@ module Datadog
|
|
|
29
29
|
# native extension), we need to add a "runpath" -- a list of folders to search for libdatadog.
|
|
30
30
|
#
|
|
31
31
|
# This runpath gets hardcoded at native library linking time. You can look at it using the `readelf` tool in
|
|
32
|
-
# Linux: e.g. `readelf -d
|
|
32
|
+
# Linux: e.g. `readelf -d datadog_profiling_native_extension.2.7.3_x86_64-linux.so`.
|
|
33
33
|
#
|
|
34
34
|
# In older versions of ddtrace, we only set as runpath an absolute path to libdatadog.
|
|
35
35
|
# (This gets set automatically by the call
|
|
@@ -67,6 +67,52 @@ module Datadog
|
|
|
67
67
|
Pathname.new(libdatadog_lib_folder).relative_path_from(Pathname.new(profiling_native_lib_folder)).to_s
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
+
# In https://github.com/DataDog/dd-trace-rb/pull/3582 we got a report of a customer for which the native extension
|
|
71
|
+
# only got installed into the extensions folder.
|
|
72
|
+
#
|
|
73
|
+
# But then this fix was not enough to fully get them moving because then they started to see the issue from
|
|
74
|
+
# https://github.com/DataDog/dd-trace-rb/issues/2067 / https://github.com/DataDog/dd-trace-rb/pull/2125 :
|
|
75
|
+
#
|
|
76
|
+
# > Profiling was requested but is not supported, profiling disabled: There was an error loading the profiling
|
|
77
|
+
# > native extension due to 'RuntimeError Failure to load datadog_profiling_native_extension.3.2.2_x86_64-linux
|
|
78
|
+
# > due to libdatadog_profiling.so: cannot open shared object file: No such file or directory
|
|
79
|
+
#
|
|
80
|
+
# The problem is that when loading the native extension from the extensions directory, the relative rpath we add
|
|
81
|
+
# with the #libdatadog_folder_relative_to_native_lib_folder helper above is not correct, we need to add a relative
|
|
82
|
+
# rpath to the extensions directory.
|
|
83
|
+
#
|
|
84
|
+
# So how do we find the full path where the native extension is placed?
|
|
85
|
+
# * From https://github.com/ruby/ruby/blob/83f02d42e0a3c39661dc99c049ab9a70ff227d5b/lib/bundler/runtime.rb#L166
|
|
86
|
+
# `extension_dirs = Dir["#{Gem.dir}/extensions/*/*/*"] + Dir["#{Gem.dir}/bundler/gems/extensions/*/*/*"]`
|
|
87
|
+
# we get that's in one of two fixed subdirectories of `Gem.dir`
|
|
88
|
+
# * From https://github.com/ruby/ruby/blob/83f02d42e0a3c39661dc99c049ab9a70ff227d5b/lib/rubygems/basic_specification.rb#L111-L115
|
|
89
|
+
# we get the structure of the subdirectory (platform/extension_api_version/gem_and_version)
|
|
90
|
+
#
|
|
91
|
+
# Thus, `Gem.dir` of `/var/app/current/vendor/bundle/ruby/3.2.0` becomes (for instance)
|
|
92
|
+
# `/var/app/current/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/datadog-2.0.0/` or
|
|
93
|
+
# `/var/app/current/vendor/bundle/ruby/3.2.0/bundler/gems/extensions/x86_64-linux/3.2.0/datadog-2.0.0/`
|
|
94
|
+
#
|
|
95
|
+
# We then compute the relative path between these folders and the libdatadog folder, and use that as a relative path.
|
|
96
|
+
def self.libdatadog_folder_relative_to_ruby_extensions_folders(
|
|
97
|
+
gem_dir: Gem.dir,
|
|
98
|
+
libdatadog_pkgconfig_folder: Libdatadog.pkgconfig_folder
|
|
99
|
+
)
|
|
100
|
+
return unless libdatadog_pkgconfig_folder
|
|
101
|
+
|
|
102
|
+
# For the purposes of calculating a folder relative to the other, we don't actually NEED to fill in the
|
|
103
|
+
# platform, extension_api_version and gem version. We're basically just after how many folders it is deep from
|
|
104
|
+
# the Gem.dir.
|
|
105
|
+
expected_ruby_extensions_folders = [
|
|
106
|
+
"#{gem_dir}/extensions/platform/extension_api_version/datadog_version/",
|
|
107
|
+
"#{gem_dir}/bundler/gems/extensions/platform/extension_api_version/datadog_version/",
|
|
108
|
+
]
|
|
109
|
+
libdatadog_lib_folder = "#{libdatadog_pkgconfig_folder}/../"
|
|
110
|
+
|
|
111
|
+
expected_ruby_extensions_folders.map do |folder|
|
|
112
|
+
Pathname.new(libdatadog_lib_folder).relative_path_from(Pathname.new(folder)).to_s
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
70
116
|
# Used to check if profiler is supported, including user-visible clear messages explaining why their
|
|
71
117
|
# system may not be supported.
|
|
72
118
|
module Supported
|
|
@@ -305,8 +351,8 @@ module Datadog
|
|
|
305
351
|
no_binaries_for_current_platform = explain_issue(
|
|
306
352
|
'the `libdatadog` gem installed on your system is missing binaries for your',
|
|
307
353
|
'platform variant.',
|
|
308
|
-
"(Your platform: `#{
|
|
309
|
-
'(Available binaries:
|
|
354
|
+
"(Your platform: `#{Libdatadog.current_platform}`)",
|
|
355
|
+
'(Available binaries:',
|
|
310
356
|
"`#{Libdatadog.available_binaries.join('`, `')}`)",
|
|
311
357
|
suggested: CONTACT_SUPPORT,
|
|
312
358
|
)
|