ddtrace 1.21.1 → 1.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +39 -1
  3. data/ext/datadog_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +32 -12
  4. data/ext/datadog_profiling_native_extension/collectors_thread_context.c +5 -2
  5. data/ext/datadog_profiling_native_extension/heap_recorder.c +45 -3
  6. data/ext/datadog_profiling_native_extension/heap_recorder.h +7 -1
  7. data/ext/datadog_profiling_native_extension/http_transport.c +5 -5
  8. data/ext/datadog_profiling_native_extension/native_extension_helpers.rb +1 -1
  9. data/ext/datadog_profiling_native_extension/stack_recorder.c +7 -9
  10. data/lib/datadog/appsec/contrib/rack/request_middleware.rb +43 -13
  11. data/lib/datadog/appsec/event.rb +1 -1
  12. data/lib/datadog/core/configuration/components.rb +2 -1
  13. data/lib/datadog/core/configuration/option.rb +7 -5
  14. data/lib/datadog/core/configuration/settings.rb +38 -17
  15. data/lib/datadog/core/configuration.rb +20 -4
  16. data/lib/datadog/core/environment/platform.rb +7 -1
  17. data/lib/datadog/core/remote/client/capabilities.rb +1 -1
  18. data/lib/datadog/core/remote/transport/http/config.rb +1 -1
  19. data/lib/datadog/core/telemetry/client.rb +18 -10
  20. data/lib/datadog/core/telemetry/emitter.rb +9 -13
  21. data/lib/datadog/core/telemetry/event.rb +247 -57
  22. data/lib/datadog/core/telemetry/ext.rb +1 -0
  23. data/lib/datadog/core/telemetry/heartbeat.rb +1 -3
  24. data/lib/datadog/core/telemetry/http/ext.rb +4 -1
  25. data/lib/datadog/core/telemetry/http/transport.rb +9 -4
  26. data/lib/datadog/core/telemetry/request.rb +59 -0
  27. data/lib/datadog/profiling/collectors/code_provenance.rb +10 -4
  28. data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +25 -0
  29. data/lib/datadog/profiling/component.rb +23 -15
  30. data/lib/datadog/profiling/load_native_extension.rb +14 -1
  31. data/lib/datadog/profiling.rb +11 -0
  32. data/lib/datadog/tracing/sampling/matcher.rb +23 -3
  33. data/lib/datadog/tracing/sampling/rule.rb +7 -2
  34. data/lib/datadog/tracing/sampling/rule_sampler.rb +2 -0
  35. data/lib/ddtrace/version.rb +2 -2
  36. metadata +6 -17
  37. data/lib/datadog/core/telemetry/collector.rb +0 -250
  38. data/lib/datadog/core/telemetry/v1/app_event.rb +0 -59
  39. data/lib/datadog/core/telemetry/v1/application.rb +0 -92
  40. data/lib/datadog/core/telemetry/v1/configuration.rb +0 -25
  41. data/lib/datadog/core/telemetry/v1/dependency.rb +0 -43
  42. data/lib/datadog/core/telemetry/v1/host.rb +0 -59
  43. data/lib/datadog/core/telemetry/v1/install_signature.rb +0 -38
  44. data/lib/datadog/core/telemetry/v1/integration.rb +0 -64
  45. data/lib/datadog/core/telemetry/v1/product.rb +0 -36
  46. data/lib/datadog/core/telemetry/v1/telemetry_request.rb +0 -106
  47. data/lib/datadog/core/telemetry/v2/app_client_configuration_change.rb +0 -41
  48. data/lib/datadog/core/telemetry/v2/request.rb +0 -29
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Datadog
4
- module Core
5
- module Telemetry
6
- module V1
7
- # Describes payload for telemetry V1 API app-integrations-change event
8
- class AppEvent
9
- attr_reader \
10
- :additional_payload,
11
- :configuration,
12
- :dependencies,
13
- :install_signature,
14
- :integrations
15
-
16
- # @param additional_payload [Array<Telemetry::V1::Configuration>] List of Additional payload to track (any key
17
- # value not mentioned and doesn't fit under a metric)
18
- # @param configuration [Array<Telemetry::V1::Configuration>] List of Tracer related configuration data
19
- # @param dependencies [Array<Telemetry::V1::Dependency>] List of all loaded modules requested by the app
20
- # @param install_signature [Telemetry::V1::InstallSignature] Install signature data
21
- # @param integrations [Array<Telemetry::V1::Integration>] List of integrations that are available within the app
22
- # and applicable to be traced
23
- def initialize(
24
- additional_payload: nil, configuration: nil, dependencies: nil, install_signature: nil,
25
- integrations: nil
26
- )
27
- @additional_payload = additional_payload
28
- @configuration = configuration
29
- @dependencies = dependencies
30
- @install_signature = install_signature
31
- @integrations = integrations
32
- end
33
-
34
- def to_h
35
- {}.tap do |hash|
36
- hash[:additional_payload] = map_hash(@additional_payload) if @additional_payload
37
- hash[:configuration] = map_hash(@configuration) if @configuration
38
- hash[:dependencies] = map_array(@dependencies) if @dependencies
39
- hash[:install_signature] = @install_signature.to_h if @install_signature
40
- hash[:integrations] = map_array(@integrations) if @integrations
41
- end
42
- end
43
-
44
- private
45
-
46
- def map_hash(hash)
47
- hash.map do |k, v|
48
- { name: k.to_s, value: v }
49
- end
50
- end
51
-
52
- def map_array(arr)
53
- arr.map(&:to_h)
54
- end
55
- end
56
- end
57
- end
58
- end
59
- end
@@ -1,92 +0,0 @@
1
- require_relative '../../utils/hash'
2
-
3
- module Datadog
4
- module Core
5
- module Telemetry
6
- module V1
7
- # Describes attributes for application environment object
8
- class Application
9
- using Core::Utils::Hash::Refinement
10
-
11
- ERROR_NIL_LANGUAGE_NAME_MESSAGE = ':language_name must not be nil'.freeze
12
- ERROR_NIL_LANGUAGE_VERSION_MESSAGE = ':language_version must not be nil'.freeze
13
- ERROR_NIL_SERVICE_NAME_MESSAGE = ':service_name must not be nil'.freeze
14
- ERROR_NIL_TRACER_VERSION_MESSAGE = ':tracer_version must not be nil'.freeze
15
-
16
- attr_reader \
17
- :env,
18
- :language_name,
19
- :language_version,
20
- :products,
21
- :runtime_name,
22
- :runtime_patches,
23
- :runtime_version,
24
- :service_name,
25
- :service_version,
26
- :tracer_version
27
-
28
- # @param env [String] Service's environment
29
- # @param language_name [String] 'ruby'
30
- # @param language_version [String] Version of language used
31
- # @param products [Telemetry::V1::Product] Contains information about specific products added to the environment
32
- # @param runtime_name [String] Runtime being used
33
- # @param runtime_patches [String] String of patches applied to the runtime
34
- # @param runtime_version [String] Runtime version; potentially the same as :language_version
35
- # @param service_name [String] Service’s name (DD_SERVICE)
36
- # @param service_version [String] Service’s version (DD_VERSION)
37
- # @param tracer_version [String] Version of the used tracer
38
- def initialize(
39
- language_name:, language_version:, service_name:, tracer_version:, env: nil, products: nil,
40
- runtime_name: nil, runtime_patches: nil, runtime_version: nil, service_version: nil
41
- )
42
- validate(
43
- language_name: language_name,
44
- language_version: language_version,
45
- service_name: service_name,
46
- tracer_version: tracer_version
47
- )
48
- @env = env
49
- @language_name = language_name
50
- @language_version = language_version
51
- @products = products
52
- @runtime_name = runtime_name
53
- @runtime_patches = runtime_patches
54
- @runtime_version = runtime_version
55
- @service_name = service_name
56
- @service_version = service_version
57
- @tracer_version = tracer_version
58
- end
59
-
60
- def to_h
61
- hash = {
62
- env: @env,
63
- language_name: @language_name,
64
- language_version: @language_version,
65
- products: @products.to_h,
66
- runtime_name: @runtime_name,
67
- runtime_patches: @runtime_patches,
68
- runtime_version: @runtime_version,
69
- service_name: @service_name,
70
- service_version: @service_version,
71
- tracer_version: @tracer_version
72
- }
73
- hash.compact!
74
- hash
75
- end
76
-
77
- private
78
-
79
- # Validates required arguments passed to the class on initialization are not nil
80
- #
81
- # @!visibility private
82
- def validate(language_name:, language_version:, service_name:, tracer_version:)
83
- raise ArgumentError, ERROR_NIL_LANGUAGE_NAME_MESSAGE if language_name.nil?
84
- raise ArgumentError, ERROR_NIL_LANGUAGE_VERSION_MESSAGE if language_version.nil?
85
- raise ArgumentError, ERROR_NIL_SERVICE_NAME_MESSAGE if service_name.nil?
86
- raise ArgumentError, ERROR_NIL_TRACER_VERSION_MESSAGE if tracer_version.nil?
87
- end
88
- end
89
- end
90
- end
91
- end
92
- end
@@ -1,25 +0,0 @@
1
- module Datadog
2
- module Core
3
- module Telemetry
4
- module V1
5
- # Describes attributes for additional payload or configuration object
6
- class Configuration
7
- ERROR_NIL_NAME_MESSAGE = ':name must not be nil'.freeze
8
-
9
- attr_reader \
10
- :name,
11
- :value
12
-
13
- # @param name [String] Configuration/additional payload attribute name
14
- # @param value [String, Integer, Boolean] Corresponding value
15
- def initialize(name:, value: nil)
16
- raise ArgumentError, ERROR_NIL_NAME_MESSAGE if name.nil?
17
-
18
- @name = name
19
- @value = value
20
- end
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,43 +0,0 @@
1
- require_relative '../../utils/hash'
2
-
3
- module Datadog
4
- module Core
5
- module Telemetry
6
- module V1
7
- # Describes attributes for dependency object
8
- class Dependency
9
- using Core::Utils::Hash::Refinement
10
-
11
- ERROR_NIL_NAME_MESSAGE = ':name must not be nil'.freeze
12
-
13
- attr_reader \
14
- :hash,
15
- :name,
16
- :version
17
-
18
- # @param name [String] Module name
19
- # @param version [String] Version of resolved module
20
- # @param hash [String] Dependency hash, in case `version` is not available
21
- def initialize(name:, version: nil, hash: nil)
22
- raise ArgumentError, ERROR_NIL_NAME_MESSAGE if name.nil?
23
- raise ArgumentError, 'if both :version and :hash exist, use :version only' if version && hash
24
-
25
- @hash = hash
26
- @name = name
27
- @version = version
28
- end
29
-
30
- def to_h
31
- hash = {
32
- hash: @hash,
33
- name: @name,
34
- version: @version
35
- }
36
- hash.compact!
37
- hash
38
- end
39
- end
40
- end
41
- end
42
- end
43
- end
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../../utils/hash'
4
-
5
- module Datadog
6
- module Core
7
- module Telemetry
8
- module V1
9
- # Describes attributes for host object
10
- class Host
11
- using Core::Utils::Hash::Refinement
12
-
13
- attr_reader \
14
- :container_id,
15
- :hostname,
16
- :kernel_name,
17
- :kernel_release,
18
- :kernel_version,
19
- :os_version,
20
- :os
21
-
22
- # @param container_id [String] Docker container ID
23
- # @param hostname [String] uname -n
24
- # @param kernel_name [String] uname -s
25
- # @param kernel_release [String] uname -r
26
- # @param kernel_version [String] uname -v
27
- # @param os [String] uname -o
28
- # @param os_version [String] Version of OS running
29
- def initialize(
30
- container_id: nil, hostname: nil, kernel_name: nil, kernel_release: nil, kernel_version: nil,
31
- os_version: nil, os: nil
32
- )
33
- @container_id = container_id
34
- @hostname = hostname
35
- @kernel_name = kernel_name
36
- @kernel_release = kernel_release
37
- @kernel_version = kernel_version
38
- @os = os
39
- @os_version = os_version
40
- end
41
-
42
- def to_h
43
- hash = {
44
- container_id: @container_id,
45
- hostname: @hostname,
46
- kernel_name: @kernel_name,
47
- kernel_release: @kernel_release,
48
- kernel_version: @kernel_version,
49
- os: @os,
50
- os_version: @os_version,
51
- }
52
- hash.compact!
53
- hash
54
- end
55
- end
56
- end
57
- end
58
- end
59
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Datadog
4
- module Core
5
- module Telemetry
6
- module V1
7
- # Describes attributes for install signature
8
- class InstallSignature
9
- using Core::Utils::Hash::Refinement
10
-
11
- attr_reader \
12
- :install_id,
13
- :install_type,
14
- :install_time
15
-
16
- # @param id [String,nil] Install ID
17
- # @param type [String,nil] Install type
18
- # @param type [String,nil] Install time
19
- def initialize(install_id:, install_type:, install_time:)
20
- @install_id = install_id
21
- @install_type = install_type
22
- @install_time = install_time
23
- end
24
-
25
- def to_h
26
- hash = {
27
- install_id: @install_id,
28
- install_type: @install_type,
29
- install_time: @install_time
30
- }
31
- hash.compact!
32
- hash
33
- end
34
- end
35
- end
36
- end
37
- end
38
- end
@@ -1,64 +0,0 @@
1
- require_relative '../../utils/hash'
2
-
3
- module Datadog
4
- module Core
5
- module Telemetry
6
- module V1
7
- # Describes attributes for integration object
8
- class Integration
9
- using Core::Utils::Hash::Refinement
10
-
11
- ERROR_NIL_ENABLED_MESSAGE = ':enabled must not be nil'.freeze
12
- ERROR_NIL_NAME_MESSAGE = ':name must not be nil'.freeze
13
-
14
- attr_reader \
15
- :auto_enabled,
16
- :compatible,
17
- :enabled,
18
- :error,
19
- :name,
20
- :version
21
-
22
- # @param enabled [Boolean] Whether integration is enabled at time of request
23
- # @param name [String] Integration name
24
- # @param auto_enabled [Boolean] If integration is not enabled by default, but by user choice
25
- # @param compatible [Boolean] If integration is available, but incompatible
26
- # @param error [String] Error message if integration fails to load
27
- # @param version [String] Integration version (if specified in app-started, it should be for other events too)
28
- def initialize(enabled:, name:, auto_enabled: nil, compatible: nil, error: nil, version: nil)
29
- validate(enabled: enabled, name: name)
30
- @auto_enabled = auto_enabled
31
- @compatible = compatible
32
- @enabled = enabled
33
- @error = error
34
- @name = name
35
- @version = version
36
- end
37
-
38
- def to_h
39
- hash = {
40
- auto_enabled: @auto_enabled,
41
- compatible: @compatible,
42
- enabled: @enabled,
43
- error: @error,
44
- name: @name,
45
- version: @version
46
- }
47
- hash.compact!
48
- hash
49
- end
50
-
51
- private
52
-
53
- # Validates all required arguments passed to the class on initialization are not nil
54
- #
55
- # @!visibility private
56
- def validate(enabled:, name:)
57
- raise ArgumentError, ERROR_NIL_ENABLED_MESSAGE if enabled.nil?
58
- raise ArgumentError, ERROR_NIL_NAME_MESSAGE if name.nil?
59
- end
60
- end
61
- end
62
- end
63
- end
64
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../../utils/hash'
4
-
5
- module Datadog
6
- module Core
7
- module Telemetry
8
- module V1
9
- # Describes attributes for products object
10
- class Product
11
- using Core::Utils::Hash::Refinement
12
-
13
- attr_reader \
14
- :appsec,
15
- :profiler
16
-
17
- # @param appsec [Telemetry::V1::AppSec] Holds custom information about the appsec product
18
- # @param profiler [Telemetry::V1::Profiler] Holds custom information about the profiler product
19
- def initialize(appsec: nil, profiler: nil)
20
- @appsec = appsec
21
- @profiler = profiler
22
- end
23
-
24
- def to_h
25
- hash = {
26
- appsec: @appsec,
27
- profiler: @profiler
28
- }
29
- hash.compact!
30
- hash
31
- end
32
- end
33
- end
34
- end
35
- end
36
- end
@@ -1,106 +0,0 @@
1
- require_relative '../../utils/hash'
2
-
3
- module Datadog
4
- module Core
5
- module Telemetry
6
- module V1
7
- # Describes attributes for telemetry API request
8
- class TelemetryRequest
9
- using Core::Utils::Hash::Refinement
10
-
11
- ERROR_NIL_API_VERSION_MESSAGE = ':api_version must not be nil'.freeze
12
- ERROR_NIL_APPLICATION_MESSAGE = ':application must not be nil'.freeze
13
- ERROR_NIL_HOST_MESSAGE = ':host must not be nil'.freeze
14
- ERROR_NIL_PAYLOAD_MESSAGE = ':payload must not be nil'.freeze
15
- ERROR_NIL_REQUEST_TYPE_MESSAGE = ':request_type must not be nil'.freeze
16
- ERROR_NIL_RUNTIME_ID_MESSAGE = ':runtime_id must not be nil'.freeze
17
- ERROR_NIL_SEQ_ID_MESSAGE = ':seq_id must not be nil'.freeze
18
- ERROR_NIL_TRACER_TIME_MESSAGE = ':tracer_time must not be nil'.freeze
19
-
20
- attr_reader \
21
- :api_version,
22
- :application,
23
- :debug,
24
- :host,
25
- :payload,
26
- :request_type,
27
- :runtime_id,
28
- :seq_id,
29
- :session_id,
30
- :tracer_time
31
-
32
- # @param api_version [String] Requested API version, `v1`
33
- # @param application [Telemetry::V1::Application] Object that contains information about the environment of the
34
- # application
35
- # @param host [Telemetry::V1::Host] Object that holds host related information
36
- # @param payload [Telemetry::V1::AppEvent] The payload of the request, type impacted by :request_type
37
- # @param request_type [String] Requested API function impacting the Payload type, `app-started`
38
- # @param runtime_id [String] V4 UUID that represents a tracer session
39
- # @param seq_id [Integer] Counter that should be auto incremented every time an API call is being made
40
- # @param tracer_time [Integer] Unix timestamp (in seconds) of when the message is being sent
41
- # @param debug [Boolean] Flag that enables payload debug mode
42
- # @param session_id [String] V4 UUID that represents the session of the top level tracer process, often same\
43
- # as runtime_id
44
- def initialize(
45
- api_version:, application:, host:, payload:, request_type:, runtime_id:, seq_id:, tracer_time:,
46
- debug: nil, session_id: nil
47
- )
48
- validate(
49
- api_version: api_version,
50
- application: application,
51
- host: host,
52
- payload: payload,
53
- request_type: request_type,
54
- runtime_id: runtime_id,
55
- seq_id: seq_id,
56
- tracer_time: tracer_time
57
- )
58
- @api_version = api_version
59
- @application = application
60
- @debug = debug
61
- @host = host
62
- @payload = payload
63
- @request_type = request_type
64
- @runtime_id = runtime_id
65
- @seq_id = seq_id
66
- @session_id = session_id
67
- @tracer_time = tracer_time
68
- end
69
-
70
- def to_h
71
- hash = {
72
- api_version: @api_version,
73
- application: @application.to_h,
74
- debug: @debug,
75
- host: @host.to_h,
76
- payload: @payload.to_h,
77
- request_type: @request_type,
78
- runtime_id: @runtime_id,
79
- seq_id: @seq_id,
80
- session_id: @session_id,
81
- tracer_time: @tracer_time
82
- }
83
- hash.compact!
84
- hash
85
- end
86
-
87
- private
88
-
89
- # Validates all required arguments passed to the class on initialization are not nil
90
- #
91
- # @!visibility private
92
- def validate(api_version:, application:, host:, payload:, request_type:, runtime_id:, seq_id:, tracer_time:)
93
- raise ArgumentError, ERROR_NIL_API_VERSION_MESSAGE if api_version.nil?
94
- raise ArgumentError, ERROR_NIL_APPLICATION_MESSAGE if application.nil?
95
- raise ArgumentError, ERROR_NIL_HOST_MESSAGE if host.nil?
96
- raise ArgumentError, ERROR_NIL_PAYLOAD_MESSAGE if payload.nil?
97
- raise ArgumentError, ERROR_NIL_REQUEST_TYPE_MESSAGE if request_type.nil?
98
- raise ArgumentError, ERROR_NIL_RUNTIME_ID_MESSAGE if runtime_id.nil?
99
- raise ArgumentError, ERROR_NIL_SEQ_ID_MESSAGE if seq_id.nil?
100
- raise ArgumentError, ERROR_NIL_TRACER_TIME_MESSAGE if tracer_time.nil?
101
- end
102
- end
103
- end
104
- end
105
- end
106
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'request'
4
-
5
- module Datadog
6
- module Core
7
- module Telemetry
8
- module V2
9
- # Telemetry 'app-client-configuration-change' event.
10
- # This request should contain client library configuration that have changes since the app-started event.
11
- class AppClientConfigurationChange < Request
12
- def initialize(configuration_changes, origin: 'unknown')
13
- super('app-client-configuration-change')
14
-
15
- @configuration_changes = configuration_changes
16
- @origin = origin
17
- end
18
-
19
- # @see [Request#to_h]
20
- def to_h
21
- super.merge(payload: payload)
22
- end
23
-
24
- private
25
-
26
- def payload
27
- {
28
- configuration: @configuration_changes.map do |name, value|
29
- {
30
- name: name,
31
- value: value,
32
- origin: @origin,
33
- }
34
- end
35
- }
36
- end
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Datadog
4
- module Core
5
- module Telemetry
6
- module V2
7
- # Base request object for Telemetry V2.
8
- #
9
- # `#to_h` is the main API, which returns a Ruby
10
- # Hash that will be serialized as JSON.
11
- class Request
12
- # @param [String] request_type the Telemetry request type, which dictates how the Hash payload should be processed
13
- def initialize(request_type)
14
- @request_type = request_type
15
- end
16
-
17
- # Converts this request to a Hash that will
18
- # be serialized as JSON.
19
- # @return [Hash]
20
- def to_h
21
- {
22
- request_type: @request_type
23
- }
24
- end
25
- end
26
- end
27
- end
28
- end
29
- end