ddtrace 1.1.0 → 1.2.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 +59 -1
- data/CONTRIBUTING.md +1 -1
- data/README.md +7 -2
- data/ddtrace.gemspec +5 -2
- data/docs/GettingStarted.md +27 -3
- data/docs/ProfilingDevelopment.md +27 -28
- data/docs/UpgradeGuide.md +1 -1
- data/ext/ddtrace_profiling_loader/ddtrace_profiling_loader.c +1 -1
- data/ext/ddtrace_profiling_loader/extconf.rb +1 -0
- data/ext/ddtrace_profiling_native_extension/NativeExtensionDesign.md +6 -5
- data/ext/ddtrace_profiling_native_extension/clock_id.h +1 -1
- data/ext/ddtrace_profiling_native_extension/clock_id_from_pthread.c +1 -1
- data/ext/ddtrace_profiling_native_extension/clock_id_noop.c +1 -1
- data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time.c +269 -0
- data/ext/ddtrace_profiling_native_extension/collectors_stack.c +12 -12
- data/ext/ddtrace_profiling_native_extension/collectors_stack.h +9 -0
- data/ext/ddtrace_profiling_native_extension/extconf.rb +44 -3
- data/ext/ddtrace_profiling_native_extension/http_transport.c +341 -0
- data/ext/ddtrace_profiling_native_extension/native_extension_helpers.rb +92 -4
- data/ext/ddtrace_profiling_native_extension/private_vm_api_access.c +76 -1
- data/ext/ddtrace_profiling_native_extension/private_vm_api_access.h +3 -0
- data/ext/ddtrace_profiling_native_extension/profiling.c +4 -0
- data/ext/ddtrace_profiling_native_extension/ruby_helpers.h +33 -0
- data/ext/ddtrace_profiling_native_extension/stack_recorder.c +18 -10
- data/ext/ddtrace_profiling_native_extension/stack_recorder.h +10 -1
- data/lib/datadog/core/configuration/components.rb +39 -24
- data/lib/datadog/core/configuration/settings.rb +8 -1
- data/lib/datadog/core/environment/platform.rb +40 -0
- data/lib/datadog/core/utils.rb +1 -1
- data/lib/datadog/opentracer/thread_local_scope_manager.rb +26 -3
- data/lib/datadog/profiling/collectors/code_provenance.rb +1 -0
- data/lib/datadog/profiling/collectors/cpu_and_wall_time.rb +42 -0
- data/lib/datadog/profiling/collectors/stack.rb +2 -0
- data/lib/datadog/profiling/encoding/profile.rb +7 -11
- data/lib/datadog/profiling/exporter.rb +58 -9
- data/lib/datadog/profiling/ext/forking.rb +8 -8
- data/lib/datadog/profiling/ext.rb +2 -15
- data/lib/datadog/profiling/flush.rb +25 -53
- data/lib/datadog/profiling/http_transport.rb +131 -0
- data/lib/datadog/profiling/old_ext.rb +42 -0
- data/lib/datadog/profiling/{recorder.rb → old_recorder.rb} +20 -31
- data/lib/datadog/profiling/scheduler.rb +24 -43
- data/lib/datadog/profiling/transport/http/api/endpoint.rb +9 -31
- data/lib/datadog/profiling/transport/http/client.rb +5 -3
- data/lib/datadog/profiling/transport/http/response.rb +0 -2
- data/lib/datadog/profiling/transport/http.rb +1 -1
- data/lib/datadog/profiling.rb +3 -3
- data/lib/datadog/tracing/context_provider.rb +17 -1
- data/lib/datadog/tracing/contrib/action_pack/action_controller/instrumentation.rb +4 -0
- data/lib/datadog/tracing/contrib/grpc/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb +1 -1
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor.rb +4 -0
- data/lib/datadog/tracing/contrib/pg/configuration/settings.rb +35 -0
- data/lib/datadog/tracing/contrib/pg/ext.rb +31 -0
- data/lib/datadog/tracing/contrib/pg/instrumentation.rb +129 -0
- data/lib/datadog/tracing/contrib/pg/integration.rb +43 -0
- data/lib/datadog/tracing/contrib/pg/patcher.rb +31 -0
- data/lib/datadog/tracing/contrib/rails/configuration/settings.rb +3 -0
- data/lib/datadog/tracing/contrib/rails/framework.rb +2 -1
- data/lib/datadog/tracing/contrib/rest_client/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +1 -1
- data/lib/datadog/tracing/contrib.rb +1 -0
- data/lib/datadog/tracing/distributed/headers/b3.rb +1 -1
- data/lib/datadog/tracing/distributed/headers/b3_single.rb +4 -4
- data/lib/datadog/tracing/distributed/headers/datadog.rb +1 -1
- data/lib/datadog/tracing/distributed/headers/parser.rb +37 -0
- data/lib/datadog/tracing/distributed/helpers.rb +34 -0
- data/lib/datadog/tracing/distributed/metadata/b3.rb +55 -0
- data/lib/datadog/tracing/distributed/metadata/b3_single.rb +66 -0
- data/lib/datadog/tracing/distributed/metadata/datadog.rb +73 -0
- data/lib/datadog/tracing/distributed/metadata/parser.rb +34 -0
- data/lib/datadog/tracing/metadata/ext.rb +25 -0
- data/lib/datadog/tracing/metadata/tagging.rb +6 -0
- data/lib/datadog/tracing/propagation/grpc.rb +65 -55
- data/lib/datadog/tracing/sampling/rate_sampler.rb +2 -2
- data/lib/datadog/tracing/sampling/span/matcher.rb +80 -0
- data/lib/datadog/tracing/span.rb +21 -1
- data/lib/datadog/tracing/span_operation.rb +2 -1
- data/lib/ddtrace/version.rb +1 -1
- metadata +24 -13
- data/lib/datadog/profiling/transport/client.rb +0 -16
- data/lib/datadog/profiling/transport/io/client.rb +0 -29
- data/lib/datadog/profiling/transport/io/response.rb +0 -18
- data/lib/datadog/profiling/transport/io.rb +0 -32
- data/lib/datadog/profiling/transport/parcel.rb +0 -19
- data/lib/datadog/profiling/transport/request.rb +0 -17
- data/lib/datadog/profiling/transport/response.rb +0 -10
- data/lib/datadog/tracing/distributed/parser.rb +0 -70
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7eadd5e3cd8cb0144883eb120e8aee9289d06acfc2e8c5b4b6d863f524be26e7
|
4
|
+
data.tar.gz: 6d0005127cfe83c0332275215a850a33d13e7670ae74982286e9fe77ac7214b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58e0edde95e595e435e6fad3ee078fe6bb6cf70301b6802b3b527b2804af259276752f3820901962ff94729149d60f4c81be7d3fe5c1c81b5b2119db89a9d3fa
|
7
|
+
data.tar.gz: baf7561a9b11f8a80fd8f36fe331c8dbdb7a7271db4cfe69f78e50b26a5946c426d0cba38b032eea964e619c3f67fcecb8b0350e72e73b7c02c53af84dbd8ecd
|
data/CHANGELOG.md
CHANGED
@@ -2,8 +2,44 @@
|
|
2
2
|
|
3
3
|
## [Unreleased]
|
4
4
|
|
5
|
+
## [1.2.0] - 2022-07-11
|
6
|
+
|
7
|
+
Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v1.2.0
|
8
|
+
|
9
|
+
Git diff: https://github.com/DataDog/dd-trace-rb/compare/v1.1.0...v1.2.0
|
10
|
+
|
11
|
+
Special thanks go to [@miketheman][] for gifting Datadog access to the `datadog` gem a few days ago.
|
12
|
+
|
13
|
+
### Added
|
14
|
+
|
15
|
+
* Add Postgres (`pg` gem) instrumentation ([#2054][]) ([@jennchenn][])
|
16
|
+
* Add env var for debugging profiling native extension compilation issues ([#2069][])
|
17
|
+
* Teach Rest Client integration the `:split_by_domain` option ([#2079][]) ([@agrobbin][])
|
18
|
+
* Allow passing request_queuing option to Rack through Rails tracer ([#2082][]) ([@KieranP][])
|
19
|
+
* Add Utility to Collect Platform Information ([#2097][]) ([@jennchenn][])
|
20
|
+
* Add convenient interface for getting and setting tags using `[]` and `[]=` respectively ([#2076][]) ([@ioquatix][])
|
21
|
+
* Add b3 metadata in grpc ([#2110][]) ([@henrich-m][])
|
22
|
+
|
23
|
+
### Changed
|
24
|
+
|
25
|
+
* Profiler now reports profiling data using the libddprof gem ([#2059][])
|
26
|
+
* Rename `Kernel#at_fork_blocks` monkey patch to `Kernel#ddtrace_at_fork_blocks` ([#2070][])
|
27
|
+
* Improved error message for enabling profiling when `pkg-config` system tool is not installed ([#2134][])
|
28
|
+
|
29
|
+
### Fixed
|
30
|
+
|
31
|
+
* Prevent errors in `action_controller` integration when tracing is disabled ([#2027][]) ([@ahorner][])
|
32
|
+
* Fix profiler not building on ruby-head (3.2) due to VM refactoring ([#2066][])
|
33
|
+
* Span and trace IDs should not be zero ([#2113][]) ([@albertvaka][])
|
34
|
+
* Fix object_id usage as thread local key ([#2096][])
|
35
|
+
* Fix profiling not working on Heroku and AWS Elastic Beanstalk due to linking issues ([#2125][])
|
36
|
+
|
5
37
|
## [1.1.0] - 2022-05-25
|
6
38
|
|
39
|
+
Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v1.1.0
|
40
|
+
|
41
|
+
Git diff: https://github.com/DataDog/dd-trace-rb/compare/v1.0.0...v1.1.0
|
42
|
+
|
7
43
|
### Added
|
8
44
|
|
9
45
|
* [Application Security Monitoring](https://docs.datadoghq.com/security_platform/application_security/)
|
@@ -2852,7 +2888,22 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
|
|
2852
2888
|
[#2010]: https://github.com/DataDog/dd-trace-rb/issues/2010
|
2853
2889
|
[#2011]: https://github.com/DataDog/dd-trace-rb/issues/2011
|
2854
2890
|
[#2022]: https://github.com/DataDog/dd-trace-rb/issues/2022
|
2891
|
+
[#2027]: https://github.com/DataDog/dd-trace-rb/issues/2027
|
2855
2892
|
[#2028]: https://github.com/DataDog/dd-trace-rb/issues/2028
|
2893
|
+
[#2054]: https://github.com/DataDog/dd-trace-rb/issues/2054
|
2894
|
+
[#2059]: https://github.com/DataDog/dd-trace-rb/issues/2059
|
2895
|
+
[#2066]: https://github.com/DataDog/dd-trace-rb/issues/2066
|
2896
|
+
[#2069]: https://github.com/DataDog/dd-trace-rb/issues/2069
|
2897
|
+
[#2070]: https://github.com/DataDog/dd-trace-rb/issues/2070
|
2898
|
+
[#2076]: https://github.com/DataDog/dd-trace-rb/issues/2076
|
2899
|
+
[#2079]: https://github.com/DataDog/dd-trace-rb/issues/2079
|
2900
|
+
[#2082]: https://github.com/DataDog/dd-trace-rb/issues/2082
|
2901
|
+
[#2096]: https://github.com/DataDog/dd-trace-rb/issues/2096
|
2902
|
+
[#2097]: https://github.com/DataDog/dd-trace-rb/issues/2097
|
2903
|
+
[#2110]: https://github.com/DataDog/dd-trace-rb/issues/2110
|
2904
|
+
[#2113]: https://github.com/DataDog/dd-trace-rb/issues/2113
|
2905
|
+
[#2125]: https://github.com/DataDog/dd-trace-rb/issues/2125
|
2906
|
+
[#2134]: https://github.com/DataDog/dd-trace-rb/issues/2134
|
2856
2907
|
[@AdrianLC]: https://github.com/AdrianLC
|
2857
2908
|
[@Azure7111]: https://github.com/Azure7111
|
2858
2909
|
[@BabyGroot]: https://github.com/BabyGroot
|
@@ -2865,6 +2916,7 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
|
|
2865
2916
|
[@Jared-Prime]: https://github.com/Jared-Prime
|
2866
2917
|
[@Joas1988]: https://github.com/Joas1988
|
2867
2918
|
[@JustSnow]: https://github.com/JustSnow
|
2919
|
+
[@KieranP]: https://github.com/KieranP
|
2868
2920
|
[@MMartyn]: https://github.com/MMartyn
|
2869
2921
|
[@NobodysNightmare]: https://github.com/NobodysNightmare
|
2870
2922
|
[@Redapted]: https://github.com/Redapted
|
@@ -2875,7 +2927,9 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
|
|
2875
2927
|
[@agirlnamedsophia]: https://github.com/agirlnamedsophia
|
2876
2928
|
[@agrobbin]: https://github.com/agrobbin
|
2877
2929
|
[@ahammel]: https://github.com/ahammel
|
2930
|
+
[@ahorner]: https://github.com/ahorner
|
2878
2931
|
[@al-kudryavtsev]: https://github.com/al-kudryavtsev
|
2932
|
+
[@albertvaka]: https://github.com/albertvaka
|
2879
2933
|
[@alksl]: https://github.com/alksl
|
2880
2934
|
[@alloy]: https://github.com/alloy
|
2881
2935
|
[@aurelian]: https://github.com/aurelian
|
@@ -2921,11 +2975,14 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
|
|
2921
2975
|
[@guizmaii]: https://github.com/guizmaii
|
2922
2976
|
[@hatstand]: https://github.com/hatstand
|
2923
2977
|
[@hawknewton]: https://github.com/hawknewton
|
2978
|
+
[@henrich-m]: https://github.com/henrich-m
|
2924
2979
|
[@hs-bguven]: https://github.com/hs-bguven
|
2925
2980
|
[@illdelph]: https://github.com/illdelph
|
2981
|
+
[@ioquatix]: https://github.com/ioquatix
|
2926
2982
|
[@jamiehodge]: https://github.com/jamiehodge
|
2927
2983
|
[@janz93]: https://github.com/janz93
|
2928
2984
|
[@jeffjo]: https://github.com/jeffjo
|
2985
|
+
[@jennchenn]: https://github.com/jennchenn
|
2929
2986
|
[@jfrancoist]: https://github.com/jfrancoist
|
2930
2987
|
[@joeyAghion]: https://github.com/joeyAghion
|
2931
2988
|
[@jpaulgs]: https://github.com/jpaulgs
|
@@ -2945,6 +3002,7 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
|
|
2945
3002
|
[@mdehoog]: https://github.com/mdehoog
|
2946
3003
|
[@mdross95]: https://github.com/mdross95
|
2947
3004
|
[@michaelkl]: https://github.com/michaelkl
|
3005
|
+
[@miketheman]: https://github.com/miketheman
|
2948
3006
|
[@mriddle]: https://github.com/mriddle
|
2949
3007
|
[@mscrivo]: https://github.com/mscrivo
|
2950
3008
|
[@mstruve]: https://github.com/mstruve
|
@@ -2983,4 +3041,4 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
|
|
2983
3041
|
[@vramaiah]: https://github.com/vramaiah
|
2984
3042
|
[@walterking]: https://github.com/walterking
|
2985
3043
|
[@y-yagi]: https://github.com/y-yagi
|
2986
|
-
[@zachmccormick]: https://github.com/zachmccormick
|
3044
|
+
[@zachmccormick]: https://github.com/zachmccormick
|
data/CONTRIBUTING.md
CHANGED
@@ -52,7 +52,7 @@ We welcome code contributions to the library, which you can [submit as a pull re
|
|
52
52
|
|
53
53
|
1. **Fork the repository** from https://github.com/DataDog/dd-trace-rb
|
54
54
|
2. **Make any changes** for your patch.
|
55
|
-
3. **Write tests** that demonstrate how the feature works or how the bug is fixed.
|
55
|
+
3. **Write tests** that demonstrate how the feature works or how the bug is fixed. See the [DevelopmentGuide](https://github.com/DataDog/dd-trace-rb/blob/master/docs/DevelopmentGuide.md) for detailed test instructions.
|
56
56
|
4. **Update any documentation** such as `docs/GettingStarted.md`, especially for new features.
|
57
57
|
5. **Submit the pull request** from your fork back to the latest revision of the `master` branch on https://github.com/DataDog/dd-trace-rb.
|
58
58
|
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
[![Gem](https://img.shields.io/gem/v/ddtrace)](https://rubygems.org/gems/ddtrace/)
|
6
6
|
[![CircleCI](https://circleci.com/gh/DataDog/dd-trace-rb/tree/master.svg?style=svg&circle-token=b0bd5ef866ec7f7b018f48731bb495f2d1372cc1)](https://circleci.com/gh/DataDog/dd-trace-rb/tree/master)
|
7
7
|
[![codecov](https://codecov.io/gh/DataDog/dd-trace-rb/branch/master/graph/badge.svg)](https://app.codecov.io/gh/DataDog/dd-trace-rb/branch/master)
|
8
|
-
[![YARD documentation](https://img.shields.io/badge/YARD-documentation-blue)](https://
|
8
|
+
[![YARD documentation](https://img.shields.io/badge/YARD-documentation-blue)](https://s3.amazonaws.com/gems.datadoghq.com/trace/docs/index.html)
|
9
9
|
|
10
10
|
``ddtrace`` is Datadog’s tracing client for Ruby. It is used to trace requests as they flow across web servers,
|
11
11
|
databases and microservices so that developers have great visiblity into bottlenecks and troublesome requests.
|
@@ -22,7 +22,12 @@ For contributing, checkout the [contribution guidelines][contribution docs] and
|
|
22
22
|
|
23
23
|
[setup docs]: https://docs.datadoghq.com/tracing/setup/ruby/
|
24
24
|
[api docs]: https://github.com/DataDog/dd-trace-rb/blob/master/docs/GettingStarted.md
|
25
|
-
[gem docs]:
|
25
|
+
[gem docs]: https://s3.amazonaws.com/gems.datadoghq.com/trace/docs/index.html
|
26
26
|
[visualization docs]: https://docs.datadoghq.com/tracing/visualization/
|
27
27
|
[contribution docs]: https://github.com/DataDog/dd-trace-rb/blob/master/CONTRIBUTING.md
|
28
28
|
[development docs]: https://github.com/DataDog/dd-trace-rb/blob/master/docs/DevelopmentGuide.md
|
29
|
+
|
30
|
+
## Special thanks
|
31
|
+
|
32
|
+
* [Mike Fiedler](https://github.com/miketheman) for working on a number of Datadog Ruby projects, as well as graciously
|
33
|
+
gifting control of the `datadog` gem
|
data/ddtrace.gemspec
CHANGED
@@ -54,9 +54,12 @@ Gem::Specification.new do |spec|
|
|
54
54
|
|
55
55
|
# Used by the profiler native extension to support older Rubies (see NativeExtensionDesign.md for notes)
|
56
56
|
#
|
57
|
-
#
|
57
|
+
# Most versions of this gem work for us, but 0.10.16 includes an important fix for Ruby 2.5.4 to 2.5.9
|
58
|
+
# (https://github.com/ruby-debug/debase-ruby_core_source/pull/6) so we should keep that as a lower bound going
|
59
|
+
# forward.
|
60
|
+
#
|
58
61
|
# we're pinning it at the latest available version and will manually bump the dependency as needed.
|
59
|
-
spec.add_dependency 'debase-ruby_core_source', '
|
62
|
+
spec.add_dependency 'debase-ruby_core_source', '= 0.10.16'
|
60
63
|
|
61
64
|
# Used by appsec
|
62
65
|
spec.add_dependency 'libddwaf', '~> 1.3.0.2.0'
|
data/docs/GettingStarted.md
CHANGED
@@ -62,6 +62,7 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
|
|
62
62
|
- [MongoDB](#mongodb)
|
63
63
|
- [MySQL2](#mysql2)
|
64
64
|
- [Net/HTTP](#nethttp)
|
65
|
+
- [Postgres](#postgres)
|
65
66
|
- [Presto](#presto)
|
66
67
|
- [Qless](#qless)
|
67
68
|
- [Que](#que)
|
@@ -497,6 +498,7 @@ For a list of available integrations, and their configuration options, please re
|
|
497
498
|
| MongoDB | `mongo` | `>= 2.1` | `>= 2.1` | *[Link](#mongodb)* | *[Link](https://github.com/mongodb/mongo-ruby-driver)* |
|
498
499
|
| MySQL2 | `mysql2` | `>= 0.3.21` | *gem not available* | *[Link](#mysql2)* | *[Link](https://github.com/brianmario/mysql2)* |
|
499
500
|
| Net/HTTP | `http` | *(Any supported Ruby)* | *(Any supported Ruby)* | *[Link](#nethttp)* | *[Link](https://ruby-doc.org/stdlib-2.4.0/libdoc/net/http/rdoc/Net/HTTP.html)* |
|
501
|
+
| Postgres | `pg` | `>= 0.18.4` | *gem not available* | *[Link](#postgres)* | *[Link](https://github.com/ged/ruby-pg)* |
|
500
502
|
| Presto | `presto` | `>= 0.5.14` | `>= 0.5.14` | *[Link](#presto)* | *[Link](https://github.com/treasure-data/presto-client-ruby)* |
|
501
503
|
| Qless | `qless` | `>= 0.10.0` | `>= 0.10.0` | *[Link](#qless)* | *[Link](https://github.com/seomoz/qless)* |
|
502
504
|
| Que | `que` | `>= 1.0.0.beta2` | `>= 1.0.0.beta2` | *[Link](#que)* | *[Link](https://github.com/que-rb/que)* |
|
@@ -1142,6 +1144,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
1142
1144
|
|
1143
1145
|
| Key | Description | Default |
|
1144
1146
|
| --- | ----------- | ------- |
|
1147
|
+
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
|
1145
1148
|
| `service_name` | Service name used for `grpc` instrumentation | `'grpc'` |
|
1146
1149
|
| `error_handler` | Custom error handler invoked when a request is an error. A `Proc` that accepts `span` and `error` parameters. Sets error on the span by default. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
|
1147
1150
|
|
@@ -1369,6 +1372,27 @@ If you wish to configure each connection object individually, you may use the `D
|
|
1369
1372
|
client = Net::HTTP.new(host, port)
|
1370
1373
|
Datadog.configure_onto(client, **options)
|
1371
1374
|
```
|
1375
|
+
### Postgres
|
1376
|
+
|
1377
|
+
The PG integration traces SQL commands sent through the `pg` gem via:
|
1378
|
+
* `exec`, `exec_params`, `exec_prepared`;
|
1379
|
+
* `async_exec`, `async_exec_params`, `async_exec_prepared`; or,
|
1380
|
+
* `sync_exec`, `sync_exec_params`, `sync_exec_prepared`
|
1381
|
+
|
1382
|
+
```ruby
|
1383
|
+
require 'pg'
|
1384
|
+
require 'ddtrace'
|
1385
|
+
|
1386
|
+
Datadog.configure do |c|
|
1387
|
+
c.tracing.instrument :pg, options
|
1388
|
+
end
|
1389
|
+
```
|
1390
|
+
|
1391
|
+
Where `options` is an optional `Hash` that accepts the following parameters:
|
1392
|
+
|
1393
|
+
| Key | Description | Default |
|
1394
|
+
| --- | ----------- | ------- |
|
1395
|
+
| `service_name` | Service name used for `pg` instrumentation | `'pg'` |
|
1372
1396
|
|
1373
1397
|
### Presto
|
1374
1398
|
|
@@ -1556,6 +1580,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
1556
1580
|
| `cache_service` | Cache service name used when tracing cache activity | `'<app_name>-cache'` |
|
1557
1581
|
| `database_service` | Database service name used when tracing database activity | `'<app_name>-<adapter_name>'` |
|
1558
1582
|
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) so that this service trace is connected with a trace of another service if tracing headers are received | `true` |
|
1583
|
+
| `request_queuing` | Track HTTP request time spent in the queue of the frontend server. See [HTTP request queuing](#http-request-queuing) for setup details. Set to `true` to enable. | `false` |
|
1559
1584
|
| `exception_controller` | Class or Module which identifies a custom exception controller class. Tracer provides improved error behavior when it can identify custom exception controllers. By default, without this option, it 'guesses' what a custom exception controller looks like. Providing this option aids this identification. | `nil` |
|
1560
1585
|
| `middleware` | Add the trace middleware to the Rails application. Set to `false` if you don't want the middleware to load. | `true` |
|
1561
1586
|
| `middleware_names` | Enables any short-circuited middleware requests to display the middleware name as a resource for the trace. | `false` |
|
@@ -1757,6 +1782,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
1757
1782
|
| --- | ----------- | ------- |
|
1758
1783
|
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
|
1759
1784
|
| `service_name` | Service name for `rest_client` instrumentation. | `'rest_client'` |
|
1785
|
+
| `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
|
1760
1786
|
|
1761
1787
|
### RSpec
|
1762
1788
|
|
@@ -1867,7 +1893,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
1867
1893
|
| Key | Description | Default |
|
1868
1894
|
| --- | ----------- | ------- |
|
1869
1895
|
| `tag_args` | Enable tagging of job arguments. `true` for on, `false` for off. | `false` |
|
1870
|
-
| `error_handler` | Custom error handler invoked when a job raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc {
|
1896
|
+
| `error_handler` | Custom error handler invoked when a job raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { \|span, error\| span.set_error(error) unless span.nil? }` |
|
1871
1897
|
| `quantize` | Hash containing options for quantization of job arguments. | `{}` |
|
1872
1898
|
|
1873
1899
|
### Sinatra
|
@@ -2639,8 +2665,6 @@ However, additional instrumentation provided by Datadog can be activated alongsi
|
|
2639
2665
|
|
2640
2666
|
### Profiling
|
2641
2667
|
|
2642
|
-
*Currently available as BETA feature.*
|
2643
|
-
|
2644
2668
|
`ddtrace` can produce profiles that measure method-level application resource usage within production environments. These profiles can give insight into resources spent in Ruby code outside of existing trace instrumentation.
|
2645
2669
|
|
2646
2670
|
**Setup**
|
@@ -11,23 +11,23 @@ Components below live inside <../lib/datadog/profiling>:
|
|
11
11
|
* `Collectors::OldStack`: Collects stack trace samples from Ruby threads for both CPU-time (if available) and wall-clock.
|
12
12
|
Runs on its own background thread.
|
13
13
|
* `Collectors::CodeProvenance`: Collects library metadata to power grouping and categorization of stack traces (e.g. to help distinguish user code, from libraries, from the standard library, etc).
|
14
|
-
* `Encoding::Profile`: Encodes gathered data into the pprof format.
|
14
|
+
* `Encoding::Profile::Protobuf`: Encodes gathered data into the pprof format.
|
15
15
|
* `Events::Stack`, `Events::StackSample`: Entity classes used to represent stacks.
|
16
16
|
* `Ext::Forking`: Monkey patches `Kernel#fork`, adding a `Kernel#at_fork` callback mechanism which is used to restore
|
17
17
|
profiling abilities after the VM forks (such as re-instrumenting the main thread, and restarting profiler threads).
|
18
|
-
* `Pprof::*` (in <../lib/datadog/profiling/pprof>):
|
19
|
-
|
20
|
-
* `
|
21
|
-
|
18
|
+
* `Pprof::*` (in <../lib/datadog/profiling/pprof>): Used by `Encoding::Profile::Protobuf` to convert samples captured in
|
19
|
+
the `OldRecorder` into the pprof format.
|
20
|
+
* `Tasks::Setup`: Takes care of loading our extensions/monkey patches to handle `fork()`.
|
21
|
+
* `HttpTransport`: Implements transmission of profiling payloads to the Datadog agent or backend.
|
22
22
|
* `TraceIdentifiers::*`: Used to retrieve trace id and span id from tracers, to be used to connect traces to profiles.
|
23
23
|
* `BacktraceLocation`: Entity class used to represent an entry in a stack trace.
|
24
24
|
* `Buffer`: Bounded buffer used to store profiling events.
|
25
|
-
* `
|
26
|
-
* `Flush`: Entity class used to represent metadata for a given profile.
|
25
|
+
* `Flush`: Entity class used to represent the payload to be reported for a given profile.
|
27
26
|
* `Profiler`: Profiling entry point, which coordinates collectors and a scheduler.
|
28
|
-
* `
|
29
|
-
* `
|
30
|
-
|
27
|
+
* `OldRecorder`: Stores profiling events gathered by the `Collector::OldStack`. (To be removed after migration to libddprof aggregation)
|
28
|
+
* `Exporter`: Gathers data from `OldRecorder` and `Collectors::CodeProvenance` to be reported as a profile.
|
29
|
+
* `Scheduler`: Periodically (every 1 minute) takes data from the `Exporter` and pushes them to the configured transport.
|
30
|
+
Runs on its own background thread.
|
31
31
|
|
32
32
|
## Initialization
|
33
33
|
|
@@ -35,11 +35,10 @@ When started via `ddtracerb exec` (together with `DD_PROFILING_ENABLED=true`), i
|
|
35
35
|
flow:
|
36
36
|
|
37
37
|
1. <../lib/datadog/profiling/preload.rb> triggers the creation of the profiler instance by calling the method `Datadog::Profiling.start_if_enabled`
|
38
|
-
2.
|
39
|
-
|
40
|
-
3. Inside `Datadog::Components`, the `build_profiler` method triggers the execution of the `Tasks::Setup`
|
41
|
-
4. The `Setup` task activates our extensions
|
42
|
-
* `Datadog::Profiling::Ext::Forking`
|
38
|
+
2. Creation of the profiler instance is handled by `Datadog::Configuration`, which triggers the configuration of all
|
39
|
+
`ddtrace` components in `#build_components`
|
40
|
+
3. Inside `Datadog::Components`, the `build_profiler` method triggers the execution of the `Tasks::Setup` task
|
41
|
+
4. The `Setup` task activates our extensions (`Datadog::Profiling::Ext::Forking`)
|
43
42
|
5. Still inside `Datadog::Components`, the `build_profiler` method then creates and wires up the Profiler as such:
|
44
43
|
```asciiflow
|
45
44
|
+------------+
|
@@ -52,17 +51,17 @@ flow:
|
|
52
51
|
+---------+--+ +-+-------+-+
|
53
52
|
| | |
|
54
53
|
v | v
|
55
|
-
+--------+-+ |
|
56
|
-
| OldStack | | |
|
57
|
-
+--------+-+ |
|
54
|
+
+--------+-+ | +----+----------+
|
55
|
+
| OldStack | | | HttpTransport |
|
56
|
+
+--------+-+ | +---------------+
|
58
57
|
| |
|
59
58
|
v v
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
59
|
+
+---------+---+ ++---------+
|
60
|
+
| OldRecorder |<-| Exporter |
|
61
|
+
+-------------+ +-+--------+
|
62
|
+
|
|
63
|
+
v
|
64
|
+
+--------------+--+
|
66
65
|
| Code Provenance |
|
67
66
|
+-----------------+
|
68
67
|
```
|
@@ -73,11 +72,11 @@ flow:
|
|
73
72
|
During run-time, the `Scheduler` and the `Collectors::OldStack` each execute on their own background thread.
|
74
73
|
|
75
74
|
The `Collectors::OldStack` samples stack traces of threads, capturing both CPU-time (if available) and wall-clock, storing
|
76
|
-
them in the `
|
75
|
+
them in the `OldRecorder`.
|
77
76
|
|
78
|
-
The `Scheduler` wakes up every 1 minute to flush the results of the `
|
79
|
-
|
80
|
-
takes care of encoding the data and reporting it to the
|
77
|
+
The `Scheduler` wakes up every 1 minute to flush the results of the `Exporter` into the transport.
|
78
|
+
By default, the `Scheduler` gets created with the default `HttpTransport`, which
|
79
|
+
takes care of encoding the data and reporting it to the Datadog agent.
|
81
80
|
|
82
81
|
## How CPU-time profiling works
|
83
82
|
|
data/docs/UpgradeGuide.md
CHANGED
@@ -41,7 +41,7 @@ static void unload_failed_library(void *handle);
|
|
41
41
|
|
42
42
|
#define DDTRACE_EXPORT __attribute__ ((visibility ("default")))
|
43
43
|
|
44
|
-
void DDTRACE_EXPORT Init_ddtrace_profiling_loader() {
|
44
|
+
void DDTRACE_EXPORT Init_ddtrace_profiling_loader(void) {
|
45
45
|
VALUE datadog_module = rb_define_module("Datadog");
|
46
46
|
VALUE profiling_module = rb_define_module_under(datadog_module, "Profiling");
|
47
47
|
VALUE loader_module = rb_define_module_under(profiling_module, "Loader");
|
@@ -10,13 +10,13 @@ JRuby or TruffleRuby. When below we say "Ruby", read it as "MRI Ruby".
|
|
10
10
|
|
11
11
|
## Disabling
|
12
12
|
|
13
|
-
The profiling native extension can be disabled by setting `DD_PROFILING_NO_EXTENSION=true` when installing
|
13
|
+
The profiling native extension can be disabled by setting `DD_PROFILING_NO_EXTENSION=true` when installing
|
14
14
|
the gem. Setting `DD_PROFILING_NO_EXTENSION` at installation time skips compilation of the extension entirely.
|
15
15
|
|
16
16
|
(If you're a customer and needed to use this, please tell us why on <https://github.com/DataDog/dd-trace-rb/issues/new>.)
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
In past releases, it was possible for the profiler to run without the native extension, but that's no longer the case,
|
19
|
+
and disabling the extension will disable profiling.
|
20
20
|
|
21
21
|
## Must not block or break users that cannot use it
|
22
22
|
|
@@ -44,13 +44,15 @@ We avoid issues using a combination of:
|
|
44
44
|
* Avoiding calling Ruby VM APIs after doing dynamic allocations
|
45
45
|
* Wrapping dynamic allocations into Ruby GC-managed objects (using `TypedData_Wrap_Struct`), so that Ruby will manage
|
46
46
|
their lifetime and call `free` when the GC-managed object is no longer being referenced
|
47
|
+
* Using [`rb_protect` and similar APIs](https://silverhammermba.github.io/emberb/c/?#rescue) to run cleanup code on
|
48
|
+
exception cases
|
47
49
|
|
48
50
|
Non-exhaustive list of APIs that cause exceptions to be raised:
|
49
51
|
|
50
52
|
* `Check_TypedStruct`, `Check_Type`
|
51
53
|
* `rb_funcall`
|
52
54
|
* `rb_thread_call_without_gvl`, `rb_thread_call_without_gvl2`
|
53
|
-
* [Numeric conversion APIs, e.g. `NUM2LONG`, `NUM2INT`, etc.](https://silverhammermba.github.io/emberb/c
|
55
|
+
* [Numeric conversion APIs, e.g. `NUM2LONG`, `NUM2INT`, etc.](https://silverhammermba.github.io/emberb/c/?#translation)
|
54
56
|
* Our `char_slice_from_ruby_string` helper
|
55
57
|
|
56
58
|
## Usage of private VM headers
|
@@ -90,7 +92,6 @@ Thus, even though a regular Ruby installation does not include these files, we c
|
|
90
92
|
## Feature: Getting thread CPU-time clock_ids
|
91
93
|
|
92
94
|
* **OS support**: Linux
|
93
|
-
* **Ruby support**: 2.6+
|
94
95
|
|
95
96
|
To enable CPU-time profiling, we use the `pthread_getcpuclockid(pthread_t thread, clockid_t *clockid)` C function to
|
96
97
|
obtain a `clockid_t` that can then be used with the `Process.clock_gettime` method (or directly with the
|
@@ -13,7 +13,7 @@
|
|
13
13
|
#include "clock_id.h"
|
14
14
|
|
15
15
|
// Validate that our home-cooked pthread_id_for() matches pthread_self() for the current thread
|
16
|
-
void self_test_clock_id() {
|
16
|
+
void self_test_clock_id(void) {
|
17
17
|
rb_nativethread_id_t expected_pthread_id = pthread_self();
|
18
18
|
rb_nativethread_id_t actual_pthread_id = pthread_id_for(rb_thread_current());
|
19
19
|
|