datadog 2.7.1 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +34 -1
  3. data/ext/datadog_profiling_native_extension/collectors_thread_context.c +47 -17
  4. data/ext/datadog_profiling_native_extension/extconf.rb +0 -8
  5. data/ext/datadog_profiling_native_extension/heap_recorder.c +11 -89
  6. data/ext/datadog_profiling_native_extension/private_vm_api_access.c +1 -1
  7. data/ext/datadog_profiling_native_extension/stack_recorder.c +0 -34
  8. data/ext/libdatadog_extconf_helpers.rb +1 -1
  9. data/lib/datadog/appsec/component.rb +1 -8
  10. data/lib/datadog/appsec/contrib/active_record/instrumentation.rb +73 -0
  11. data/lib/datadog/appsec/contrib/active_record/integration.rb +41 -0
  12. data/lib/datadog/appsec/contrib/active_record/patcher.rb +53 -0
  13. data/lib/datadog/appsec/event.rb +1 -1
  14. data/lib/datadog/appsec/processor/context.rb +2 -2
  15. data/lib/datadog/appsec/remote.rb +1 -3
  16. data/lib/datadog/appsec/response.rb +7 -11
  17. data/lib/datadog/appsec.rb +3 -2
  18. data/lib/datadog/core/configuration/components.rb +17 -1
  19. data/lib/datadog/core/configuration/settings.rb +10 -0
  20. data/lib/datadog/core/configuration.rb +9 -1
  21. data/lib/datadog/core/remote/client/capabilities.rb +6 -0
  22. data/lib/datadog/core/remote/client.rb +65 -59
  23. data/lib/datadog/core/telemetry/component.rb +9 -3
  24. data/lib/datadog/core/telemetry/ext.rb +1 -0
  25. data/lib/datadog/di/code_tracker.rb +5 -4
  26. data/lib/datadog/di/component.rb +5 -1
  27. data/lib/datadog/di/contrib/active_record.rb +1 -0
  28. data/lib/datadog/di/init.rb +20 -0
  29. data/lib/datadog/di/instrumenter.rb +81 -11
  30. data/lib/datadog/di/probe.rb +11 -1
  31. data/lib/datadog/di/probe_builder.rb +1 -0
  32. data/lib/datadog/di/probe_manager.rb +4 -1
  33. data/lib/datadog/di/probe_notification_builder.rb +13 -7
  34. data/lib/datadog/di/remote.rb +124 -0
  35. data/lib/datadog/di/serializer.rb +14 -7
  36. data/lib/datadog/di/transport.rb +1 -1
  37. data/lib/datadog/di/utils.rb +7 -0
  38. data/lib/datadog/di.rb +84 -20
  39. data/lib/datadog/profiling/component.rb +4 -16
  40. data/lib/datadog/tracing/configuration/settings.rb +4 -8
  41. data/lib/datadog/tracing/contrib/active_support/cache/redis.rb +16 -4
  42. data/lib/datadog/tracing/contrib/elasticsearch/configuration/settings.rb +4 -0
  43. data/lib/datadog/tracing/contrib/elasticsearch/patcher.rb +6 -1
  44. data/lib/datadog/version.rb +2 -2
  45. data/lib/datadog.rb +3 -0
  46. metadata +17 -13
  47. data/lib/datadog/appsec/processor/actions.rb +0 -49
@@ -368,22 +368,18 @@ module Datadog
368
368
  end
369
369
  end
370
370
 
371
- # [Continuous Integration Visibility](https://docs.datadoghq.com/continuous_integration/) configuration.
371
+ # This is only for internal Datadog use via https://github.com/DataDog/datadog-ci-rb . It should not be
372
+ # used directly.
373
+ #
374
+ # DEV-3.0: Make this a non-public API in the next release.
372
375
  # @public_api
373
376
  settings :test_mode do
374
- # Enable test mode. This allows the tracer to collect spans from test runs.
375
- #
376
- # It also prevents the tracer from collecting spans in a production environment. Only use in a test environment.
377
- #
378
- # @default `DD_TRACE_TEST_MODE_ENABLED` environment variable, otherwise `false`
379
- # @return [Boolean]
380
377
  option :enabled do |o|
381
378
  o.type :bool
382
379
  o.default false
383
380
  o.env Tracing::Configuration::Ext::Test::ENV_MODE_ENABLED
384
381
  end
385
382
 
386
- # Use async writer in test mode
387
383
  option :async do |o|
388
384
  o.type :bool
389
385
  o.default false
@@ -22,17 +22,29 @@ module Datadog
22
22
  # For Rails >= 5.2 w/o redis-activesupport...
23
23
  # ActiveSupport includes a Redis cache store internally, and does not require these overrides.
24
24
  # https://github.com/rails/rails/blob/master/activesupport/lib/active_support/cache/redis_cache_store.rb
