ddtrace 1.7.0 → 1.9.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 +100 -1
- data/README.md +2 -2
- data/ext/ddtrace_profiling_loader/extconf.rb +4 -1
- 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 +24 -50
- 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 +284 -74
- 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 +32 -32
- data/ext/ddtrace_profiling_native_extension/collectors_stack.h +2 -2
- data/ext/ddtrace_profiling_native_extension/extconf.rb +21 -7
- data/ext/ddtrace_profiling_native_extension/helpers.h +5 -0
- data/ext/ddtrace_profiling_native_extension/http_transport.c +50 -49
- data/ext/ddtrace_profiling_native_extension/libdatadog_helpers.h +5 -1
- data/ext/ddtrace_profiling_native_extension/native_extension_helpers.rb +42 -12
- data/ext/ddtrace_profiling_native_extension/private_vm_api_access.c +116 -22
- 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 +23 -4
- data/ext/ddtrace_profiling_native_extension/setup_signal_handler.h +4 -0
- data/ext/ddtrace_profiling_native_extension/stack_recorder.c +47 -50
- data/ext/ddtrace_profiling_native_extension/stack_recorder.h +4 -4
- 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/waf_rules/recommended.json +75 -8
- data/lib/datadog/appsec/assets/waf_rules/risky.json +1 -1
- data/lib/datadog/appsec/assets/waf_rules/strict.json +1 -1
- data/lib/datadog/appsec/assets.rb +1 -1
- data/lib/datadog/appsec/configuration/settings.rb +35 -22
- data/lib/datadog/appsec/configuration.rb +4 -2
- data/lib/datadog/appsec/contrib/auto_instrument.rb +1 -1
- data/lib/datadog/appsec/contrib/configuration/settings.rb +1 -1
- data/lib/datadog/appsec/contrib/integration.rb +1 -1
- data/lib/datadog/appsec/contrib/patcher.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/configuration/settings.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/ext.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/gateway/watcher.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/reactive/request.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/reactive/request_body.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/reactive/response.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/request.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/response.rb +1 -1
- data/lib/datadog/appsec/contrib/rails/configuration/settings.rb +1 -1
- data/lib/datadog/appsec/contrib/rails/ext.rb +1 -1
- data/lib/datadog/appsec/contrib/rails/framework.rb +1 -1
- data/lib/datadog/appsec/contrib/rails/gateway/watcher.rb +1 -1
- data/lib/datadog/appsec/contrib/rails/reactive/action.rb +1 -1
- data/lib/datadog/appsec/contrib/rails/request.rb +1 -1
- data/lib/datadog/appsec/contrib/rails/request_middleware.rb +1 -1
- data/lib/datadog/appsec/contrib/sinatra/configuration/settings.rb +1 -1
- data/lib/datadog/appsec/contrib/sinatra/ext.rb +1 -1
- data/lib/datadog/appsec/contrib/sinatra/framework.rb +1 -1
- data/lib/datadog/appsec/contrib/sinatra/gateway/watcher.rb +1 -1
- data/lib/datadog/appsec/contrib/sinatra/reactive/routed.rb +1 -1
- data/lib/datadog/appsec/contrib/sinatra/request_middleware.rb +1 -1
- data/lib/datadog/appsec/event.rb +1 -1
- data/lib/datadog/appsec/extensions.rb +36 -26
- data/lib/datadog/appsec/instrumentation/gateway.rb +3 -3
- data/lib/datadog/appsec/processor.rb +15 -19
- data/lib/datadog/appsec/rate_limiter.rb +1 -1
- data/lib/datadog/appsec/reactive/address_hash.rb +1 -1
- data/lib/datadog/appsec/reactive/engine.rb +1 -1
- data/lib/datadog/appsec/reactive/operation.rb +2 -2
- data/lib/datadog/appsec/reactive/subscriber.rb +1 -1
- data/lib/datadog/appsec/response.rb +18 -9
- data/lib/datadog/appsec/utils/http/media_range.rb +201 -0
- data/lib/datadog/appsec/utils/http/media_type.rb +87 -0
- data/lib/datadog/appsec/utils/http.rb +9 -0
- data/lib/datadog/appsec/utils.rb +7 -0
- data/lib/datadog/appsec.rb +1 -1
- data/lib/datadog/ci/ext/environment.rb +57 -13
- data/lib/datadog/core/configuration/agent_settings_resolver.rb +2 -2
- data/lib/datadog/core/configuration/base.rb +3 -0
- data/lib/datadog/core/configuration/components.rb +27 -6
- data/lib/datadog/core/configuration/ext.rb +26 -0
- data/lib/datadog/core/configuration/option_definition.rb +11 -2
- data/lib/datadog/core/configuration/settings.rb +16 -341
- data/lib/datadog/core/diagnostics/environment_logger.rb +4 -3
- data/lib/datadog/core/diagnostics/health.rb +4 -22
- data/lib/datadog/core/environment/variable_helpers.rb +58 -10
- data/lib/datadog/core/metrics/client.rb +3 -2
- data/lib/datadog/core/metrics/ext.rb +0 -2
- data/lib/datadog/core/telemetry/collector.rb +1 -0
- data/lib/datadog/core/utils.rb +0 -21
- data/lib/datadog/core.rb +21 -1
- data/lib/datadog/kit/appsec/events.rb +75 -0
- data/lib/datadog/kit/enable_core_dumps.rb +1 -0
- data/lib/datadog/kit/identity.rb +8 -7
- data/lib/datadog/opentelemetry/api/context.rb +187 -0
- data/lib/datadog/opentelemetry/api/trace/span.rb +15 -0
- data/lib/datadog/opentelemetry/sdk/configurator.rb +38 -0
- data/lib/datadog/opentelemetry/sdk/id_generator.rb +27 -0
- data/lib/datadog/opentelemetry/sdk/propagator.rb +91 -0
- data/lib/datadog/opentelemetry/sdk/span_processor.rb +92 -0
- data/lib/datadog/opentelemetry.rb +48 -0
- data/lib/datadog/opentracer/distributed_headers.rb +2 -2
- data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +16 -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/stack_recorder.rb +14 -0
- data/lib/datadog/profiling.rb +2 -0
- data/lib/datadog/tracing/configuration/ext.rb +33 -4
- 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/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/distributed/propagation.rb +9 -4
- data/lib/datadog/tracing/contrib/grpc/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/http/configuration/settings.rb +11 -1
- data/lib/datadog/tracing/contrib/http/distributed/fetcher.rb +10 -3
- data/lib/datadog/tracing/contrib/http/distributed/propagation.rb +9 -4
- data/lib/datadog/tracing/contrib/http/ext.rb +2 -0
- data/lib/datadog/tracing/contrib/http/instrumentation.rb +3 -6
- data/lib/datadog/tracing/contrib/httpclient/configuration/settings.rb +11 -1
- data/lib/datadog/tracing/contrib/httpclient/ext.rb +2 -0
- data/lib/datadog/tracing/contrib/httpclient/instrumentation.rb +3 -4
- data/lib/datadog/tracing/contrib/httprb/configuration/settings.rb +11 -1
- data/lib/datadog/tracing/contrib/httprb/ext.rb +2 -0
- data/lib/datadog/tracing/contrib/httprb/instrumentation.rb +3 -4
- 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/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 +56 -33
- 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/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 -23
- 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/rest_client/configuration/settings.rb +6 -1
- data/lib/datadog/tracing/contrib/rest_client/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/stripe/configuration/settings.rb +33 -0
- data/lib/datadog/tracing/contrib/stripe/ext.rb +26 -0
- data/lib/datadog/tracing/contrib/stripe/integration.rb +43 -0
- data/lib/datadog/tracing/contrib/stripe/patcher.rb +29 -0
- data/lib/datadog/tracing/contrib/stripe/request.rb +67 -0
- data/lib/datadog/tracing/contrib.rb +1 -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.rb → b3_multi.rb} +2 -2
- data/lib/datadog/tracing/distributed/helpers.rb +2 -1
- data/lib/datadog/tracing/distributed/none.rb +19 -0
- data/lib/datadog/tracing/distributed/trace_context.rb +378 -0
- data/lib/datadog/tracing/metadata/ext.rb +1 -1
- data/lib/datadog/tracing/metadata/tagging.rb +6 -0
- 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 +85 -2
- data/lib/datadog/tracing/trace_operation.rb +13 -4
- data/lib/datadog/tracing/utils.rb +50 -0
- data/lib/ddtrace/version.rb +1 -1
- metadata +41 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ba4a81593411a12abfa1665b3910e49e35429b1b266779e93accb0f84a478d2
|
4
|
+
data.tar.gz: e72362dc1a1e682a3c52b8af8017fcd12e60d353843cdd129f65a55dbb0c312d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a083b23cfadccc78e67a5aa2a3ae067bc868e4721d92d1fb9fcbadc7536332fabd20f6638fb157712e5e909afd3e3e505a2011838a4f0e98dbebaa64a38f7db6
|
7
|
+
data.tar.gz: 81b27dbbf685c01ee99ab79a8774aefca4a2feb93363a41e1a3465b01b1b07f571d5bdd75a73880658ae05254a3d742651bdf8df98fd48c040f73bb6a16702d0
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,69 @@
|
|
2
2
|
|
3
3
|
## [Unreleased]
|
4
4
|
|
5
|
+
## [1.9.0] - 2023-01-30
|
6
|
+
|
7
|
+
As of ddtrace 1.9.0, CPU Profiling 2.0 is now in opt-in (that is, disabled by default) public beta. For more details, check the release notes.
|
8
|
+
|
9
|
+
Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v1.9.0
|
10
|
+
|
11
|
+
### Added
|
12
|
+
|
13
|
+
* Tracing: Add `Stripe` instrumentation ([#2557][])
|
14
|
+
* Tracing: Add configurable response codes considered as errors for `Net/HTTP`, `httprb` and `httpclient` ([#2501][], [#2576][])([@caramcc][])
|
15
|
+
* Tracing: Flexible header matching for HTTP propagator ([#2504][])
|
16
|
+
* Tracing: `OpenTelemetry` Traces support ([#2496][])
|
17
|
+
* Tracing: W3C: Propagate unknown values as-is ([#2485][])
|
18
|
+
* Appsec: Add event kit API ([#2512][])
|
19
|
+
* Profiling: Allow profiler development on arm64 macOS ([#2573][])
|
20
|
+
* Core: Add `profiling_enabled` state to environment logger output ([#2541][])
|
21
|
+
* Core: Add 'type' to `OptionDefinition` ([#2493][])
|
22
|
+
* Allow `debase-ruby_core_source` 3.2.0 to be used ([#2526][])
|
23
|
+
|
24
|
+
### Changed
|
25
|
+
|
26
|
+
* Profiling: Upgrade to `libdatadog` to `1.0.1.1.0` ([#2530][])
|
27
|
+
* Appsec: Update appsec rules `1.4.3` ([#2580][])
|
28
|
+
* Ci: Update CI Visibility metadata extraction ([#2586][])
|
29
|
+
|
30
|
+
### Fixed
|
31
|
+
|
32
|
+
* Profiling: Fix wrong `libdatadog` version being picked during profiler build ([#2531][])
|
33
|
+
* Tracing: Support `PG` calls with a block ([#2522][])
|
34
|
+
* Ci: Fix error in `teamcity` env vars ([#2562][])
|
35
|
+
|
36
|
+
## [1.8.0] - 2022-12-14
|
37
|
+
|
38
|
+
Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v1.8.0
|
39
|
+
|
40
|
+
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,
|
41
|
+
check the release notes.
|
42
|
+
|
43
|
+
### Added
|
44
|
+
|
45
|
+
* Core: Profiling: [PROF-6559] Mark Ruby CPU Profiling 2.0 as being in beta ([#2489][])
|
46
|
+
* Tracing: Attempt to parse future version of TraceContext ([#2473][])
|
47
|
+
* Tracing: Add DD_TRACE_PROPAGATION_STYLE option ([#2466][])
|
48
|
+
* Integrations: Tracing: SQL comment propagation full mode with traceparent ([#2464][])
|
49
|
+
* Integrations: Tracing: Wire W3C propagator to HTTP & gRPC propagation ([#2458][])
|
50
|
+
* Integrations: Tracing: Auto-instrumentation with service_name from environmental variable ([#2455][])
|
51
|
+
* Core: Integrations: Tracing: Deprecation notice for B3 propagation configuration ([#2454][])
|
52
|
+
* Tracing: Add W3C Trace Context propagator ([#2451][])
|
53
|
+
* Integrations: Tracing: Redis 5 Instrumentation ([#2428][])
|
54
|
+
|
55
|
+
### Changed
|
56
|
+
|
57
|
+
* Tracing: Changes `error.msg` to `error.message` for UNC ([#2469][])
|
58
|
+
* Tracing: Semicolons not allowed in 'origin' ([#2461][])
|
59
|
+
* Core: Dev/refactor: Tracing: Dev/internal: Move Utils#next_id and constants to Tracing::Utils ([#2463][])
|
60
|
+
* Core: Dev/refactor: Tracing: Dev/internal: Move Tracing config settings from Core to Tracing ([#2459][])
|
61
|
+
* Core: Dev/refactor: Tracing: Dev/internal: Move Tracing diagnostic code from Core to Tracing ([#2453][])
|
62
|
+
|
63
|
+
### Fixed
|
64
|
+
|
65
|
+
* Integrations: Tracing: Improve redis integration patching ([#2470][])
|
66
|
+
* Tracing: Extra testing from W3C spec ([#2460][])
|
67
|
+
|
5
68
|
## [1.7.0] - 2022-11-29
|
6
69
|
|
7
70
|
### Added
|
@@ -2218,7 +2281,9 @@ Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.3.1
|
|
2218
2281
|
|
2219
2282
|
Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
|
2220
2283
|
|
2221
|
-
[Unreleased]: https://github.com/DataDog/dd-trace-rb/compare/v1.
|
2284
|
+
[Unreleased]: https://github.com/DataDog/dd-trace-rb/compare/v1.9.0...master
|
2285
|
+
[1.9.0]: https://github.com/DataDog/dd-trace-rb/compare/v1.8.0...v1.9.0
|
2286
|
+
[1.8.0]: https://github.com/DataDog/dd-trace-rb/compare/v1.7.0...v1.8.0
|
2222
2287
|
[1.7.0]: https://github.com/DataDog/dd-trace-rb/compare/v1.6.1...v1.7.0
|
2223
2288
|
[1.6.1]: https://github.com/DataDog/dd-trace-rb/compare/v1.6.0...v1.6.1
|
2224
2289
|
[1.6.0]: https://github.com/DataDog/dd-trace-rb/compare/v1.5.2...v1.6.0
|
@@ -3161,7 +3226,40 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
|
|
3161
3226
|
[#2413]: https://github.com/DataDog/dd-trace-rb/issues/2413
|
3162
3227
|
[#2419]: https://github.com/DataDog/dd-trace-rb/issues/2419
|
3163
3228
|
[#2420]: https://github.com/DataDog/dd-trace-rb/issues/2420
|
3229
|
+
[#2428]: https://github.com/DataDog/dd-trace-rb/issues/2428
|
3164
3230
|
[#2435]: https://github.com/DataDog/dd-trace-rb/issues/2435
|
3231
|
+
[#2451]: https://github.com/DataDog/dd-trace-rb/issues/2451
|
3232
|
+
[#2453]: https://github.com/DataDog/dd-trace-rb/issues/2453
|
3233
|
+
[#2454]: https://github.com/DataDog/dd-trace-rb/issues/2454
|
3234
|
+
[#2455]: https://github.com/DataDog/dd-trace-rb/issues/2455
|
3235
|
+
[#2458]: https://github.com/DataDog/dd-trace-rb/issues/2458
|
3236
|
+
[#2459]: https://github.com/DataDog/dd-trace-rb/issues/2459
|
3237
|
+
[#2460]: https://github.com/DataDog/dd-trace-rb/issues/2460
|
3238
|
+
[#2461]: https://github.com/DataDog/dd-trace-rb/issues/2461
|
3239
|
+
[#2463]: https://github.com/DataDog/dd-trace-rb/issues/2463
|
3240
|
+
[#2464]: https://github.com/DataDog/dd-trace-rb/issues/2464
|
3241
|
+
[#2466]: https://github.com/DataDog/dd-trace-rb/issues/2466
|
3242
|
+
[#2469]: https://github.com/DataDog/dd-trace-rb/issues/2469
|
3243
|
+
[#2470]: https://github.com/DataDog/dd-trace-rb/issues/2470
|
3244
|
+
[#2473]: https://github.com/DataDog/dd-trace-rb/issues/2473
|
3245
|
+
[#2485]: https://github.com/DataDog/dd-trace-rb/issues/2485
|
3246
|
+
[#2489]: https://github.com/DataDog/dd-trace-rb/issues/2489
|
3247
|
+
[#2493]: https://github.com/DataDog/dd-trace-rb/issues/2493
|
3248
|
+
[#2496]: https://github.com/DataDog/dd-trace-rb/issues/2496
|
3249
|
+
[#2501]: https://github.com/DataDog/dd-trace-rb/issues/2501
|
3250
|
+
[#2504]: https://github.com/DataDog/dd-trace-rb/issues/2504
|
3251
|
+
[#2512]: https://github.com/DataDog/dd-trace-rb/issues/2512
|
3252
|
+
[#2522]: https://github.com/DataDog/dd-trace-rb/issues/2522
|
3253
|
+
[#2526]: https://github.com/DataDog/dd-trace-rb/issues/2526
|
3254
|
+
[#2530]: https://github.com/DataDog/dd-trace-rb/issues/2530
|
3255
|
+
[#2531]: https://github.com/DataDog/dd-trace-rb/issues/2531
|
3256
|
+
[#2541]: https://github.com/DataDog/dd-trace-rb/issues/2541
|
3257
|
+
[#2557]: https://github.com/DataDog/dd-trace-rb/issues/2557
|
3258
|
+
[#2562]: https://github.com/DataDog/dd-trace-rb/issues/2562
|
3259
|
+
[#2573]: https://github.com/DataDog/dd-trace-rb/issues/2573
|
3260
|
+
[#2576]: https://github.com/DataDog/dd-trace-rb/issues/2576
|
3261
|
+
[#2580]: https://github.com/DataDog/dd-trace-rb/issues/2580
|
3262
|
+
[#2586]: https://github.com/DataDog/dd-trace-rb/issues/2586
|
3165
3263
|
[@AdrianLC]: https://github.com/AdrianLC
|
3166
3264
|
[@Azure7111]: https://github.com/Azure7111
|
3167
3265
|
[@BabyGroot]: https://github.com/BabyGroot
|
@@ -3200,6 +3298,7 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
|
|
3200
3298
|
[@brafales]: https://github.com/brafales
|
3201
3299
|
[@bzf]: https://github.com/bzf
|
3202
3300
|
[@callumj]: https://github.com/callumj
|
3301
|
+
[@caramcc]: https://github.com/caramcc
|
3203
3302
|
[@carlallen]: https://github.com/carlallen
|
3204
3303
|
[@chychkan]: https://github.com/chychkan
|
3205
3304
|
[@cjford]: https://github.com/cjford
|
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].
|
@@ -34,7 +34,7 @@ add_compiler_flag '-Werror' if ENV['DDTRACE_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,8 +62,6 @@
|
|
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
|
@@ -128,9 +128,8 @@ struct trace_identifiers {
|
|
128
128
|
|
129
129
|
bool valid;
|
130
130
|
ddog_CharSlice local_root_span_id;
|
131
|
-
|
131
|
+
uint64_t span_id;
|
132
132
|
char local_root_span_id_buffer[MAXIMUM_LENGTH_64_BIT_IDENTIFIER];
|
133
|
-
char span_id_buffer[MAXIMUM_LENGTH_64_BIT_IDENTIFIER];
|
134
133
|
VALUE trace_endpoint;
|
135
134
|
};
|
136
135
|
|
@@ -148,7 +147,7 @@ static void trigger_sample_for_thread(
|
|
148
147
|
struct cpu_and_wall_time_collector_state *state,
|
149
148
|
VALUE thread,
|
150
149
|
struct per_thread_context *thread_context,
|
151
|
-
|
150
|
+
ddog_Slice_I64 metric_values_slice,
|
152
151
|
sample_type type
|
153
152
|
);
|
154
153
|
static VALUE _native_thread_list(VALUE self);
|
@@ -164,7 +163,6 @@ static int remove_if_dead_thread(st_data_t key_thread, st_data_t value_context,
|
|
164
163
|
static VALUE _native_per_thread_context(VALUE self, VALUE collector_instance);
|
165
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);
|
166
165
|
static long cpu_time_now_ns(struct per_thread_context *thread_context);
|
167
|
-
static long wall_time_now_ns(bool raise_on_failure);
|
168
166
|
static long thread_id_for(VALUE thread);
|
169
167
|
static VALUE _native_stats(VALUE self, VALUE collector_instance);
|
170
168
|
static void trace_identifiers_for(struct cpu_and_wall_time_collector_state *state, VALUE thread, struct trace_identifiers *trace_identifiers_result);
|
@@ -300,7 +298,7 @@ static VALUE _native_initialize(DDTRACE_UNUSED VALUE _self, VALUE collector_inst
|
|
300
298
|
// This method exists only to enable testing Datadog::Profiling::Collectors::CpuAndWallTime behavior using RSpec.
|
301
299
|
// It SHOULD NOT be used for other purposes.
|
302
300
|
static VALUE _native_sample(DDTRACE_UNUSED VALUE _self, VALUE collector_instance) {
|
303
|
-
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));
|
304
302
|
return Qtrue;
|
305
303
|
}
|
306
304
|
|
@@ -332,12 +330,11 @@ static VALUE _native_sample_after_gc(DDTRACE_UNUSED VALUE self, VALUE collector_
|
|
332
330
|
// Assumption 3: This function IS NOT called from a signal handler. This function is not async-signal-safe.
|
333
331
|
// Assumption 4: This function IS NOT called in a reentrant way.
|
334
332
|
// Assumption 5: This function is called from the main Ractor (if Ruby has support for Ractors).
|
335
|
-
|
333
|
+
void cpu_and_wall_time_collector_sample(VALUE self_instance, long current_monotonic_wall_time_ns) {
|
336
334
|
struct cpu_and_wall_time_collector_state *state;
|
337
335
|
TypedData_Get_Struct(self_instance, struct cpu_and_wall_time_collector_state, &cpu_and_wall_time_collector_typed_data, state);
|
338
336
|
|
339
337
|
VALUE threads = ddtrace_thread_list();
|
340
|
-
long current_wall_time_ns = wall_time_now_ns(RAISE_ON_FAILURE);
|
341
338
|
|
342
339
|
const long thread_count = RARRAY_LEN(threads);
|
343
340
|
for (long i = 0; i < thread_count; i++) {
|
@@ -354,7 +351,7 @@ VALUE cpu_and_wall_time_collector_sample(VALUE self_instance) {
|
|
354
351
|
);
|
355
352
|
long wall_time_elapsed_ns = update_time_since_previous_sample(
|
356
353
|
&thread_context->wall_time_at_previous_sample_ns,
|
357
|
-
|
354
|
+
current_monotonic_wall_time_ns,
|
358
355
|
thread_context->gc_tracking.wall_time_at_start_ns,
|
359
356
|
IS_WALL_TIME
|
360
357
|
);
|
@@ -369,19 +366,16 @@ VALUE cpu_and_wall_time_collector_sample(VALUE self_instance) {
|
|
369
366
|
state,
|
370
367
|
thread,
|
371
368
|
thread_context,
|
372
|
-
(
|
369
|
+
(ddog_Slice_I64) {.ptr = metric_values, .len = ENABLED_VALUE_TYPES_COUNT},
|
373
370
|
SAMPLE_REGULAR
|
374
371
|
);
|
375
372
|
}
|
376
373
|
|
377
374
|
state->sample_count++;
|
378
375
|
|
379
|
-
// 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
|
380
377
|
// but there's probably a better way to do this if we actually track when threads finish
|
381
378
|
if (state->sample_count % 100 == 0) remove_context_for_dead_threads(state);
|
382
|
-
|
383
|
-
// Return a VALUE to make it easier to call this function from Ruby APIs that expect a return value (such as rb_rescue2)
|
384
|
-
return Qnil;
|
385
379
|
}
|
386
380
|
|
387
381
|
// This function gets called when Ruby is about to start running the Garbage Collector on the current thread.
|
@@ -425,7 +419,7 @@ void cpu_and_wall_time_collector_on_gc_start(VALUE self_instance) {
|
|
425
419
|
thread_context->gc_tracking.wall_time_at_finish_ns != INVALID_TIME) return;
|
426
420
|
|
427
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
|
428
|
-
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);
|
429
423
|
thread_context->gc_tracking.cpu_time_at_start_ns = cpu_time_now_ns(thread_context);
|
430
424
|
}
|
431
425
|
|
@@ -461,7 +455,7 @@ void cpu_and_wall_time_collector_on_gc_finish(VALUE self_instance) {
|
|
461
455
|
|
462
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
|
463
457
|
thread_context->gc_tracking.cpu_time_at_finish_ns = cpu_time_now_ns(thread_context);
|
464
|
-
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);
|
465
459
|
}
|
466
460
|
|
467
461
|
// This function gets called shortly after Ruby has finished running the Garbage Collector.
|
@@ -526,7 +520,7 @@ VALUE cpu_and_wall_time_collector_sample_after_gc(VALUE self_instance) {
|
|
526
520
|
state,
|
527
521
|
thread,
|
528
522
|
thread_context,
|
529
|
-
(
|
523
|
+
(ddog_Slice_I64) {.ptr = metric_values, .len = ENABLED_VALUE_TYPES_COUNT},
|
530
524
|
SAMPLE_IN_GC
|
531
525
|
);
|
532
526
|
|
@@ -555,24 +549,24 @@ static void trigger_sample_for_thread(
|
|
555
549
|
struct cpu_and_wall_time_collector_state *state,
|
556
550
|
VALUE thread,
|
557
551
|
struct per_thread_context *thread_context,
|
558
|
-
|
552
|
+
ddog_Slice_I64 metric_values_slice,
|
559
553
|
sample_type type
|
560
554
|
) {
|
561
555
|
int max_label_count =
|
562
556
|
1 + // thread id
|
563
557
|
1 + // thread name
|
564
558
|
2; // local root span id and span id
|
565
|
-
|
559
|
+
ddog_prof_Label labels[max_label_count];
|
566
560
|
int label_pos = 0;
|
567
561
|
|
568
|
-
labels[label_pos++] = (
|
562
|
+
labels[label_pos++] = (ddog_prof_Label) {
|
569
563
|
.key = DDOG_CHARSLICE_C("thread id"),
|
570
564
|
.str = thread_context->thread_id_char_slice
|
571
565
|
};
|
572
566
|
|
573
567
|
VALUE thread_name = thread_name_for(thread);
|
574
568
|
if (thread_name != Qnil) {
|
575
|
-
labels[label_pos++] = (
|
569
|
+
labels[label_pos++] = (ddog_prof_Label) {
|
576
570
|
.key = DDOG_CHARSLICE_C("thread name"),
|
577
571
|
.str = char_slice_from_ruby_string(thread_name)
|
578
572
|
};
|
@@ -582,8 +576,8 @@ static void trigger_sample_for_thread(
|
|
582
576
|
trace_identifiers_for(state, thread, &trace_identifiers_result);
|
583
577
|
|
584
578
|
if (trace_identifiers_result.valid) {
|
585
|
-
labels[label_pos++] = (
|
586
|
-
labels[label_pos++] = (
|
579
|
+
labels[label_pos++] = (ddog_prof_Label) {.key = DDOG_CHARSLICE_C("local root span id"), .str = trace_identifiers_result.local_root_span_id};
|
580
|
+
labels[label_pos++] = (ddog_prof_Label) {.key = DDOG_CHARSLICE_C("span id"), .num = trace_identifiers_result.span_id};
|
587
581
|
|
588
582
|
if (trace_identifiers_result.trace_endpoint != Qnil) {
|
589
583
|
// The endpoint gets recorded in a different way because it is mutable in the tracer and can change during a
|
@@ -616,7 +610,7 @@ static void trigger_sample_for_thread(
|
|
616
610
|
state->sampling_buffer,
|
617
611
|
state->recorder_instance,
|
618
612
|
metric_values_slice,
|
619
|
-
(
|
613
|
+
(ddog_prof_Slice_Label) {.ptr = labels, .len = label_pos},
|
620
614
|
type
|
621
615
|
);
|
622
616
|
}
|
@@ -693,8 +687,6 @@ static VALUE per_thread_context_st_table_as_ruby_hash(struct cpu_and_wall_time_c
|
|
693
687
|
return result;
|
694
688
|
}
|
695
689
|
|
696
|
-
#define VALUE_COUNT(array) (sizeof(array) / sizeof(VALUE))
|
697
|
-
|
698
690
|
static int per_thread_context_as_ruby_hash(st_data_t key_thread, st_data_t value_context, st_data_t result_hash) {
|
699
691
|
VALUE thread = (VALUE) key_thread;
|
700
692
|
struct per_thread_context *thread_context = (struct per_thread_context*) value_context;
|
@@ -723,8 +715,8 @@ static VALUE stats_as_ruby_hash(struct cpu_and_wall_time_collector_state *state)
|
|
723
715
|
// Update this when modifying state struct (stats inner struct)
|
724
716
|
VALUE stats_as_hash = rb_hash_new();
|
725
717
|
VALUE arguments[] = {
|
726
|
-
ID2SYM(rb_intern("gc_samples")), /* => */
|
727
|
-
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),
|
728
720
|
};
|
729
721
|
for (long unsigned int i = 0; i < VALUE_COUNT(arguments); i += 2) rb_hash_aset(stats_as_hash, arguments[i], arguments[i+1]);
|
730
722
|
return stats_as_hash;
|
@@ -794,18 +786,6 @@ static long update_time_since_previous_sample(long *time_at_previous_sample_ns,
|
|
794
786
|
return elapsed_time_ns;
|
795
787
|
}
|
796
788
|
|
797
|
-
// Safety: This function is assumed never to raise exceptions by callers when raise_on_failure == false
|
798
|
-
static long wall_time_now_ns(bool raise_on_failure) {
|
799
|
-
struct timespec current_monotonic;
|
800
|
-
|
801
|
-
if (clock_gettime(CLOCK_MONOTONIC, ¤t_monotonic) != 0) {
|
802
|
-
if (raise_on_failure) rb_sys_fail("Failed to read CLOCK_MONOTONIC");
|
803
|
-
else return 0;
|
804
|
-
}
|
805
|
-
|
806
|
-
return current_monotonic.tv_nsec + (current_monotonic.tv_sec * 1000 * 1000 * 1000);
|
807
|
-
}
|
808
|
-
|
809
789
|
// Safety: This function is assumed never to raise exceptions by callers
|
810
790
|
static long cpu_time_now_ns(struct per_thread_context *thread_context) {
|
811
791
|
thread_cpu_time cpu_time = thread_cpu_time_for(thread_context->thread_cpu_time_id);
|
@@ -872,19 +852,13 @@ static void trace_identifiers_for(struct cpu_and_wall_time_collector_state *stat
|
|
872
852
|
if (numeric_local_root_span_id == Qnil || numeric_span_id == Qnil) return;
|
873
853
|
|
874
854
|
unsigned long long local_root_span_id = NUM2ULL(numeric_local_root_span_id);
|
875
|
-
unsigned long long span_id = NUM2ULL(numeric_span_id);
|
876
|
-
|
877
855
|
snprintf(trace_identifiers_result->local_root_span_id_buffer, MAXIMUM_LENGTH_64_BIT_IDENTIFIER, "%llu", local_root_span_id);
|
878
|
-
snprintf(trace_identifiers_result->span_id_buffer, MAXIMUM_LENGTH_64_BIT_IDENTIFIER, "%llu", span_id);
|
879
856
|
|
880
857
|
trace_identifiers_result->local_root_span_id = (ddog_CharSlice) {
|
881
858
|
.ptr = trace_identifiers_result->local_root_span_id_buffer,
|
882
859
|
.len = strlen(trace_identifiers_result->local_root_span_id_buffer)
|
883
860
|
};
|
884
|
-
trace_identifiers_result->span_id = (
|
885
|
-
.ptr = trace_identifiers_result->span_id_buffer,
|
886
|
-
.len = strlen(trace_identifiers_result->span_id_buffer)
|
887
|
-
};
|
861
|
+
trace_identifiers_result->span_id = NUM2ULL(numeric_span_id);
|
888
862
|
|
889
863
|
trace_identifiers_result->valid = true;
|
890
864
|
|
@@ -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);
|