ddtrace 1.6.1 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +89 -2
- data/README.md +2 -2
- data/ext/ddtrace_profiling_loader/extconf.rb +5 -2
- data/ext/ddtrace_profiling_native_extension/NativeExtensionDesign.md +1 -1
- data/ext/ddtrace_profiling_native_extension/clock_id_from_pthread.c +3 -2
- data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time.c +81 -47
- data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time.h +1 -1
- data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +332 -125
- data/ext/ddtrace_profiling_native_extension/collectors_dynamic_sampling_rate.c +142 -0
- data/ext/ddtrace_profiling_native_extension/collectors_dynamic_sampling_rate.h +14 -0
- data/ext/ddtrace_profiling_native_extension/collectors_idle_sampling_helper.c +241 -0
- data/ext/ddtrace_profiling_native_extension/collectors_idle_sampling_helper.h +3 -0
- data/ext/ddtrace_profiling_native_extension/collectors_stack.c +11 -13
- data/ext/ddtrace_profiling_native_extension/extconf.rb +22 -8
- data/ext/ddtrace_profiling_native_extension/helpers.h +5 -0
- data/ext/ddtrace_profiling_native_extension/native_extension_helpers.rb +8 -0
- data/ext/ddtrace_profiling_native_extension/private_vm_api_access.c +111 -26
- data/ext/ddtrace_profiling_native_extension/private_vm_api_access.h +9 -0
- data/ext/ddtrace_profiling_native_extension/profiling.c +205 -0
- data/ext/ddtrace_profiling_native_extension/ruby_helpers.c +86 -0
- data/ext/ddtrace_profiling_native_extension/ruby_helpers.h +28 -6
- data/ext/ddtrace_profiling_native_extension/setup_signal_handler.c +115 -0
- data/ext/ddtrace_profiling_native_extension/setup_signal_handler.h +11 -0
- data/ext/ddtrace_profiling_native_extension/stack_recorder.c +84 -35
- data/ext/ddtrace_profiling_native_extension/stack_recorder.h +1 -0
- data/ext/ddtrace_profiling_native_extension/time_helpers.c +17 -0
- data/ext/ddtrace_profiling_native_extension/time_helpers.h +10 -0
- data/lib/datadog/appsec/assets/blocked.html +98 -3
- data/lib/datadog/appsec/assets/blocked.json +1 -0
- data/lib/datadog/appsec/assets/blocked.text +5 -0
- data/lib/datadog/appsec/assets/waf_rules/recommended.json +35 -46
- data/lib/datadog/appsec/assets/waf_rules/risky.json +1 -1
- data/lib/datadog/appsec/assets/waf_rules/strict.json +46 -1
- data/lib/datadog/appsec/assets.rb +2 -2
- data/lib/datadog/appsec/configuration/settings.rb +6 -0
- data/lib/datadog/appsec/configuration.rb +4 -0
- data/lib/datadog/appsec/contrib/rack/reactive/request.rb +4 -8
- data/lib/datadog/appsec/contrib/rack/request.rb +17 -0
- data/lib/datadog/appsec/contrib/rack/request_body_middleware.rb +2 -2
- data/lib/datadog/appsec/contrib/rack/request_middleware.rb +2 -2
- data/lib/datadog/appsec/contrib/rails/patcher.rb +3 -6
- data/lib/datadog/appsec/contrib/sinatra/ext.rb +1 -0
- data/lib/datadog/appsec/contrib/sinatra/gateway/watcher.rb +1 -1
- data/lib/datadog/appsec/contrib/sinatra/patcher.rb +11 -8
- data/lib/datadog/appsec/extensions.rb +10 -0
- data/lib/datadog/appsec/processor.rb +18 -0
- data/lib/datadog/appsec/response.rb +54 -0
- data/lib/datadog/core/configuration/components.rb +27 -6
- data/lib/datadog/core/configuration/ext.rb +18 -0
- data/lib/datadog/core/configuration/settings.rb +14 -341
- data/lib/datadog/core/diagnostics/health.rb +4 -22
- data/lib/datadog/core/environment/variable_helpers.rb +58 -10
- data/lib/datadog/core/runtime/ext.rb +1 -1
- data/lib/datadog/core/utils.rb +0 -21
- data/lib/datadog/core.rb +21 -1
- data/lib/datadog/opentracer/distributed_headers.rb +7 -9
- data/lib/datadog/opentracer/rack_propagator.rb +0 -3
- data/lib/datadog/opentracer/text_map_propagator.rb +5 -7
- data/lib/datadog/profiling/collectors/cpu_and_wall_time.rb +10 -4
- data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +20 -5
- data/lib/datadog/profiling/collectors/dynamic_sampling_rate.rb +14 -0
- data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +68 -0
- data/lib/datadog/profiling/collectors/old_stack.rb +7 -0
- data/lib/datadog/profiling/exporter.rb +5 -0
- data/lib/datadog/profiling/old_recorder.rb +8 -0
- data/lib/datadog/profiling/profiler.rb +7 -0
- data/lib/datadog/profiling/scheduler.rb +4 -7
- data/lib/datadog/profiling/stack_recorder.rb +36 -0
- data/lib/datadog/profiling/tasks/setup.rb +0 -7
- data/lib/datadog/profiling.rb +2 -0
- data/lib/datadog/tracing/configuration/ext.rb +33 -3
- data/lib/datadog/tracing/configuration/settings.rb +433 -0
- data/lib/datadog/tracing/contrib/aws/configuration/settings.rb +4 -1
- data/lib/datadog/tracing/contrib/aws/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/dalli/configuration/settings.rb +4 -1
- data/lib/datadog/tracing/contrib/dalli/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/delayed_job/plugin.rb +4 -0
- data/lib/datadog/tracing/contrib/elasticsearch/configuration/settings.rb +5 -1
- data/lib/datadog/tracing/contrib/elasticsearch/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/ethon/configuration/settings.rb +6 -1
- data/lib/datadog/tracing/contrib/ethon/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/excon/configuration/settings.rb +5 -1
- data/lib/datadog/tracing/contrib/excon/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/faraday/configuration/settings.rb +5 -1
- data/lib/datadog/tracing/contrib/faraday/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/grpc/configuration/settings.rb +6 -1
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb +2 -1
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/server.rb +6 -12
- data/lib/datadog/tracing/contrib/grpc/distributed/fetcher.rb +27 -0
- data/lib/datadog/tracing/contrib/grpc/distributed/propagation.rb +43 -0
- data/lib/datadog/tracing/contrib/grpc/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/grpc/patcher.rb +0 -2
- data/lib/datadog/tracing/contrib/http/configuration/settings.rb +6 -1
- data/lib/datadog/tracing/contrib/http/distributed/fetcher.rb +32 -0
- data/lib/datadog/tracing/contrib/http/distributed/propagation.rb +38 -0
- data/lib/datadog/tracing/contrib/http/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/httpclient/configuration/settings.rb +6 -1
- data/lib/datadog/tracing/contrib/httpclient/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/httprb/configuration/settings.rb +6 -1
- data/lib/datadog/tracing/contrib/httprb/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/kafka/consumer_event.rb +1 -0
- data/lib/datadog/tracing/contrib/kafka/events/produce_operation/send_messages.rb +1 -0
- data/lib/datadog/tracing/contrib/kafka/events/producer/deliver_messages.rb +1 -0
- data/lib/datadog/tracing/contrib/mongodb/configuration/settings.rb +5 -1
- data/lib/datadog/tracing/contrib/mongodb/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/mongodb/subscribers.rb +2 -0
- data/lib/datadog/tracing/contrib/mysql2/configuration/settings.rb +4 -1
- data/lib/datadog/tracing/contrib/mysql2/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +2 -2
- data/lib/datadog/tracing/contrib/patcher.rb +3 -2
- data/lib/datadog/tracing/contrib/pg/configuration/settings.rb +4 -1
- data/lib/datadog/tracing/contrib/pg/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/pg/instrumentation.rb +12 -2
- data/lib/datadog/tracing/contrib/presto/configuration/settings.rb +4 -1
- data/lib/datadog/tracing/contrib/presto/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/propagation/sql_comment/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/propagation/sql_comment.rb +10 -12
- data/lib/datadog/tracing/contrib/que/tracer.rb +2 -0
- data/lib/datadog/tracing/contrib/racecar/events/batch.rb +4 -1
- data/lib/datadog/tracing/contrib/racecar/events/message.rb +4 -1
- data/lib/datadog/tracing/contrib/rack/middlewares.rb +2 -0
- data/lib/datadog/tracing/contrib/redis/configuration/settings.rb +4 -1
- data/lib/datadog/tracing/contrib/redis/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/redis/instrumentation.rb +30 -21
- data/lib/datadog/tracing/contrib/redis/integration.rb +34 -2
- data/lib/datadog/tracing/contrib/redis/patcher.rb +18 -14
- data/lib/datadog/tracing/contrib/redis/quantize.rb +12 -9
- data/lib/datadog/tracing/contrib/redis/tags.rb +4 -6
- data/lib/datadog/tracing/contrib/redis/trace_middleware.rb +72 -0
- data/lib/datadog/tracing/contrib/resque/resque_job.rb +2 -0
- data/lib/datadog/tracing/contrib/rest_client/configuration/settings.rb +6 -1
- data/lib/datadog/tracing/contrib/rest_client/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/shoryuken/tracer.rb +2 -0
- data/lib/datadog/tracing/contrib/sidekiq/client_tracer.rb +5 -0
- data/lib/datadog/tracing/contrib/sidekiq/server_tracer.rb +5 -0
- data/lib/datadog/tracing/contrib/sneakers/tracer.rb +2 -0
- data/lib/datadog/{core → tracing}/diagnostics/ext.rb +1 -6
- data/lib/datadog/tracing/diagnostics/health.rb +40 -0
- data/lib/datadog/tracing/distributed/b3_multi.rb +66 -0
- data/lib/datadog/tracing/distributed/b3_single.rb +66 -0
- data/lib/datadog/tracing/distributed/datadog.rb +153 -0
- data/lib/datadog/tracing/distributed/datadog_tags_codec.rb +1 -0
- data/lib/datadog/tracing/distributed/fetcher.rb +30 -0
- data/lib/datadog/tracing/distributed/headers/ext.rb +18 -16
- data/lib/datadog/tracing/distributed/helpers.rb +9 -7
- data/lib/datadog/tracing/distributed/none.rb +19 -0
- data/lib/datadog/tracing/distributed/propagation.rb +127 -0
- data/lib/datadog/tracing/distributed/trace_context.rb +369 -0
- data/lib/datadog/tracing/metadata/ext.rb +1 -1
- data/lib/datadog/tracing/propagation/http.rb +3 -106
- data/lib/datadog/tracing/sampling/priority_sampler.rb +11 -0
- data/lib/datadog/tracing/sampling/rate_sampler.rb +3 -3
- data/lib/datadog/tracing/span.rb +3 -19
- data/lib/datadog/tracing/span_operation.rb +5 -4
- data/lib/datadog/tracing/trace_digest.rb +75 -2
- data/lib/datadog/tracing/trace_operation.rb +5 -4
- data/lib/datadog/tracing/trace_segment.rb +1 -1
- data/lib/datadog/tracing/utils.rb +50 -0
- data/lib/ddtrace/transport/trace_formatter.rb +2 -5
- data/lib/ddtrace/version.rb +2 -2
- metadata +35 -15
- data/lib/datadog/tracing/distributed/headers/b3.rb +0 -55
- data/lib/datadog/tracing/distributed/headers/b3_single.rb +0 -67
- data/lib/datadog/tracing/distributed/headers/datadog.rb +0 -144
- data/lib/datadog/tracing/distributed/headers/parser.rb +0 -37
- data/lib/datadog/tracing/distributed/metadata/b3.rb +0 -55
- data/lib/datadog/tracing/distributed/metadata/b3_single.rb +0 -66
- data/lib/datadog/tracing/distributed/metadata/datadog.rb +0 -73
- data/lib/datadog/tracing/distributed/metadata/parser.rb +0 -34
- data/lib/datadog/tracing/propagation/grpc.rb +0 -98
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '02285d37473e8fe6c731e55ae7864860a311e2b6d509f56a41f31094cd198f09'
|
4
|
+
data.tar.gz: 8857a0f43f96fef23309cd7fced88b846d5ad48834b6c87d0f40181cc3bd5dd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afcde0e01258f5ab997fa6bcfa51c29a82f0e730258056a9efae86130445dbd63471269c047878b1ee554cc4ec956fe6e95a597ce65930e73549b0e32cbec50c
|
7
|
+
data.tar.gz: 292867c7c22146d0bd3147bb8863dd51fc89200a08efe640f05ae053fb93bdaeb068eefb6c89466b40ebbe749174844aa6b874c5a2b6aae30cb5055c9f2dc3cd
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,58 @@
|
|
2
2
|
|
3
3
|
## [Unreleased]
|
4
4
|
|
5
|
+
## [1.8.0] - 2022-12-14
|
6
|
+
|
7
|
+
Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v1.8.0
|
8
|
+
|
9
|
+
As of ddtrace 1.8.0, CPU Profiling 2.0 is now in opt-in (that is, disabled by default) public beta. For more details,
|
10
|
+
check the release notes.
|
11
|
+
|
12
|
+
### Added
|
13
|
+
|
14
|
+
* Core: Profiling: [PROF-6559] Mark Ruby CPU Profiling 2.0 as being in beta ([#2489][])
|
15
|
+
* Tracing: Attempt to parse future version of TraceContext ([#2473][])
|
16
|
+
* Tracing: Add DD_TRACE_PROPAGATION_STYLE option ([#2466][])
|
17
|
+
* Integrations: Tracing: SQL comment propagation full mode with traceparent ([#2464][])
|
18
|
+
* Integrations: Tracing: Wire W3C propagator to HTTP & gRPC propagation ([#2458][])
|
19
|
+
* Integrations: Tracing: Auto-instrumentation with service_name from environmental variable ([#2455][])
|
20
|
+
* Core: Integrations: Tracing: Deprecation notice for B3 propagation configuration ([#2454][])
|
21
|
+
* Tracing: Add W3C Trace Context propagator ([#2451][])
|
22
|
+
* Integrations: Tracing: Redis 5 Instrumentation ([#2428][])
|
23
|
+
|
24
|
+
### Changed
|
25
|
+
|
26
|
+
* Tracing: Changes `error.msg` to `error.message` for UNC ([#2469][])
|
27
|
+
* Tracing: Semicolons not allowed in 'origin' ([#2461][])
|
28
|
+
* Core: Dev/refactor: Tracing: Dev/internal: Move Utils#next_id and constants to Tracing::Utils ([#2463][])
|
29
|
+
* Core: Dev/refactor: Tracing: Dev/internal: Move Tracing config settings from Core to Tracing ([#2459][])
|
30
|
+
* Core: Dev/refactor: Tracing: Dev/internal: Move Tracing diagnostic code from Core to Tracing ([#2453][])
|
31
|
+
|
32
|
+
### Fixed
|
33
|
+
|
34
|
+
* Integrations: Tracing: Improve redis integration patching ([#2470][])
|
35
|
+
* Tracing: Extra testing from W3C spec ([#2460][])
|
36
|
+
|
37
|
+
## [1.7.0] - 2022-11-29
|
38
|
+
|
39
|
+
### Added
|
40
|
+
* Integrations: Support que 2 ([#2382][]) ([@danhodge][])
|
41
|
+
* Tracing: Unified tagging `span.kind` as `server` and `client` ([#2365][])
|
42
|
+
* Tracing: Adds `span.kind` tag for `kafka`, `sidekiq`, `racecar`, `que`, `shoryuken`, `sneakers`, and `resque` ([#2420][], [#2419][], [#2413][], [#2394][])
|
43
|
+
* Tracing: Adds `span.kind` with values `producer` and `consumer` for `delayed_job` ([#2393][])
|
44
|
+
* Tracing: Adds `span.kind` as `client` for `redis` ([#2392][])
|
45
|
+
* Appsec: Pass HTTP client IP to WAF ([#2316][])
|
46
|
+
* Unified tagging `process_id` ([#2276][])
|
47
|
+
|
48
|
+
### Changed
|
49
|
+
* Allow `debase-ruby_core_source` 0.10.18 to be used ([#2435][])
|
50
|
+
* Update AppSec ruleset to v1.4.2 ([#2390][])
|
51
|
+
* Refactored clearing of profile data after Ruby app forks ([#2362][], [#2367][])
|
52
|
+
* Tracing: Move distributed propagation to Contrib ([#2352][])
|
53
|
+
|
54
|
+
### Fixed
|
55
|
+
* Fix ddtrace installation issue when users have CI=true ([#2378][])
|
56
|
+
|
5
57
|
## [1.6.1] - 2022-11-16
|
6
58
|
|
7
59
|
### Changed
|
@@ -2198,7 +2250,9 @@ Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.3.1
|
|
2198
2250
|
|
2199
2251
|
Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
|
2200
2252
|
|
2201
|
-
[Unreleased]: https://github.com/DataDog/dd-trace-rb/compare/v1.
|
2253
|
+
[Unreleased]: https://github.com/DataDog/dd-trace-rb/compare/v1.8.0...master
|
2254
|
+
[1.8.0]: https://github.com/DataDog/dd-trace-rb/compare/v1.7.0...v1.8.0
|
2255
|
+
[1.7.0]: https://github.com/DataDog/dd-trace-rb/compare/v1.6.1...v1.7.0
|
2202
2256
|
[1.6.1]: https://github.com/DataDog/dd-trace-rb/compare/v1.6.0...v1.6.1
|
2203
2257
|
[1.6.0]: https://github.com/DataDog/dd-trace-rb/compare/v1.5.2...v1.6.0
|
2204
2258
|
[1.5.2]: https://github.com/DataDog/dd-trace-rb/compare/v1.5.1...v1.5.2
|
@@ -3102,6 +3156,7 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
|
|
3102
3156
|
[#2260]: https://github.com/DataDog/dd-trace-rb/issues/2260
|
3103
3157
|
[#2265]: https://github.com/DataDog/dd-trace-rb/issues/2265
|
3104
3158
|
[#2267]: https://github.com/DataDog/dd-trace-rb/issues/2267
|
3159
|
+
[#2276]: https://github.com/DataDog/dd-trace-rb/issues/2276
|
3105
3160
|
[#2279]: https://github.com/DataDog/dd-trace-rb/issues/2279
|
3106
3161
|
[#2283]: https://github.com/DataDog/dd-trace-rb/issues/2283
|
3107
3162
|
[#2289]: https://github.com/DataDog/dd-trace-rb/issues/2289
|
@@ -3114,6 +3169,7 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
|
|
3114
3169
|
[#2310]: https://github.com/DataDog/dd-trace-rb/issues/2310
|
3115
3170
|
[#2311]: https://github.com/DataDog/dd-trace-rb/issues/2311
|
3116
3171
|
[#2313]: https://github.com/DataDog/dd-trace-rb/issues/2313
|
3172
|
+
[#2316]: https://github.com/DataDog/dd-trace-rb/issues/2316
|
3117
3173
|
[#2317]: https://github.com/DataDog/dd-trace-rb/issues/2317
|
3118
3174
|
[#2318]: https://github.com/DataDog/dd-trace-rb/issues/2318
|
3119
3175
|
[#2319]: https://github.com/DataDog/dd-trace-rb/issues/2319
|
@@ -3124,7 +3180,37 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
|
|
3124
3180
|
[#2331]: https://github.com/DataDog/dd-trace-rb/issues/2331
|
3125
3181
|
[#2335]: https://github.com/DataDog/dd-trace-rb/issues/2335
|
3126
3182
|
[#2339]: https://github.com/DataDog/dd-trace-rb/issues/2339
|
3183
|
+
[#2352]: https://github.com/DataDog/dd-trace-rb/issues/2352
|
3184
|
+
[#2362]: https://github.com/DataDog/dd-trace-rb/issues/2362
|
3127
3185
|
[#2363]: https://github.com/DataDog/dd-trace-rb/issues/2363
|
3186
|
+
[#2365]: https://github.com/DataDog/dd-trace-rb/issues/2365
|
3187
|
+
[#2367]: https://github.com/DataDog/dd-trace-rb/issues/2367
|
3188
|
+
[#2378]: https://github.com/DataDog/dd-trace-rb/issues/2378
|
3189
|
+
[#2382]: https://github.com/DataDog/dd-trace-rb/issues/2382
|
3190
|
+
[#2390]: https://github.com/DataDog/dd-trace-rb/issues/2390
|
3191
|
+
[#2392]: https://github.com/DataDog/dd-trace-rb/issues/2392
|
3192
|
+
[#2393]: https://github.com/DataDog/dd-trace-rb/issues/2393
|
3193
|
+
[#2394]: https://github.com/DataDog/dd-trace-rb/issues/2394
|
3194
|
+
[#2413]: https://github.com/DataDog/dd-trace-rb/issues/2413
|
3195
|
+
[#2419]: https://github.com/DataDog/dd-trace-rb/issues/2419
|
3196
|
+
[#2420]: https://github.com/DataDog/dd-trace-rb/issues/2420
|
3197
|
+
[#2428]: https://github.com/DataDog/dd-trace-rb/issues/2428
|
3198
|
+
[#2435]: https://github.com/DataDog/dd-trace-rb/issues/2435
|
3199
|
+
[#2451]: https://github.com/DataDog/dd-trace-rb/issues/2451
|
3200
|
+
[#2453]: https://github.com/DataDog/dd-trace-rb/issues/2453
|
3201
|
+
[#2454]: https://github.com/DataDog/dd-trace-rb/issues/2454
|
3202
|
+
[#2455]: https://github.com/DataDog/dd-trace-rb/issues/2455
|
3203
|
+
[#2458]: https://github.com/DataDog/dd-trace-rb/issues/2458
|
3204
|
+
[#2459]: https://github.com/DataDog/dd-trace-rb/issues/2459
|
3205
|
+
[#2460]: https://github.com/DataDog/dd-trace-rb/issues/2460
|
3206
|
+
[#2461]: https://github.com/DataDog/dd-trace-rb/issues/2461
|
3207
|
+
[#2463]: https://github.com/DataDog/dd-trace-rb/issues/2463
|
3208
|
+
[#2464]: https://github.com/DataDog/dd-trace-rb/issues/2464
|
3209
|
+
[#2466]: https://github.com/DataDog/dd-trace-rb/issues/2466
|
3210
|
+
[#2469]: https://github.com/DataDog/dd-trace-rb/issues/2469
|
3211
|
+
[#2470]: https://github.com/DataDog/dd-trace-rb/issues/2470
|
3212
|
+
[#2473]: https://github.com/DataDog/dd-trace-rb/issues/2473
|
3213
|
+
[#2489]: https://github.com/DataDog/dd-trace-rb/issues/2489
|
3128
3214
|
[@AdrianLC]: https://github.com/AdrianLC
|
3129
3215
|
[@Azure7111]: https://github.com/Azure7111
|
3130
3216
|
[@BabyGroot]: https://github.com/BabyGroot
|
@@ -3170,6 +3256,7 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
|
|
3170
3256
|
[@components]: https://github.com/components
|
3171
3257
|
[@cswatt]: https://github.com/cswatt
|
3172
3258
|
[@cwoodcox]: https://github.com/cwoodcox
|
3259
|
+
[@danhodge]: https://github.com/danhodge
|
3173
3260
|
[@dasch]: https://github.com/dasch
|
3174
3261
|
[@dim]: https://github.com/dim
|
3175
3262
|
[@dirk]: https://github.com/dirk
|
@@ -3268,4 +3355,4 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
|
|
3268
3355
|
[@y-yagi]: https://github.com/y-yagi
|
3269
3356
|
[@yujideveloper]: https://github.com/yujideveloper
|
3270
3357
|
[@yukimurasawa]: https://github.com/yukimurasawa
|
3271
|
-
[@zachmccormick]: https://github.com/zachmccormick
|
3358
|
+
[@zachmccormick]: https://github.com/zachmccormick
|
data/README.md
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
**We've recently released the 1.x version series. If you're upgrading from a 0.x version, check out our [upgrade guide](https://github.com/DataDog/dd-trace-rb/blob/master/docs/UpgradeGuide.md#from-0x-to-10).**
|
2
|
-
|
3
1
|
# Datadog Trace Client
|
4
2
|
|
5
3
|
[![Gem](https://img.shields.io/gem/v/ddtrace)](https://rubygems.org/gems/ddtrace/)
|
@@ -12,6 +10,8 @@ databases and microservices so that developers have great visiblity into bottlen
|
|
12
10
|
|
13
11
|
## Getting started
|
14
12
|
|
13
|
+
**If you're upgrading from a 0.x version, check out our [upgrade guide](https://github.com/DataDog/dd-trace-rb/blob/master/docs/UpgradeGuide.md#from-0x-to-10).**
|
14
|
+
|
15
15
|
For a basic product overview, check out our [setup documentation][setup docs].
|
16
16
|
|
17
17
|
For installation, configuration, and details about using the API, check out our [API documentation][api docs] and [gem documentation][gem docs].
|
@@ -26,7 +26,7 @@ end
|
|
26
26
|
|
27
27
|
# Because we can't control what compiler versions our customers use, shipping with -Werror by default is a no-go.
|
28
28
|
# But we can enable it in CI, so that we quickly spot any new warnings that just got introduced.
|
29
|
-
add_compiler_flag '-Werror' if ENV['
|
29
|
+
add_compiler_flag '-Werror' if ENV['DDTRACE_CI'] == 'true'
|
30
30
|
|
31
31
|
# Older gcc releases may not default to C99 and we need to ask for this. This is also used:
|
32
32
|
# * by upstream Ruby -- search for gnu99 in the codebase
|
@@ -34,7 +34,7 @@ add_compiler_flag '-Werror' if ENV['CI'] == 'true'
|
|
34
34
|
# (https://github.com/msgpack/msgpack-ruby/blob/18ce08f6d612fe973843c366ac9a0b74c4e50599/ext/msgpack/extconf.rb#L8)
|
35
35
|
add_compiler_flag '-std=gnu99'
|
36
36
|
|
37
|
-
# Gets really noisy when we include the MJIT header, let's omit it
|
37
|
+
# Gets really noisy when we include the MJIT header, let's omit it (TODO: Use #pragma GCC diagnostic instead?)
|
38
38
|
add_compiler_flag '-Wno-unused-function'
|
39
39
|
|
40
40
|
# Allow defining variables at any point in a function
|
@@ -55,6 +55,9 @@ add_compiler_flag '-Wunused-parameter'
|
|
55
55
|
# For more details see https://gcc.gnu.org/wiki/Visibility
|
56
56
|
add_compiler_flag '-fvisibility=hidden'
|
57
57
|
|
58
|
+
# Avoid legacy C definitions
|
59
|
+
add_compiler_flag '-Wold-style-definition'
|
60
|
+
|
58
61
|
# Enable all other compiler warnings
|
59
62
|
add_compiler_flag '-Wall'
|
60
63
|
add_compiler_flag '-Wextra'
|
@@ -57,7 +57,7 @@ Non-exhaustive list of APIs that cause exceptions to be raised:
|
|
57
57
|
|
58
58
|
* `Check_TypedStruct`, `Check_Type`, `ENFORCE_TYPE`
|
59
59
|
* `rb_funcall`
|
60
|
-
* `rb_thread_call_without_gvl
|
60
|
+
* `rb_thread_call_without_gvl`
|
61
61
|
* [Numeric conversion APIs, e.g. `NUM2LONG`, `NUM2INT`, etc.](https://silverhammermba.github.io/emberb/c/?#translation)
|
62
62
|
* Our `char_slice_from_ruby_string` helper
|
63
63
|
|
@@ -7,11 +7,12 @@
|
|
7
7
|
#include <pthread.h>
|
8
8
|
#include <time.h>
|
9
9
|
#include <errno.h>
|
10
|
-
|
11
10
|
#include <ruby.h>
|
11
|
+
|
12
12
|
#include "helpers.h"
|
13
13
|
#include "private_vm_api_access.h"
|
14
14
|
#include "clock_id.h"
|
15
|
+
#include "time_helpers.h"
|
15
16
|
|
16
17
|
// Validate that our home-cooked pthread_id_for() matches pthread_self() for the current thread
|
17
18
|
void self_test_clock_id(void) {
|
@@ -68,7 +69,7 @@ thread_cpu_time thread_cpu_time_for(thread_cpu_time_id time_id) {
|
|
68
69
|
// TODO: Include the error code in some way in the output?
|
69
70
|
if (clock_gettime(time_id.clock_id, ¤t_cpu) != 0) return error;
|
70
71
|
|
71
|
-
return (thread_cpu_time) {.valid = true, .result_ns = current_cpu.tv_nsec + (current_cpu.tv_sec
|
72
|
+
return (thread_cpu_time) {.valid = true, .result_ns = current_cpu.tv_nsec + SECONDS_AS_NS(current_cpu.tv_sec)};
|
72
73
|
}
|
73
74
|
|
74
75
|
#endif
|
@@ -1,11 +1,13 @@
|
|
1
1
|
#include <ruby.h>
|
2
|
-
|
2
|
+
|
3
3
|
#include "clock_id.h"
|
4
|
+
#include "collectors_cpu_and_wall_time.h"
|
4
5
|
#include "collectors_stack.h"
|
6
|
+
#include "helpers.h"
|
5
7
|
#include "libdatadog_helpers.h"
|
6
8
|
#include "private_vm_api_access.h"
|
7
9
|
#include "stack_recorder.h"
|
8
|
-
#include "
|
10
|
+
#include "time_helpers.h"
|
9
11
|
|
10
12
|
// Used to periodically sample threads, recording elapsed CPU-time and Wall-time between samples.
|
11
13
|
//
|
@@ -60,16 +62,16 @@
|
|
60
62
|
|
61
63
|
#define INVALID_TIME -1
|
62
64
|
#define THREAD_ID_LIMIT_CHARS 44 // Why 44? "#{2**64} (#{2**64})".size + 1 for \0
|
63
|
-
#define RAISE_ON_FAILURE true
|
64
|
-
#define DO_NOT_RAISE_ON_FAILURE false
|
65
65
|
#define IS_WALL_TIME true
|
66
66
|
#define IS_NOT_WALL_TIME false
|
67
67
|
#define MISSING_TRACER_CONTEXT_KEY 0
|
68
68
|
|
69
|
-
static ID at_active_trace_id; // id of :@active_trace in Ruby
|
70
|
-
static ID at_root_span_id; // id of :@root_span in Ruby
|
71
69
|
static ID at_active_span_id; // id of :@active_span in Ruby
|
70
|
+
static ID at_active_trace_id; // id of :@active_trace in Ruby
|
72
71
|
static ID at_id_id; // id of :@id in Ruby
|
72
|
+
static ID at_resource_id; // id of :@resource in Ruby
|
73
|
+
static ID at_root_span_id; // id of :@root_span in Ruby
|
74
|
+
static ID at_type_id; // id of :@type in Ruby
|
73
75
|
|
74
76
|
// Contains state for a single CpuAndWallTime instance
|
75
77
|
struct cpu_and_wall_time_collector_state {
|
@@ -91,7 +93,7 @@ struct cpu_and_wall_time_collector_state {
|
|
91
93
|
// is not (just) a stat.
|
92
94
|
unsigned int sample_count;
|
93
95
|
|
94
|
-
struct {
|
96
|
+
struct stats {
|
95
97
|
// Track how many garbage collection samples we've taken.
|
96
98
|
unsigned int gc_samples;
|
97
99
|
// See cpu_and_wall_time_collector_on_gc_start for details
|
@@ -126,9 +128,9 @@ struct trace_identifiers {
|
|
126
128
|
|
127
129
|
bool valid;
|
128
130
|
ddog_CharSlice local_root_span_id;
|
129
|
-
|
131
|
+
uint64_t span_id;
|
130
132
|
char local_root_span_id_buffer[MAXIMUM_LENGTH_64_BIT_IDENTIFIER];
|
131
|
-
|
133
|
+
VALUE trace_endpoint;
|
132
134
|
};
|
133
135
|
|
134
136
|
static void cpu_and_wall_time_collector_typed_data_mark(void *state_ptr);
|
@@ -161,10 +163,11 @@ static int remove_if_dead_thread(st_data_t key_thread, st_data_t value_context,
|
|
161
163
|
static VALUE _native_per_thread_context(VALUE self, VALUE collector_instance);
|
162
164
|
static long update_time_since_previous_sample(long *time_at_previous_sample_ns, long current_time_ns, long gc_start_time_ns, bool is_wall_time);
|
163
165
|
static long cpu_time_now_ns(struct per_thread_context *thread_context);
|
164
|
-
static long wall_time_now_ns(bool raise_on_failure);
|
165
166
|
static long thread_id_for(VALUE thread);
|
166
167
|
static VALUE _native_stats(VALUE self, VALUE collector_instance);
|
167
168
|
static void trace_identifiers_for(struct cpu_and_wall_time_collector_state *state, VALUE thread, struct trace_identifiers *trace_identifiers_result);
|
169
|
+
static bool is_type_web(VALUE root_span_type);
|
170
|
+
static VALUE _native_reset_after_fork(DDTRACE_UNUSED VALUE self, VALUE collector_instance);
|
168
171
|
|
169
172
|
void collectors_cpu_and_wall_time_init(VALUE profiling_module) {
|
170
173
|
VALUE collectors_module = rb_define_module_under(profiling_module, "Collectors");
|
@@ -184,6 +187,7 @@ void collectors_cpu_and_wall_time_init(VALUE profiling_module) {
|
|
184
187
|
|
185
188
|
rb_define_singleton_method(collectors_cpu_and_wall_time_class, "_native_initialize", _native_initialize, 4);
|
186
189
|
rb_define_singleton_method(collectors_cpu_and_wall_time_class, "_native_inspect", _native_inspect, 1);
|
190
|
+
rb_define_singleton_method(collectors_cpu_and_wall_time_class, "_native_reset_after_fork", _native_reset_after_fork, 1);
|
187
191
|
rb_define_singleton_method(testing_module, "_native_sample", _native_sample, 1);
|
188
192
|
rb_define_singleton_method(testing_module, "_native_on_gc_start", _native_on_gc_start, 1);
|
189
193
|
rb_define_singleton_method(testing_module, "_native_on_gc_finish", _native_on_gc_finish, 1);
|
@@ -192,10 +196,12 @@ void collectors_cpu_and_wall_time_init(VALUE profiling_module) {
|
|
192
196
|
rb_define_singleton_method(testing_module, "_native_per_thread_context", _native_per_thread_context, 1);
|
193
197
|
rb_define_singleton_method(testing_module, "_native_stats", _native_stats, 1);
|
194
198
|
|
195
|
-
at_active_trace_id = rb_intern_const("@active_trace");
|
196
|
-
at_root_span_id = rb_intern_const("@root_span");
|
197
199
|
at_active_span_id = rb_intern_const("@active_span");
|
200
|
+
at_active_trace_id = rb_intern_const("@active_trace");
|
198
201
|
at_id_id = rb_intern_const("@id");
|
202
|
+
at_resource_id = rb_intern_const("@resource");
|
203
|
+
at_root_span_id = rb_intern_const("@root_span");
|
204
|
+
at_type_id = rb_intern_const("@type");
|
199
205
|
}
|
200
206
|
|
201
207
|
// This structure is used to define a Ruby object that stores a pointer to a struct cpu_and_wall_time_collector_state
|
@@ -292,7 +298,7 @@ static VALUE _native_initialize(DDTRACE_UNUSED VALUE _self, VALUE collector_inst
|
|
292
298
|
// This method exists only to enable testing Datadog::Profiling::Collectors::CpuAndWallTime behavior using RSpec.
|
293
299
|
// It SHOULD NOT be used for other purposes.
|
294
300
|
static VALUE _native_sample(DDTRACE_UNUSED VALUE _self, VALUE collector_instance) {
|
295
|
-
cpu_and_wall_time_collector_sample(collector_instance);
|
301
|
+
cpu_and_wall_time_collector_sample(collector_instance, monotonic_wall_time_now_ns(RAISE_ON_FAILURE));
|
296
302
|
return Qtrue;
|
297
303
|
}
|
298
304
|
|
@@ -324,12 +330,11 @@ static VALUE _native_sample_after_gc(DDTRACE_UNUSED VALUE self, VALUE collector_
|
|
324
330
|
// Assumption 3: This function IS NOT called from a signal handler. This function is not async-signal-safe.
|
325
331
|
// Assumption 4: This function IS NOT called in a reentrant way.
|
326
332
|
// Assumption 5: This function is called from the main Ractor (if Ruby has support for Ractors).
|
327
|
-
|
333
|
+
void cpu_and_wall_time_collector_sample(VALUE self_instance, long current_monotonic_wall_time_ns) {
|
328
334
|
struct cpu_and_wall_time_collector_state *state;
|
329
335
|
TypedData_Get_Struct(self_instance, struct cpu_and_wall_time_collector_state, &cpu_and_wall_time_collector_typed_data, state);
|
330
336
|
|
331
337
|
VALUE threads = ddtrace_thread_list();
|
332
|
-
long current_wall_time_ns = wall_time_now_ns(RAISE_ON_FAILURE);
|
333
338
|
|
334
339
|
const long thread_count = RARRAY_LEN(threads);
|
335
340
|
for (long i = 0; i < thread_count; i++) {
|
@@ -346,7 +351,7 @@ VALUE cpu_and_wall_time_collector_sample(VALUE self_instance) {
|
|
346
351
|
);
|
347
352
|
long wall_time_elapsed_ns = update_time_since_previous_sample(
|
348
353
|
&thread_context->wall_time_at_previous_sample_ns,
|
349
|
-
|
354
|
+
current_monotonic_wall_time_ns,
|
350
355
|
thread_context->gc_tracking.wall_time_at_start_ns,
|
351
356
|
IS_WALL_TIME
|
352
357
|
);
|
@@ -368,12 +373,9 @@ VALUE cpu_and_wall_time_collector_sample(VALUE self_instance) {
|
|
368
373
|
|
369
374
|
state->sample_count++;
|
370
375
|
|
371
|
-
// TODO: This seems somewhat overkill and inefficient to do often; right now we just
|
376
|
+
// TODO: This seems somewhat overkill and inefficient to do often; right now we just do it every few samples
|
372
377
|
// but there's probably a better way to do this if we actually track when threads finish
|
373
378
|
if (state->sample_count % 100 == 0) remove_context_for_dead_threads(state);
|
374
|
-
|
375
|
-
// Return a VALUE to make it easier to call this function from Ruby APIs that expect a return value (such as rb_rescue2)
|
376
|
-
return Qnil;
|
377
379
|
}
|
378
380
|
|
379
381
|
// This function gets called when Ruby is about to start running the Garbage Collector on the current thread.
|
@@ -417,7 +419,7 @@ void cpu_and_wall_time_collector_on_gc_start(VALUE self_instance) {
|
|
417
419
|
thread_context->gc_tracking.wall_time_at_finish_ns != INVALID_TIME) return;
|
418
420
|
|
419
421
|
// Here we record the wall-time first and in on_gc_finish we record it second to avoid having wall-time be slightly < cpu-time
|
420
|
-
thread_context->gc_tracking.wall_time_at_start_ns =
|
422
|
+
thread_context->gc_tracking.wall_time_at_start_ns = monotonic_wall_time_now_ns(DO_NOT_RAISE_ON_FAILURE);
|
421
423
|
thread_context->gc_tracking.cpu_time_at_start_ns = cpu_time_now_ns(thread_context);
|
422
424
|
}
|
423
425
|
|
@@ -453,7 +455,7 @@ void cpu_and_wall_time_collector_on_gc_finish(VALUE self_instance) {
|
|
453
455
|
|
454
456
|
// Here we record the wall-time second and in on_gc_start we record it first to avoid having wall-time be slightly < cpu-time
|
455
457
|
thread_context->gc_tracking.cpu_time_at_finish_ns = cpu_time_now_ns(thread_context);
|
456
|
-
thread_context->gc_tracking.wall_time_at_finish_ns =
|
458
|
+
thread_context->gc_tracking.wall_time_at_finish_ns = monotonic_wall_time_now_ns(DO_NOT_RAISE_ON_FAILURE);
|
457
459
|
}
|
458
460
|
|
459
461
|
// This function gets called shortly after Ruby has finished running the Garbage Collector.
|
@@ -570,12 +572,29 @@ static void trigger_sample_for_thread(
|
|
570
572
|
};
|
571
573
|
}
|
572
574
|
|
573
|
-
struct trace_identifiers trace_identifiers_result = {.valid = false};
|
575
|
+
struct trace_identifiers trace_identifiers_result = {.valid = false, .trace_endpoint = Qnil};
|
574
576
|
trace_identifiers_for(state, thread, &trace_identifiers_result);
|
575
577
|
|
576
578
|
if (trace_identifiers_result.valid) {
|
577
579
|
labels[label_pos++] = (ddog_Label) {.key = DDOG_CHARSLICE_C("local root span id"), .str = trace_identifiers_result.local_root_span_id};
|
578
|
-
labels[label_pos++] = (ddog_Label) {.key = DDOG_CHARSLICE_C("span id"), .
|
580
|
+
labels[label_pos++] = (ddog_Label) {.key = DDOG_CHARSLICE_C("span id"), .num = trace_identifiers_result.span_id};
|
581
|
+
|
582
|
+
if (trace_identifiers_result.trace_endpoint != Qnil) {
|
583
|
+
// The endpoint gets recorded in a different way because it is mutable in the tracer and can change during a
|
584
|
+
// trace.
|
585
|
+
//
|
586
|
+
// Instead of each sample for the same local_root_span_id getting a potentially-different endpoint,
|
587
|
+
// `record_endpoint` (via libdatadog) keeps a list of local_root_span_id values and their most-recently-seen
|
588
|
+
// endpoint values, and at serialization time the most-recently-seen endpoint is applied to all relevant samples.
|
589
|
+
//
|
590
|
+
// This is why the endpoint is not directly added in this function to the labels array, although it will later
|
591
|
+
// show up in the array in the output pprof.
|
592
|
+
record_endpoint(
|
593
|
+
state->recorder_instance,
|
594
|
+
trace_identifiers_result.local_root_span_id,
|
595
|
+
char_slice_from_ruby_string(trace_identifiers_result.trace_endpoint)
|
596
|
+
);
|
597
|
+
}
|
579
598
|
}
|
580
599
|
|
581
600
|
// The number of times `label_pos++` shows up in this function needs to match `max_label_count`. To avoid "oops I
|
@@ -668,8 +687,6 @@ static VALUE per_thread_context_st_table_as_ruby_hash(struct cpu_and_wall_time_c
|
|
668
687
|
return result;
|
669
688
|
}
|
670
689
|
|
671
|
-
#define VALUE_COUNT(array) (sizeof(array) / sizeof(VALUE))
|
672
|
-
|
673
690
|
static int per_thread_context_as_ruby_hash(st_data_t key_thread, st_data_t value_context, st_data_t result_hash) {
|
674
691
|
VALUE thread = (VALUE) key_thread;
|
675
692
|
struct per_thread_context *thread_context = (struct per_thread_context*) value_context;
|
@@ -698,8 +715,8 @@ static VALUE stats_as_ruby_hash(struct cpu_and_wall_time_collector_state *state)
|
|
698
715
|
// Update this when modifying state struct (stats inner struct)
|
699
716
|
VALUE stats_as_hash = rb_hash_new();
|
700
717
|
VALUE arguments[] = {
|
701
|
-
ID2SYM(rb_intern("gc_samples")), /* => */
|
702
|
-
ID2SYM(rb_intern("gc_samples_missed_due_to_missing_context")), /* => */
|
718
|
+
ID2SYM(rb_intern("gc_samples")), /* => */ UINT2NUM(state->stats.gc_samples),
|
719
|
+
ID2SYM(rb_intern("gc_samples_missed_due_to_missing_context")), /* => */ UINT2NUM(state->stats.gc_samples_missed_due_to_missing_context),
|
703
720
|
};
|
704
721
|
for (long unsigned int i = 0; i < VALUE_COUNT(arguments); i += 2) rb_hash_aset(stats_as_hash, arguments[i], arguments[i+1]);
|
705
722
|
return stats_as_hash;
|
@@ -769,18 +786,6 @@ static long update_time_since_previous_sample(long *time_at_previous_sample_ns,
|
|
769
786
|
return elapsed_time_ns;
|
770
787
|
}
|
771
788
|
|
772
|
-
// Safety: This function is assumed never to raise exceptions by callers when raise_on_failure == false
|
773
|
-
static long wall_time_now_ns(bool raise_on_failure) {
|
774
|
-
struct timespec current_monotonic;
|
775
|
-
|
776
|
-
if (clock_gettime(CLOCK_MONOTONIC, ¤t_monotonic) != 0) {
|
777
|
-
if (raise_on_failure) rb_sys_fail("Failed to read CLOCK_MONOTONIC");
|
778
|
-
else return 0;
|
779
|
-
}
|
780
|
-
|
781
|
-
return current_monotonic.tv_nsec + (current_monotonic.tv_sec * 1000 * 1000 * 1000);
|
782
|
-
}
|
783
|
-
|
784
789
|
// Safety: This function is assumed never to raise exceptions by callers
|
785
790
|
static long cpu_time_now_ns(struct per_thread_context *thread_context) {
|
786
791
|
thread_cpu_time cpu_time = thread_cpu_time_for(thread_context->thread_cpu_time_id);
|
@@ -847,19 +852,48 @@ static void trace_identifiers_for(struct cpu_and_wall_time_collector_state *stat
|
|
847
852
|
if (numeric_local_root_span_id == Qnil || numeric_span_id == Qnil) return;
|
848
853
|
|
849
854
|
unsigned long long local_root_span_id = NUM2ULL(numeric_local_root_span_id);
|
850
|
-
unsigned long long span_id = NUM2ULL(numeric_span_id);
|
851
|
-
|
852
855
|
snprintf(trace_identifiers_result->local_root_span_id_buffer, MAXIMUM_LENGTH_64_BIT_IDENTIFIER, "%llu", local_root_span_id);
|
853
|
-
snprintf(trace_identifiers_result->span_id_buffer, MAXIMUM_LENGTH_64_BIT_IDENTIFIER, "%llu", span_id);
|
854
856
|
|
855
857
|
trace_identifiers_result->local_root_span_id = (ddog_CharSlice) {
|
856
858
|
.ptr = trace_identifiers_result->local_root_span_id_buffer,
|
857
859
|
.len = strlen(trace_identifiers_result->local_root_span_id_buffer)
|
858
860
|
};
|
859
|
-
trace_identifiers_result->span_id = (
|
860
|
-
.ptr = trace_identifiers_result->span_id_buffer,
|
861
|
-
.len = strlen(trace_identifiers_result->span_id_buffer)
|
862
|
-
};
|
861
|
+
trace_identifiers_result->span_id = NUM2ULL(numeric_span_id);
|
863
862
|
|
864
863
|
trace_identifiers_result->valid = true;
|
864
|
+
|
865
|
+
VALUE root_span_type = rb_ivar_get(root_span, at_type_id /* @type */);
|
866
|
+
if (root_span_type == Qnil || !is_type_web(root_span_type)) return;
|
867
|
+
|
868
|
+
VALUE trace_resource = rb_ivar_get(active_trace, at_resource_id /* @resource */);
|
869
|
+
if (RB_TYPE_P(trace_resource, T_STRING)) {
|
870
|
+
trace_identifiers_result->trace_endpoint = trace_resource;
|
871
|
+
} else if (trace_resource == Qnil) {
|
872
|
+
// Fall back to resource from span, if any
|
873
|
+
trace_identifiers_result->trace_endpoint = rb_ivar_get(root_span, at_resource_id /* @resource */);
|
874
|
+
}
|
875
|
+
}
|
876
|
+
|
877
|
+
static bool is_type_web(VALUE root_span_type) {
|
878
|
+
ENFORCE_TYPE(root_span_type, T_STRING);
|
879
|
+
|
880
|
+
return RSTRING_LEN(root_span_type) == strlen("web") &&
|
881
|
+
(memcmp("web", StringValuePtr(root_span_type), strlen("web")) == 0);
|
882
|
+
}
|
883
|
+
|
884
|
+
// After the Ruby VM forks, this method gets called in the child process to clean up any leftover state from the parent.
|
885
|
+
//
|
886
|
+
// Assumption: This method gets called BEFORE restarting profiling -- e.g. there are no components attempting to
|
887
|
+
// trigger samples at the same time.
|
888
|
+
static VALUE _native_reset_after_fork(DDTRACE_UNUSED VALUE self, VALUE collector_instance) {
|
889
|
+
struct cpu_and_wall_time_collector_state *state;
|
890
|
+
TypedData_Get_Struct(collector_instance, struct cpu_and_wall_time_collector_state, &cpu_and_wall_time_collector_typed_data, state);
|
891
|
+
|
892
|
+
st_clear(state->hash_map_per_thread_context);
|
893
|
+
|
894
|
+
state->stats = (struct stats) {}; // Resets all stats back to zero
|
895
|
+
|
896
|
+
rb_funcall(state->recorder_instance, rb_intern("reset_after_fork"), 0);
|
897
|
+
|
898
|
+
return Qtrue;
|
865
899
|
}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
#include <ruby.h>
|
4
4
|
|
5
|
-
|
5
|
+
void cpu_and_wall_time_collector_sample(VALUE self_instance, long current_monotonic_wall_time_ns);
|
6
6
|
VALUE cpu_and_wall_time_collector_sample_after_gc(VALUE self_instance);
|
7
7
|
void cpu_and_wall_time_collector_on_gc_start(VALUE self_instance);
|
8
8
|
void cpu_and_wall_time_collector_on_gc_finish(VALUE self_instance);
|