25
- def patch_redis?(meth)
25
+ def patch_redis_store?(meth)
26
26
  !Gem.loaded_specs['redis-activesupport'].nil? \
27
27
  && defined?(::ActiveSupport::Cache::RedisStore) \
28
28
  && ::ActiveSupport::Cache::RedisStore.instance_methods(false).include?(meth)
29
29
  end
30
30
 
31
+ # Patches the Rails built-in Redis cache backend `redis_cache_store`, added in Rails 5.2.
32
+ # We avoid loading the RedisCacheStore class, as it invokes the statement `gem "redis", ">= 4.0.1"` which
33
+ # fails if the application is using an old version of Redis, or not using Redis at all.
34
+ # @see https://github.com/rails/rails/blob/d0dcb8fa6073a0c4d42600c15e82e3bb386b27d3/activesupport/lib/active_support/cache/redis_cache_store.rb#L4
35
+ def patch_redis_cache_store?(meth)
36
+ Gem.loaded_specs['redis'] &&
37
+ # Autoload constants return `constant` for `defined?`, but that doesn't mean they are loaded...
38
+ defined?(::ActiveSupport::Cache::RedisCacheStore) &&
39
+ # ... to check that we need to call `autoload?` and check if it returns `nil`, meaning it's loaded.
40
+ ::ActiveSupport::Cache.autoload?(:RedisCacheStore).nil? &&
41
+ ::ActiveSupport::Cache::RedisCacheStore.instance_methods(false).include?(meth)
42
+ end
43
+
31
44
  def cache_store_class(meth)
32
- if patch_redis?(meth)
45
+ if patch_redis_store?(meth)
33
46
  [::ActiveSupport::Cache::RedisStore, ::ActiveSupport::Cache::Store]
34
- elsif Gem.loaded_specs['redis'] && defined?(::ActiveSupport::Cache::RedisCacheStore) \
35
- && ::ActiveSupport::Cache::RedisCacheStore.instance_methods(false).include?(meth)
47
+ elsif patch_redis_cache_store?(meth)
36
48
  [::ActiveSupport::Cache::RedisCacheStore, ::ActiveSupport::Cache::Store]
37
49
  else
38
50
  super
@@ -49,6 +49,10 @@ module Datadog
49
49
  o.type :string, nilable: true
50
50
  o.env Ext::ENV_PEER_SERVICE
51
51
  end
52
+
53
+ option :on_error do |o|
54
+ o.type :proc, nilable: true
55
+ end
52
56
  end
53
57
  end
54
58
  end
@@ -40,6 +40,7 @@ module Datadog
40
40
  # `Client#transport` is the most convenient object both for this integration and the library
41
41
  # as users have shared access to it across all `elasticsearch` versions.
42
42
  service ||= Datadog.configuration_for(transport, :service_name) || datadog_configuration[:service_name]
43
+ on_error = Datadog.configuration_for(transport, :on_error) || datadog_configuration[:on_error]
43
44
 
44
45
  method = args[0]
45
46
  path = args[1]
@@ -49,7 +50,11 @@ module Datadog
49
50
  url = full_url.path
50
51
  response = nil
51
52
 
52
- Tracing.trace(Datadog::Tracing::Contrib::Elasticsearch::Ext::SPAN_QUERY, service: service) do |span|
53
+ Tracing.trace(
54
+ Datadog::Tracing::Contrib::Elasticsearch::Ext::SPAN_QUERY,
55
+ service: service,
56
+ on_error: on_error
57
+ ) do |span|
53
58
  begin
54
59
  connection = transport.connections.first
55
60
  host = connection.host[:host] if connection
@@ -3,8 +3,8 @@
3
3
  module Datadog
4
4
  module VERSION
5
5
  MAJOR = 2
6
- MINOR = 7
7
- PATCH = 1
6
+ MINOR = 8
7
+ PATCH = 0
8
8
  PRE = nil
9
9
  BUILD = nil
10
10
  # PRE and BUILD above are modified for dev gems during gem build GHA workflow
data/lib/datadog.rb CHANGED
@@ -7,4 +7,7 @@ require_relative 'datadog/tracing/contrib'
7
7
  # Load other products (must follow tracing)
8
8
  require_relative 'datadog/profiling'
9
9
  require_relative 'datadog/appsec'
10
+ # Line probes will not work on Ruby < 2.6 because of lack of :script_compiled
11
+ # trace point. Only load DI on supported Ruby versions.
12
+ require_relative 'datadog/di' if RUBY_VERSION >= '2.6'
10
13
  require_relative 'datadog/kit'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datadog
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.1
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Datadog, Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-28 00:00:00.000000000 Z
11
+ date: 2024-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -44,28 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.15.0.0.0
47
+ version: 1.18.0.0.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.15.0.0.0
54
+ version: 1.18.0.0.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: libdatadog
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 14.1.0.1.0
61
+ version: 14.3.1.1.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 14.1.0.1.0
68
+ version: 14.3.1.1.0
69
69
  description: |
