ddtrace 1.11.0 → 1.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +85 -1
- data/ext/ddtrace_profiling_native_extension/NativeExtensionDesign.md +6 -4
- data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +34 -16
- data/ext/ddtrace_profiling_native_extension/extconf.rb +19 -3
- data/ext/ddtrace_profiling_native_extension/native_extension_helpers.rb +2 -2
- data/ext/ddtrace_profiling_native_extension/private_vm_api_access.c +38 -4
- data/lib/datadog/appsec/assets/blocked.html +1 -1
- data/lib/datadog/appsec/assets/waf_rules/recommended.json +489 -133
- data/lib/datadog/appsec/assets/waf_rules/strict.json +2 -47
- data/lib/datadog/appsec/configuration/settings.rb +2 -10
- data/lib/datadog/appsec/configuration.rb +3 -9
- data/lib/datadog/appsec/contrib/rack/ext.rb +0 -1
- data/lib/datadog/appsec/contrib/rack/gateway/request.rb +17 -3
- data/lib/datadog/appsec/contrib/rack/gateway/response.rb +3 -3
- data/lib/datadog/appsec/contrib/rack/gateway/watcher.rb +27 -45
- data/lib/datadog/appsec/contrib/rack/integration.rb +0 -5
- data/lib/datadog/appsec/contrib/rack/reactive/request.rb +7 -1
- data/lib/datadog/appsec/contrib/rack/request_body_middleware.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/request_middleware.rb +34 -26
- data/lib/datadog/appsec/contrib/rails/ext.rb +0 -1
- data/lib/datadog/appsec/contrib/rails/framework.rb +1 -13
- data/lib/datadog/appsec/contrib/rails/gateway/watcher.rb +9 -27
- data/lib/datadog/appsec/contrib/rails/integration.rb +0 -5
- data/lib/datadog/appsec/contrib/rails/patcher.rb +1 -1
- data/lib/datadog/appsec/contrib/sinatra/ext.rb +0 -1
- data/lib/datadog/appsec/contrib/sinatra/framework.rb +1 -13
- data/lib/datadog/appsec/contrib/sinatra/gateway/watcher.rb +18 -36
- data/lib/datadog/appsec/contrib/sinatra/integration.rb +0 -5
- data/lib/datadog/appsec/contrib/sinatra/patcher.rb +5 -4
- data/lib/datadog/appsec/event.rb +37 -37
- data/lib/datadog/appsec/ext.rb +1 -0
- data/lib/datadog/appsec/extensions.rb +2 -6
- data/lib/datadog/appsec/monitor/gateway/watcher.rb +9 -28
- data/lib/datadog/appsec/processor/rule_loader.rb +3 -3
- data/lib/datadog/appsec/processor/rule_merger.rb +15 -29
- data/lib/datadog/appsec/processor.rb +0 -45
- data/lib/datadog/appsec/remote.rb +10 -8
- data/lib/datadog/appsec/response.rb +23 -11
- data/lib/datadog/appsec/scope.rb +61 -0
- data/lib/datadog/appsec.rb +6 -0
- data/lib/datadog/ci/ext/environment.rb +40 -4
- data/lib/datadog/core/configuration/components.rb +9 -3
- data/lib/datadog/core/configuration/settings.rb +74 -14
- data/lib/datadog/core/configuration.rb +5 -1
- data/lib/datadog/core/remote/client/capabilities.rb +1 -1
- data/lib/datadog/core/remote/client.rb +5 -1
- data/lib/datadog/core/telemetry/client.rb +1 -1
- data/lib/datadog/core/telemetry/collector.rb +2 -1
- data/lib/datadog/core/telemetry/http/transport.rb +1 -0
- data/lib/datadog/core/telemetry/v1/dependency.rb +2 -1
- data/lib/datadog/kit/appsec/events.rb +58 -13
- data/lib/datadog/kit/identity.rb +29 -10
- data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +2 -0
- data/lib/datadog/profiling/component.rb +69 -29
- data/lib/datadog/profiling.rb +2 -1
- data/lib/datadog/tracing/buffer.rb +0 -1
- data/lib/datadog/tracing/contrib/active_support/configuration/settings.rb +9 -1
- data/lib/datadog/tracing/contrib/aws/ext.rb +11 -1
- data/lib/datadog/tracing/contrib/aws/instrumentation.rb +7 -0
- data/lib/datadog/tracing/contrib/aws/parsed_context.rb +4 -0
- data/lib/datadog/tracing/contrib/aws/service/base.rb +16 -0
- data/lib/datadog/tracing/contrib/aws/service/dynamodb.rb +22 -0
- data/lib/datadog/tracing/contrib/aws/service/eventbridge.rb +22 -0
- data/lib/datadog/tracing/contrib/aws/service/kinesis.rb +32 -0
- data/lib/datadog/tracing/contrib/aws/service/s3.rb +22 -0
- data/lib/datadog/tracing/contrib/aws/service/sns.rb +30 -0
- data/lib/datadog/tracing/contrib/aws/service/sqs.rb +27 -0
- data/lib/datadog/tracing/contrib/aws/service/states.rb +40 -0
- data/lib/datadog/tracing/contrib/aws/services.rb +18 -0
- data/lib/datadog/tracing/contrib/httpclient/configuration/settings.rb +6 -1
- data/lib/datadog/tracing/contrib/httpclient/instrumentation.rb +5 -2
- data/lib/datadog/tracing/contrib/httprb/configuration/settings.rb +6 -1
- data/lib/datadog/tracing/contrib/httprb/instrumentation.rb +4 -2
- data/lib/datadog/tracing/contrib/mongodb/configuration/settings.rb +6 -1
- data/lib/datadog/tracing/contrib/mongodb/subscribers.rb +5 -2
- data/lib/datadog/tracing/contrib/mysql2/configuration/settings.rb +6 -1
- data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +5 -2
- data/lib/datadog/tracing/contrib/patcher.rb +0 -1
- data/lib/datadog/tracing/contrib/pg/configuration/settings.rb +6 -1
- data/lib/datadog/tracing/contrib/pg/instrumentation.rb +5 -2
- data/lib/datadog/tracing/contrib/presto/configuration/settings.rb +6 -1
- data/lib/datadog/tracing/contrib/presto/instrumentation.rb +4 -2
- data/lib/datadog/tracing/contrib/propagation/sql_comment.rb +10 -2
- data/lib/datadog/tracing/contrib/racecar/configuration/settings.rb +9 -1
- data/lib/datadog/tracing/contrib/racecar/event.rb +3 -1
- data/lib/datadog/tracing/contrib/rack/middlewares.rb +3 -1
- data/lib/datadog/tracing/contrib/redis/configuration/settings.rb +6 -1
- data/lib/datadog/tracing/contrib/redis/tags.rb +4 -1
- data/lib/datadog/tracing/contrib/rest_client/configuration/settings.rb +6 -1
- data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +4 -1
- data/lib/datadog/tracing/contrib/roda/patcher.rb +1 -1
- data/lib/datadog/tracing/contrib/sequel/database.rb +4 -1
- data/lib/datadog/tracing/contrib/sequel/dataset.rb +4 -1
- data/lib/datadog/tracing/contrib/sequel/utils.rb +4 -1
- data/lib/datadog/tracing/contrib/status_code_matcher.rb +0 -1
- data/lib/datadog/tracing/correlation.rb +0 -1
- data/lib/datadog/tracing/distributed/headers/ext.rb +1 -1
- data/lib/datadog/tracing/event.rb +0 -2
- data/lib/datadog/tracing/pipeline.rb +0 -2
- data/lib/datadog/tracing/runtime/metrics.rb +0 -2
- data/lib/datadog/tracing/sampling/rate_by_service_sampler.rb +0 -1
- data/lib/datadog/tracing/sampling/rate_sampler.rb +0 -2
- data/lib/datadog/tracing/sampling/rule.rb +0 -2
- data/lib/datadog/tracing/sampling/rule_sampler.rb +0 -2
- data/lib/datadog/tracing/span_operation.rb +0 -1
- data/lib/datadog/tracing/sync_writer.rb +0 -2
- data/lib/datadog/tracing/trace_operation.rb +0 -1
- data/lib/datadog/tracing/tracer.rb +0 -1
- data/lib/datadog/tracing/workers/trace_writer.rb +0 -1
- data/lib/datadog/tracing/workers.rb +0 -2
- data/lib/datadog/tracing/writer.rb +0 -2
- data/lib/ddtrace/version.rb +2 -2
- metadata +17 -18
- data/lib/datadog/appsec/contrib/configuration/settings.rb +0 -20
- data/lib/datadog/appsec/contrib/rack/configuration/settings.rb +0 -22
- data/lib/datadog/appsec/contrib/rails/configuration/settings.rb +0 -22
- data/lib/datadog/appsec/contrib/sinatra/configuration/settings.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7755d42a1b84dda8386f13ce2edc3854f09e1e227d5786546b19ea31a60cc03b
|
4
|
+
data.tar.gz: 57ee6f72d29b72305c8272b98dc4b7d08a66f9463820d9963aa487723094d1f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9c5d234fb1261e202bf8d4ae00417f31f325dbcc9ceb9081277ac96a04114316456fed6d21f3de343dbe6192e4a0ceccb4504e5b1a59bbb44fe2666042a7890
|
7
|
+
data.tar.gz: effa42b2181771676d69ea5efb946cd6bd4617853b36f75b9655a710d369f57a200dded1cdc8b86642eaf60174c20b44da3b3de29fbfddfd76c6845364927fe2
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,58 @@
|
|
2
2
|
|
3
3
|
## [Unreleased]
|
4
4
|
|
5
|
+
## [1.12.1] - 2023-06-14
|
6
|
+
|
7
|
+
### Added
|
8
|
+
Appsec: Add `appsec.blocked` tag to span ([#2895][])
|
9
|
+
Profiling: Add workaround for legacy profiler incompatibility with ruby-cloud-profiler gem ([#2891][])
|
10
|
+
Core: Allow setting remote configuration service name ([#2853][])
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
Appsec: Change the value format for the WAF address `server.request.query` ([#2903][])
|
14
|
+
Profiling: Log pkg-config command when building profiling native extension
|
15
|
+
|
16
|
+
### Fixed
|
17
|
+
Appsec: Update blocked response content_type resolution ([#2900][])
|
18
|
+
Appsec: Ensure to use service entry span. ([#2898][])
|
19
|
+
Tracing: Fix AWS integration constant loading ([#2896][])
|
20
|
+
|
21
|
+
## [1.12.0] - 2023-06-02
|
22
|
+
|
23
|
+
### Added
|
24
|
+
* Profiling: Add support for profiling Ruby 3.3.0-preview1 ([#2860][])
|
25
|
+
* Appsec: Appsec support nested apps ([#2836][])
|
26
|
+
* Appsec: Appsec add support for custom rules ([#2856][])
|
27
|
+
* Appsec: Update appsec static rules to 1.7.0 version ([#2869][])
|
28
|
+
* Appsec: Tag AppSec on Rack top-level span ([#2858][])
|
29
|
+
* Profiling: Implement "no signals" workaround and enable CPU Profiling 2.0 for all customers ([#2873][])
|
30
|
+
* Ci: Update CI Visibility spec ([#2874][])
|
31
|
+
* Appsec: Added missing waf addresses to request operation ([#2883][])
|
32
|
+
|
33
|
+
### Changed
|
34
|
+
|
35
|
+
* Tracing: Consistent APM Span tags for AWS SDK Requests ([#2730][])
|
36
|
+
* Tracing: Change default `service_name` values Part 2 ([#2765][])
|
37
|
+
* Profiling: Bump debase-ruby_core_source dependency to 3.2.1 ([#2875][])
|
38
|
+
|
39
|
+
### Fixed
|
40
|
+
* Telemetry: Disable for non-HTTP agent connection ([#2815][])
|
41
|
+
* Tracing: Fix circular requires ([#2826][])
|
42
|
+
* Tracing: Update comment about Datadog::Tracing::Distributed::Ext to correct modules ([#2840][])
|
43
|
+
* Appsec: Check if `:appsec` setting is present before accessing it in remote component ([#2854][])
|
44
|
+
* Telemetry: Do not send Dependency `hash` when `version` is present ([#2855][])
|
45
|
+
* Core: Fix symbol configuration for `env` and `service` ([#2864][])
|
46
|
+
* Tracing: Fix sql comment propagation `full` mode when tracing is disabled ([#2866][])
|
47
|
+
* Appsec: Use relative URI for server.request.uri.raw ([#2890][])
|
48
|
+
|
49
|
+
## [1.11.1] - 2023-05-03
|
50
|
+
|
51
|
+
### Fixed
|
52
|
+
|
53
|
+
* Appsec: Remove misreported `ASM_CUSTOM_RULES` capability ([#2829][])
|
54
|
+
* Appsec: Fix block response content negotiation ([#2824][])
|
55
|
+
* Appsec: Fix incorrect remote configuration payload key handling ([#2822][])
|
56
|
+
|
5
57
|
## [1.11.0] - 2023-04-27
|
6
58
|
|
7
59
|
### Highlights
|
@@ -2402,7 +2454,10 @@ Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.3.1
|
|
2402
2454
|
|
2403
2455
|
Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
|
2404
2456
|
|
2405
|
-
[Unreleased]: https://github.com/DataDog/dd-trace-rb/compare/v1.
|
2457
|
+
[Unreleased]: https://github.com/DataDog/dd-trace-rb/compare/v1.12.1...master
|
2458
|
+
[1.12.1]: https://github.com/DataDog/dd-trace-rb/compare/v1.12.0...v1.12.1
|
2459
|
+
[1.12.0]: https://github.com/DataDog/dd-trace-rb/compare/v1.11.1...v1.12.0
|
2460
|
+
[1.11.1]: https://github.com/DataDog/dd-trace-rb/compare/v1.10.1...v1.11.1
|
2406
2461
|
[1.11.0]: https://github.com/DataDog/dd-trace-rb/compare/v1.10.1...v1.11.0
|
2407
2462
|
[1.11.0.beta1]: https://github.com/DataDog/dd-trace-rb/compare/v1.10.1...v1.11.0.beta1
|
2408
2463
|
[1.10.1]: https://github.com/DataDog/dd-trace-rb/compare/v1.10.0...v1.10.1
|
@@ -3436,6 +3491,7 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
|
|
3436
3491
|
[#2720]: https://github.com/DataDog/dd-trace-rb/issues/2720
|
3437
3492
|
[#2726]: https://github.com/DataDog/dd-trace-rb/issues/2726
|
3438
3493
|
[#2727]: https://github.com/DataDog/dd-trace-rb/issues/2727
|
3494
|
+
[#2730]: https://github.com/DataDog/dd-trace-rb/issues/2730
|
3439
3495
|
[#2731]: https://github.com/DataDog/dd-trace-rb/issues/2731
|
3440
3496
|
[#2732]: https://github.com/DataDog/dd-trace-rb/issues/2732
|
3441
3497
|
[#2733]: https://github.com/DataDog/dd-trace-rb/issues/2733
|
@@ -3446,6 +3502,7 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
|
|
3446
3502
|
[#2757]: https://github.com/DataDog/dd-trace-rb/issues/2757
|
3447
3503
|
[#2760]: https://github.com/DataDog/dd-trace-rb/issues/2760
|
3448
3504
|
[#2762]: https://github.com/DataDog/dd-trace-rb/issues/2762
|
3505
|
+
[#2765]: https://github.com/DataDog/dd-trace-rb/issues/2765
|
3449
3506
|
[#2769]: https://github.com/DataDog/dd-trace-rb/issues/2769
|
3450
3507
|
[#2770]: https://github.com/DataDog/dd-trace-rb/issues/2770
|
3451
3508
|
[#2771]: https://github.com/DataDog/dd-trace-rb/issues/2771
|
@@ -3457,6 +3514,33 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
|
|
3457
3514
|
[#2805]: https://github.com/DataDog/dd-trace-rb/issues/2805
|
3458
3515
|
[#2806]: https://github.com/DataDog/dd-trace-rb/issues/2806
|
3459
3516
|
[#2810]: https://github.com/DataDog/dd-trace-rb/issues/2810
|
3517
|
+
[#2815]: https://github.com/DataDog/dd-trace-rb/issues/2815
|
3518
|
+
[#2822]: https://github.com/DataDog/dd-trace-rb/issues/2822
|
3519
|
+
[#2824]: https://github.com/DataDog/dd-trace-rb/issues/2824
|
3520
|
+
[#2826]: https://github.com/DataDog/dd-trace-rb/issues/2826
|
3521
|
+
[#2829]: https://github.com/DataDog/dd-trace-rb/issues/2829
|
3522
|
+
[#2836]: https://github.com/DataDog/dd-trace-rb/issues/2836
|
3523
|
+
[#2840]: https://github.com/DataDog/dd-trace-rb/issues/2840
|
3524
|
+
[#2853]: https://github.com/DataDog/dd-trace-rb/issues/2853
|
3525
|
+
[#2854]: https://github.com/DataDog/dd-trace-rb/issues/2854
|
3526
|
+
[#2855]: https://github.com/DataDog/dd-trace-rb/issues/2855
|
3527
|
+
[#2856]: https://github.com/DataDog/dd-trace-rb/issues/2856
|
3528
|
+
[#2858]: https://github.com/DataDog/dd-trace-rb/issues/2858
|
3529
|
+
[#2860]: https://github.com/DataDog/dd-trace-rb/issues/2860
|
3530
|
+
[#2864]: https://github.com/DataDog/dd-trace-rb/issues/2864
|
3531
|
+
[#2866]: https://github.com/DataDog/dd-trace-rb/issues/2866
|
3532
|
+
[#2869]: https://github.com/DataDog/dd-trace-rb/issues/2869
|
3533
|
+
[#2873]: https://github.com/DataDog/dd-trace-rb/issues/2873
|
3534
|
+
[#2874]: https://github.com/DataDog/dd-trace-rb/issues/2874
|
3535
|
+
[#2875]: https://github.com/DataDog/dd-trace-rb/issues/2875
|
3536
|
+
[#2883]: https://github.com/DataDog/dd-trace-rb/issues/2883
|
3537
|
+
[#2890]: https://github.com/DataDog/dd-trace-rb/issues/2890
|
3538
|
+
[#2891]: https://github.com/DataDog/dd-trace-rb/issues/2891
|
3539
|
+
[#2895]: https://github.com/DataDog/dd-trace-rb/issues/2895
|
3540
|
+
[#2896]: https://github.com/DataDog/dd-trace-rb/issues/2896
|
3541
|
+
[#2898]: https://github.com/DataDog/dd-trace-rb/issues/2898
|
3542
|
+
[#2900]: https://github.com/DataDog/dd-trace-rb/issues/2900
|
3543
|
+
[#2903]: https://github.com/DataDog/dd-trace-rb/issues/2903
|
3460
3544
|
[@AdrianLC]: https://github.com/AdrianLC
|
3461
3545
|
[@Azure7111]: https://github.com/Azure7111
|
3462
3546
|
[@BabyGroot]: https://github.com/BabyGroot
|
@@ -68,19 +68,19 @@ internal types, structures and functions).
|
|
68
68
|
|
69
69
|
Because these private header files are not included in regular Ruby installations, we have two different workarounds:
|
70
70
|
|
71
|
-
1. for Ruby versions
|
72
|
-
2. for Ruby versions < 2.6
|
71
|
+
1. for Ruby versions 2.6 to 3.2 we make use use the Ruby private MJIT header
|
72
|
+
2. for Ruby versions < 2.6 and > 3.2 we make use of the `debase-ruby_core_source` gem
|
73
73
|
|
74
74
|
Functions which make use of these headers are defined in the <private_vm_api_acccess.c> file.
|
75
75
|
|
76
|
-
There is currently no way for disabling usage of the private MJIT header for Ruby 2.6
|
76
|
+
There is currently no way for disabling usage of the private MJIT header for Ruby 2.6 to 3.2.
|
77
77
|
|
78
78
|
**Important Note**: Our medium/long-term plan is to stop relying on all private Ruby headers, and instead request and
|
79
79
|
contribute upstream changes so that they become official public VM APIs.
|
80
80
|
|
81
81
|
### Approach 1: Using the Ruby private MJIT header
|
82
82
|
|
83
|
-
Ruby versions
|
83
|
+
Ruby versions 2.6 to 3.2 shipped a JIT compiler called MJIT. This compiler does not directly generate machine code;
|
84
84
|
instead it generates C code and uses the system C compiler to turn it into machine code.
|
85
85
|
|
86
86
|
The generated C code `#include`s a private header -- which we reference as "the MJIT header" everywhere.
|
@@ -90,6 +90,8 @@ and of course the intention is that it is only used by the Ruby MJIT compiler.
|
|
90
90
|
This header is placed inside the `include/` directory in a Ruby installation, and is named for that specific Ruby
|
91
91
|
version. e.g. `rb_mjit_min_header-2.7.4.h`.
|
92
92
|
|
93
|
+
This header was removed in Ruby 3.3.
|
94
|
+
|
93
95
|
### Approach 2: Using the `debase-ruby_core_source` gem
|
94
96
|
|
95
97
|
The [`debase-ruby_core_source`](https://github.com/ruby-debug/debase-ruby_core_source) contains almost no code;
|
@@ -81,6 +81,7 @@ struct cpu_and_wall_time_worker_state {
|
|
81
81
|
|
82
82
|
bool gc_profiling_enabled;
|
83
83
|
bool allocation_counting_enabled;
|
84
|
+
bool no_signals_workaround_enabled;
|
84
85
|
bool dynamic_sampling_rate_enabled;
|
85
86
|
VALUE self_instance;
|
86
87
|
VALUE thread_context_collector_instance;
|
@@ -148,6 +149,7 @@ static VALUE _native_initialize(
|
|
148
149
|
VALUE gc_profiling_enabled,
|
149
150
|
VALUE idle_sampling_helper_instance,
|
150
151
|
VALUE allocation_counting_enabled,
|
152
|
+
VALUE no_signals_workaround_enabled,
|
151
153
|
VALUE dynamic_sampling_rate_enabled
|
152
154
|
);
|
153
155
|
static void cpu_and_wall_time_worker_typed_data_mark(void *state_ptr);
|
@@ -221,7 +223,7 @@ void collectors_cpu_and_wall_time_worker_init(VALUE profiling_module) {
|
|
221
223
|
// https://bugs.ruby-lang.org/issues/18007 for a discussion around this.
|
222
224
|
rb_define_alloc_func(collectors_cpu_and_wall_time_worker_class, _native_new);
|
223
225
|
|
224
|
-
rb_define_singleton_method(collectors_cpu_and_wall_time_worker_class, "_native_initialize", _native_initialize,
|
226
|
+
rb_define_singleton_method(collectors_cpu_and_wall_time_worker_class, "_native_initialize", _native_initialize, 7);
|
225
227
|
rb_define_singleton_method(collectors_cpu_and_wall_time_worker_class, "_native_sampling_loop", _native_sampling_loop, 1);
|
226
228
|
rb_define_singleton_method(collectors_cpu_and_wall_time_worker_class, "_native_stop", _native_stop, 2);
|
227
229
|
rb_define_singleton_method(collectors_cpu_and_wall_time_worker_class, "_native_reset_after_fork", _native_reset_after_fork, 1);
|
@@ -257,6 +259,7 @@ static VALUE _native_new(VALUE klass) {
|
|
257
259
|
|
258
260
|
state->gc_profiling_enabled = false;
|
259
261
|
state->allocation_counting_enabled = false;
|
262
|
+
state->no_signals_workaround_enabled = false;
|
260
263
|
state->dynamic_sampling_rate_enabled = true;
|
261
264
|
state->thread_context_collector_instance = Qnil;
|
262
265
|
state->idle_sampling_helper_instance = Qnil;
|
@@ -283,10 +286,12 @@ static VALUE _native_initialize(
|
|
283
286
|
VALUE gc_profiling_enabled,
|
284
287
|
VALUE idle_sampling_helper_instance,
|
285
288
|
VALUE allocation_counting_enabled,
|
289
|
+
VALUE no_signals_workaround_enabled,
|
286
290
|
VALUE dynamic_sampling_rate_enabled
|
287
291
|
) {
|
288
292
|
ENFORCE_BOOLEAN(gc_profiling_enabled);
|
289
293
|
ENFORCE_BOOLEAN(allocation_counting_enabled);
|
294
|
+
ENFORCE_BOOLEAN(no_signals_workaround_enabled);
|
290
295
|
ENFORCE_BOOLEAN(dynamic_sampling_rate_enabled);
|
291
296
|
|
292
297
|
struct cpu_and_wall_time_worker_state *state;
|
@@ -294,6 +299,7 @@ static VALUE _native_initialize(
|
|
294
299
|
|
295
300
|
state->gc_profiling_enabled = (gc_profiling_enabled == Qtrue);
|
296
301
|
state->allocation_counting_enabled = (allocation_counting_enabled == Qtrue);
|
302
|
+
state->no_signals_workaround_enabled = (no_signals_workaround_enabled == Qtrue);
|
297
303
|
state->dynamic_sampling_rate_enabled = (dynamic_sampling_rate_enabled == Qtrue);
|
298
304
|
state->thread_context_collector_instance = enforce_thread_context_collector_instance(thread_context_collector_instance);
|
299
305
|
state->idle_sampling_helper_instance = idle_sampling_helper_instance;
|
@@ -439,7 +445,7 @@ static void handle_sampling_signal(DDTRACE_UNUSED int _signal, DDTRACE_UNUSED si
|
|
439
445
|
}
|
440
446
|
|
441
447
|
// We implicitly assume there can be no concurrent nor nested calls to handle_sampling_signal because
|
442
|
-
// a) we get triggered using SIGPROF, and the docs state second SIGPROF will not interrupt an existing one
|
448
|
+
// a) we get triggered using SIGPROF, and the docs state a second SIGPROF will not interrupt an existing one
|
443
449
|
// b) we validate we are in the thread that has the global VM lock; if a different thread gets a signal, it will return early
|
444
450
|
// because it will not have the global VM lock
|
445
451
|
|
@@ -476,22 +482,34 @@ static void *run_sampling_trigger_loop(void *state_ptr) {
|
|
476
482
|
while (atomic_load(&state->should_run)) {
|
477
483
|
state->stats.trigger_sample_attempts++;
|
478
484
|
|
479
|
-
|
480
|
-
|
481
|
-
//
|
482
|
-
//
|
483
|
-
//
|
484
|
-
pthread_kill(owner.owner, SIGPROF);
|
485
|
-
} else {
|
486
|
-
// If no thread owns the Global VM Lock, the application is probably idle at the moment. We still want to sample
|
487
|
-
// so we "ask a friend" (the IdleSamplingHelper component) to grab the GVL and simulate getting a SIGPROF.
|
485
|
+
if (state->no_signals_workaround_enabled) {
|
486
|
+
// In the no_signals_workaround_enabled mode, the profiler never sends SIGPROF signals.
|
487
|
+
//
|
488
|
+
// This is a fallback for a few incompatibilities and limitations -- see the code that decides when to enable
|
489
|
+
// `no_signals_workaround_enabled` in `Profiling::Component` for details.
|
488
490
|
//
|
489
|
-
//
|
490
|
-
//
|
491
|
-
// for an uncontrolled amount of time. (This can still happen to the IdleSamplingHelper, but the
|
492
|
-
// CpuAndWallTimeWorker will still be free to interrupt the Ruby VM and keep sampling for the entire blocking period).
|
491
|
+
// Thus, we instead pretty please ask Ruby to let us run. This means profiling data can be biased by when the Ruby
|
492
|
+
// scheduler chooses to schedule us.
|
493
493
|
state->stats.trigger_simulated_signal_delivery_attempts++;
|
494
|
-
|
494
|
+
grab_gvl_and_sample(); // Note: Can raise exceptions
|
495
|
+
} else {
|
496
|
+
current_gvl_owner owner = gvl_owner();
|
497
|
+
if (owner.valid) {
|
498
|
+
// Note that reading the GVL owner and sending them a signal is a race -- the Ruby VM keeps on executing while
|
499
|
+
// we're doing this, so we may still not signal the correct thread from time to time, but our signal handler
|
500
|
+
// includes a check to see if it got called in the right thread
|
501
|
+
pthread_kill(owner.owner, SIGPROF);
|
502
|
+
} else {
|
503
|
+
// If no thread owns the Global VM Lock, the application is probably idle at the moment. We still want to sample
|
504
|
+
// so we "ask a friend" (the IdleSamplingHelper component) to grab the GVL and simulate getting a SIGPROF.
|
505
|
+
//
|
506
|
+
// In a previous version of the code, we called `grab_gvl_and_sample` directly BUT this was problematic because
|
507
|
+
// Ruby may concurrently get busy and so the CpuAndWallTimeWorker would be blocked in line to acquire the GVL
|
508
|
+
// for an uncontrolled amount of time. (This can still happen to the IdleSamplingHelper, but the
|
509
|
+
// CpuAndWallTimeWorker will still be free to interrupt the Ruby VM and keep sampling for the entire blocking period).
|
510
|
+
state->stats.trigger_simulated_signal_delivery_attempts++;
|
511
|
+
idle_sampling_helper_request_action(state->idle_sampling_helper_instance, grab_gvl_and_sample);
|
512
|
+
}
|
495
513
|
}
|
496
514
|
|
497
515
|
sleep_for(minimum_time_between_signals);
|
@@ -81,7 +81,10 @@ end
|
|
81
81
|
|
82
82
|
# Because we can't control what compiler versions our customers use, shipping with -Werror by default is a no-go.
|
83
83
|
# But we can enable it in CI, so that we quickly spot any new warnings that just got introduced.
|
84
|
-
|
84
|
+
#
|
85
|
+
# @ivoanjo TODO: Ruby 3.3.0-preview1 was causing issues in CI because `have_header('vm_core.h')` below triggers warnings;
|
86
|
+
# I've chosen to disable `-Werror` for this Ruby version for now, and we can revisit this on a later 3.3 release.
|
87
|
+
add_compiler_flag '-Werror' if ENV['DDTRACE_CI'] == 'true' && !RUBY_DESCRIPTION.include?('3.3.0preview1')
|
85
88
|
|
86
89
|
# Older gcc releases may not default to C99 and we need to ask for this. This is also used:
|
87
90
|
# * by upstream Ruby -- search for gnu99 in the codebase
|
@@ -128,6 +131,12 @@ if RUBY_PLATFORM.include?('linux')
|
|
128
131
|
$defs << '-DHAVE_PTHREAD_GETCPUCLOCKID'
|
129
132
|
end
|
130
133
|
|
134
|
+
# On older Rubies, we did not need to include the ractor header (this was built into the MJIT header)
|
135
|
+
$defs << '-DNO_RACTOR_HEADER_INCLUDE' if RUBY_VERSION < '3.3'
|
136
|
+
|
137
|
+
# On older Rubies, some of the Ractor internal APIs were directly accessible
|
138
|
+
$defs << '-DUSE_RACTOR_INTERNAL_APIS_DIRECTLY' if RUBY_VERSION < '3.3'
|
139
|
+
|
131
140
|
# On older Rubies, there was no struct rb_native_thread. See private_vm_api_acccess.c for details.
|
132
141
|
$defs << '-DNO_RB_NATIVE_THREAD' if RUBY_VERSION < '3.2'
|
133
142
|
|
@@ -166,6 +175,8 @@ Logging.message("[ddtrace] PKG_CONFIG_PATH set to #{ENV['PKG_CONFIG_PATH'].inspe
|
|
166
175
|
$stderr.puts("Using libdatadog #{Libdatadog::VERSION} from #{Libdatadog.pkgconfig_folder}")
|
167
176
|
|
168
177
|
unless pkg_config('datadog_profiling_with_rpath')
|
178
|
+
Logging.message("[ddtrace] Ruby detected the pkg-config command is #{$PKGCONFIG.inspect}\n")
|
179
|
+
|
169
180
|
skip_building_extension!(
|
170
181
|
if Datadog::Profiling::NativeExtensionHelpers::Supported.pkg_config_missing?
|
171
182
|
Datadog::Profiling::NativeExtensionHelpers::Supported::PKG_CONFIG_IS_MISSING
|
@@ -217,7 +228,8 @@ if Datadog::Profiling::NativeExtensionHelpers::CAN_USE_MJIT_HEADER
|
|
217
228
|
|
218
229
|
create_makefile EXTENSION_NAME
|
219
230
|
else
|
220
|
-
#
|
231
|
+
# The MJIT header was introduced on 2.6 and removed on 3.3; for other Rubies we rely on
|
232
|
+
# the debase-ruby_core_source gem to get access to private VM headers.
|
221
233
|
# This gem ships source code copies of these VM headers for the different Ruby VM versions;
|
222
234
|
# see https://github.com/ruby-debug/debase-ruby_core_source for details
|
223
235
|
|
@@ -228,7 +240,11 @@ else
|
|
228
240
|
|
229
241
|
Debase::RubyCoreSource
|
230
242
|
.create_makefile_with_core(
|
231
|
-
proc
|
243
|
+
proc do
|
244
|
+
have_header('vm_core.h') &&
|
245
|
+
have_header('iseq.h') &&
|
246
|
+
(RUBY_VERSION < '3.3' || have_header('ractor_core.h'))
|
247
|
+
end,
|
232
248
|
EXTENSION_NAME,
|
233
249
|
)
|
234
250
|
end
|
@@ -12,8 +12,8 @@ module Datadog
|
|
12
12
|
# Can be set to force rubygems to fail gem installation when profiling extension could not be built
|
13
13
|
ENV_FAIL_INSTALL_IF_MISSING_EXTENSION = 'DD_PROFILING_FAIL_INSTALL_IF_MISSING_EXTENSION'
|
14
14
|
|
15
|
-
#
|
16
|
-
CAN_USE_MJIT_HEADER = RUBY_VERSION
|
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
|
+
CAN_USE_MJIT_HEADER = RUBY_VERSION.start_with?('2.6', '2.7', '3.0.', '3.1.', '3.2.')
|
17
17
|
|
18
18
|
LIBDATADOG_VERSION = '~> 2.0.0.1.0'
|
19
19
|
|
@@ -12,7 +12,8 @@
|
|
12
12
|
// Pick up internal structures from the private Ruby MJIT header file
|
13
13
|
#include RUBY_MJIT_HEADER
|
14
14
|
#else
|
15
|
-
//
|
15
|
+
// The MJIT header was introduced on 2.6 and removed on 3.3; for other Rubies we rely on
|
16
|
+
// the debase-ruby_core_source gem to get access to private VM headers.
|
16
17
|
|
17
18
|
// We can't do anything about warnings in VM headers, so we just use this technique to suppress them.
|
18
19
|
// See https://nelkinda.com/blog/suppress-warnings-in-gcc-and-clang/#d11e364 for details.
|
@@ -23,7 +24,20 @@
|
|
23
24
|
#pragma GCC diagnostic ignored "-Wexpansion-to-defined"
|
24
25
|
#include <vm_core.h>
|
25
26
|
#pragma GCC diagnostic pop
|
26
|
-
|
27
|
+
|
28
|
+
#pragma GCC diagnostic push
|
29
|
+
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
30
|
+
#include <iseq.h>
|
31
|
+
#pragma GCC diagnostic pop
|
32
|
+
|
33
|
+
#include <ruby.h>
|
34
|
+
|
35
|
+
#ifndef NO_RACTOR_HEADER_INCLUDE
|
36
|
+
#pragma GCC diagnostic push
|
37
|
+
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
38
|
+
#include <ractor_core.h>
|
39
|
+
#pragma GCC diagnostic pop
|
40
|
+
#endif
|
27
41
|
#endif
|
28
42
|
|
29
43
|
#define PRIVATE_VM_API_ACCESS_SKIP_RUBY_INCLUDES
|
@@ -712,8 +726,28 @@ check_method_entry(VALUE obj, int can_be_svar)
|
|
712
726
|
#ifndef NO_RACTORS
|
713
727
|
// This API and definition are exported as a public symbol by the VM BUT the function header is not defined in any public header, so we
|
714
728
|
// repeat it here to be able to use in our code.
|
715
|
-
|
716
|
-
|
729
|
+
#ifndef USE_RACTOR_INTERNAL_APIS_DIRECTLY
|
730
|
+
// Disable fast path for detecting multiple Ractors. Unfortunately this symbol is no longer visible on modern Ruby
|
731
|
+
// versions, so we need to do a bit more work.
|
732
|
+
struct rb_ractor_struct *ruby_single_main_ractor = NULL;
|
733
|
+
|
734
|
+
// Taken from upstream ractor.c at commit a1b01e7701f9fc370f8dff777aad6d39a2c5a3e3 (May 2023, Ruby 3.3.0-preview1)
|
735
|
+
// to allow us to ensure that we're always operating on the main ractor (if Ruby has ractors)
|
736
|
+
// Modifications:
|
737
|
+
// * None
|
738
|
+
bool rb_ractor_main_p_(void)
|
739
|
+
{
|
740
|
+
VM_ASSERT(rb_multi_ractor_p());
|
741
|
+
rb_execution_context_t *ec = GET_EC();
|
742
|
+
return rb_ec_ractor_ptr(ec) == rb_ec_vm_ptr(ec)->ractor.main_ractor;
|
743
|
+
}
|
744
|
+
#else
|
745
|
+
// Directly access Ruby internal fast path for detecting multiple Ractors.
|
746
|
+
extern struct rb_ractor_struct *ruby_single_main_ractor;
|
747
|
+
|
748
|
+
// Ruby 3.0 to 3.2 directly expose this symbol, we just need to tell the compiler it exists.
|
749
|
+
bool rb_ractor_main_p_(void);
|
750
|
+
#endif
|
717
751
|
|
718
752
|
// Taken from upstream ractor_core.h at commit d9cf0388599a3234b9f3c06ddd006cd59a58ab8b (November 2022, Ruby 3.2 trunk)
|
719
753
|
// to allow us to ensure that we're always operating on the main ractor (if Ruby has ractors)
|