70
70
  datadog is Datadog's client library for Ruby. It includes a suite of tools
71
71
  which provide visibility into the performance and security of Ruby applications,
@@ -151,6 +151,9 @@ files:
151
151
  - lib/datadog/appsec/component.rb
152
152
  - lib/datadog/appsec/configuration.rb
153
153
  - lib/datadog/appsec/configuration/settings.rb
154
+ - lib/datadog/appsec/contrib/active_record/instrumentation.rb
155
+ - lib/datadog/appsec/contrib/active_record/integration.rb
156
+ - lib/datadog/appsec/contrib/active_record/patcher.rb
154
157
  - lib/datadog/appsec/contrib/auto_instrument.rb
155
158
  - lib/datadog/appsec/contrib/devise/event.rb
156
159
  - lib/datadog/appsec/contrib/devise/ext.rb
@@ -208,7 +211,6 @@ files:
208
211
  - lib/datadog/appsec/monitor/gateway/watcher.rb
209
212
  - lib/datadog/appsec/monitor/reactive/set_user.rb
210
213
  - lib/datadog/appsec/processor.rb
211
- - lib/datadog/appsec/processor/actions.rb
212
214
  - lib/datadog/appsec/processor/context.rb
213
215
  - lib/datadog/appsec/processor/rule_loader.rb
214
216
  - lib/datadog/appsec/processor/rule_merger.rb
@@ -370,6 +372,7 @@ files:
370
372
  - lib/datadog/di/contrib/active_record.rb
371
373
  - lib/datadog/di/error.rb
372
374
  - lib/datadog/di/extensions.rb
375
+ - lib/datadog/di/init.rb
373
376
  - lib/datadog/di/instrumenter.rb
374
377
  - lib/datadog/di/probe.rb
375
378
  - lib/datadog/di/probe_builder.rb
@@ -377,6 +380,7 @@ files:
377
380
  - lib/datadog/di/probe_notification_builder.rb
378
381
  - lib/datadog/di/probe_notifier_worker.rb
379
382
  - lib/datadog/di/redactor.rb
383
+ - lib/datadog/di/remote.rb
380
384
  - lib/datadog/di/serializer.rb
381
385
  - lib/datadog/di/transport.rb
382
386
  - lib/datadog/di/utils.rb
@@ -898,9 +902,9 @@ licenses:
898
902
  - Apache-2.0
899
903
  metadata:
900
904
  allowed_push_host: https://rubygems.org
901
- changelog_uri: https://github.com/DataDog/dd-trace-rb/blob/v2.7.1/CHANGELOG.md
902
- source_code_uri: https://github.com/DataDog/dd-trace-rb/tree/v2.7.1
903
- post_install_message:
905
+ changelog_uri: https://github.com/DataDog/dd-trace-rb/blob/v2.8.0/CHANGELOG.md
906
+ source_code_uri: https://github.com/DataDog/dd-trace-rb/tree/v2.8.0
907
+ post_install_message:
904
908
  rdoc_options: []
905
909
  require_paths:
906
910
  - lib
@@ -918,8 +922,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
918
922
  - !ruby/object:Gem::Version
919
923
  version: 2.0.0
920
924
  requirements: []
921
- rubygems_version: 3.5.16
922
- signing_key:
925
+ rubygems_version: 3.4.10
926
+ signing_key:
923
927
  specification_version: 4
924
928
  summary: Datadog tracing code for your Ruby applications
925
929
  test_files: []
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Datadog
4
- module AppSec
5
- class Processor
6
- # Actions store the actions information in memory
7
- # Also, takes care of merging when RC send new information
8
- module Actions
9
- class << self
10
- def actions
11
- @actions ||= []
12
- end
13
-
14
- def fetch_configuration(action)
15
- actions.find { |action_configuration| action_configuration['id'] == action }
16
- end
17
-
18
- def merge(actions_to_merge)
19
- return if actions_to_merge.empty?
20
-
21
- if actions.empty?
22
- @actions = actions_to_merge
23
- else
24
- merged_actions = []
25
- actions_dup = actions.dup
26
-
27
- actions_to_merge.each do |new_action|
28
- existing_action = actions_dup.find { |action| new_action['id'] == action['id'] }
29
-
30
- # the old action is discard and the new kept
31
- actions_dup.delete(existing_action) if existing_action
32
- merged_actions << new_action
33
- end
34
-
35
- @actions = merged_actions.concat(actions_dup)
36
- end
37
- end
38
-
39
- private
40
-
41
- # Used in tests
42
- def reset
43
- @actions = []
44
- end
45
- end
46
- end
47
- end
48
- end
49
- end