datadog 2.7.1 → 2.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 +69 -1
- data/ext/datadog_profiling_native_extension/clock_id.h +2 -2
- data/ext/datadog_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +64 -54
- data/ext/datadog_profiling_native_extension/collectors_discrete_dynamic_sampler.c +1 -1
- data/ext/datadog_profiling_native_extension/collectors_discrete_dynamic_sampler.h +1 -1
- data/ext/datadog_profiling_native_extension/collectors_idle_sampling_helper.c +16 -16
- data/ext/datadog_profiling_native_extension/collectors_stack.c +7 -7
- data/ext/datadog_profiling_native_extension/collectors_thread_context.c +259 -132
- data/ext/datadog_profiling_native_extension/extconf.rb +0 -8
- data/ext/datadog_profiling_native_extension/heap_recorder.c +11 -89
- data/ext/datadog_profiling_native_extension/heap_recorder.h +1 -1
- data/ext/datadog_profiling_native_extension/http_transport.c +4 -4
- data/ext/datadog_profiling_native_extension/private_vm_api_access.c +4 -1
- data/ext/datadog_profiling_native_extension/private_vm_api_access.h +3 -1
- data/ext/datadog_profiling_native_extension/profiling.c +10 -8
- data/ext/datadog_profiling_native_extension/ruby_helpers.c +8 -8
- data/ext/datadog_profiling_native_extension/stack_recorder.c +54 -88
- data/ext/datadog_profiling_native_extension/stack_recorder.h +1 -1
- data/ext/datadog_profiling_native_extension/time_helpers.h +1 -1
- data/ext/datadog_profiling_native_extension/unsafe_api_calls_check.c +47 -0
- data/ext/datadog_profiling_native_extension/unsafe_api_calls_check.h +31 -0
- data/ext/libdatadog_api/crashtracker.c +3 -0
- data/ext/libdatadog_extconf_helpers.rb +1 -1
- data/lib/datadog/appsec/assets/waf_rules/recommended.json +355 -157
- data/lib/datadog/appsec/assets/waf_rules/strict.json +62 -32
- data/lib/datadog/appsec/component.rb +1 -8
- data/lib/datadog/appsec/context.rb +54 -0
- data/lib/datadog/appsec/contrib/active_record/instrumentation.rb +73 -0
- data/lib/datadog/appsec/contrib/active_record/integration.rb +41 -0
- data/lib/datadog/appsec/contrib/active_record/patcher.rb +53 -0
- data/lib/datadog/appsec/contrib/devise/patcher/authenticatable_patch.rb +6 -6
- data/lib/datadog/appsec/contrib/devise/patcher/registration_controller_patch.rb +4 -4
- data/lib/datadog/appsec/contrib/graphql/gateway/watcher.rb +19 -28
- data/lib/datadog/appsec/contrib/graphql/reactive/multiplex.rb +5 -5
- data/lib/datadog/appsec/contrib/rack/gateway/response.rb +3 -3
- data/lib/datadog/appsec/contrib/rack/gateway/watcher.rb +64 -96
- data/lib/datadog/appsec/contrib/rack/reactive/request.rb +10 -10
- data/lib/datadog/appsec/contrib/rack/reactive/request_body.rb +5 -5
- data/lib/datadog/appsec/contrib/rack/reactive/response.rb +6 -6
- data/lib/datadog/appsec/contrib/rack/request_body_middleware.rb +10 -11
- data/lib/datadog/appsec/contrib/rack/request_middleware.rb +43 -49
- data/lib/datadog/appsec/contrib/rails/gateway/watcher.rb +21 -32
- data/lib/datadog/appsec/contrib/rails/patcher.rb +1 -1
- data/lib/datadog/appsec/contrib/rails/reactive/action.rb +6 -6
- data/lib/datadog/appsec/contrib/sinatra/gateway/watcher.rb +41 -63
- data/lib/datadog/appsec/contrib/sinatra/patcher.rb +2 -2
- data/lib/datadog/appsec/contrib/sinatra/reactive/routed.rb +5 -5
- data/lib/datadog/appsec/event.rb +6 -6
- data/lib/datadog/appsec/ext.rb +3 -1
- data/lib/datadog/appsec/monitor/gateway/watcher.rb +22 -32
- data/lib/datadog/appsec/monitor/reactive/set_user.rb +5 -5
- data/lib/datadog/appsec/processor/context.rb +2 -2
- data/lib/datadog/appsec/processor/rule_loader.rb +0 -3
- data/lib/datadog/appsec/remote.rb +1 -3
- data/lib/datadog/appsec/response.rb +7 -11
- data/lib/datadog/appsec.rb +6 -5
- data/lib/datadog/auto_instrument.rb +3 -0
- data/lib/datadog/core/configuration/agent_settings_resolver.rb +39 -11
- data/lib/datadog/core/configuration/components.rb +20 -2
- data/lib/datadog/core/configuration/settings.rb +10 -0
- data/lib/datadog/core/configuration.rb +10 -2
- data/lib/datadog/{tracing → core}/contrib/rails/utils.rb +1 -3
- data/lib/datadog/core/crashtracking/component.rb +1 -3
- data/lib/datadog/core/remote/client/capabilities.rb +6 -0
- data/lib/datadog/core/remote/client.rb +65 -59
- data/lib/datadog/core/telemetry/component.rb +9 -3
- data/lib/datadog/core/telemetry/event.rb +87 -3
- data/lib/datadog/core/telemetry/ext.rb +1 -0
- data/lib/datadog/core/telemetry/logging.rb +2 -2
- data/lib/datadog/core/telemetry/metric.rb +22 -0
- data/lib/datadog/core/telemetry/worker.rb +33 -0
- data/lib/datadog/di/base.rb +115 -0
- data/lib/datadog/di/code_tracker.rb +11 -7
- data/lib/datadog/di/component.rb +21 -11
- data/lib/datadog/di/configuration/settings.rb +11 -1
- data/lib/datadog/di/contrib/active_record.rb +1 -0
- data/lib/datadog/di/contrib/railtie.rb +15 -0
- data/lib/datadog/di/contrib.rb +26 -0
- data/lib/datadog/di/error.rb +5 -0
- data/lib/datadog/di/instrumenter.rb +111 -20
- data/lib/datadog/di/preload.rb +18 -0
- data/lib/datadog/di/probe.rb +11 -1
- data/lib/datadog/di/probe_builder.rb +1 -0
- data/lib/datadog/di/probe_manager.rb +8 -5
- data/lib/datadog/di/probe_notification_builder.rb +27 -7
- data/lib/datadog/di/probe_notifier_worker.rb +5 -6
- data/lib/datadog/di/remote.rb +124 -0
- data/lib/datadog/di/serializer.rb +14 -7
- data/lib/datadog/di/transport.rb +3 -5
- data/lib/datadog/di/utils.rb +7 -0
- data/lib/datadog/di.rb +23 -62
- data/lib/datadog/kit/appsec/events.rb +3 -3
- data/lib/datadog/kit/identity.rb +4 -4
- data/lib/datadog/profiling/component.rb +59 -69
- data/lib/datadog/profiling/http_transport.rb +1 -26
- data/lib/datadog/tracing/configuration/settings.rb +4 -8
- data/lib/datadog/tracing/contrib/action_cable/integration.rb +5 -2
- data/lib/datadog/tracing/contrib/action_mailer/integration.rb +6 -2
- data/lib/datadog/tracing/contrib/action_pack/integration.rb +5 -2
- data/lib/datadog/tracing/contrib/action_view/integration.rb +5 -2
- data/lib/datadog/tracing/contrib/active_job/integration.rb +5 -2
- data/lib/datadog/tracing/contrib/active_record/integration.rb +6 -2
- data/lib/datadog/tracing/contrib/active_support/cache/events/cache.rb +3 -1
- data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +3 -1
- data/lib/datadog/tracing/contrib/active_support/cache/redis.rb +16 -4
- data/lib/datadog/tracing/contrib/active_support/configuration/settings.rb +10 -0
- data/lib/datadog/tracing/contrib/active_support/integration.rb +5 -2
- data/lib/datadog/tracing/contrib/auto_instrument.rb +2 -2
- data/lib/datadog/tracing/contrib/aws/integration.rb +3 -0
- data/lib/datadog/tracing/contrib/concurrent_ruby/integration.rb +3 -0
- data/lib/datadog/tracing/contrib/elasticsearch/configuration/settings.rb +4 -0
- data/lib/datadog/tracing/contrib/elasticsearch/patcher.rb +6 -1
- data/lib/datadog/tracing/contrib/httprb/integration.rb +3 -0
- data/lib/datadog/tracing/contrib/kafka/integration.rb +3 -0
- data/lib/datadog/tracing/contrib/mongodb/integration.rb +3 -0
- data/lib/datadog/tracing/contrib/opensearch/integration.rb +3 -0
- data/lib/datadog/tracing/contrib/presto/integration.rb +3 -0
- data/lib/datadog/tracing/contrib/rack/integration.rb +2 -2
- data/lib/datadog/tracing/contrib/rails/framework.rb +2 -2
- data/lib/datadog/tracing/contrib/rails/patcher.rb +1 -1
- data/lib/datadog/tracing/contrib/rest_client/integration.rb +3 -0
- data/lib/datadog/tracing/span.rb +12 -4
- data/lib/datadog/tracing/span_event.rb +123 -3
- data/lib/datadog/tracing/span_operation.rb +6 -0
- data/lib/datadog/tracing/transport/serializable_trace.rb +24 -6
- data/lib/datadog/version.rb +2 -2
- data/lib/datadog.rb +3 -0
- metadata +30 -17
- data/lib/datadog/appsec/processor/actions.rb +0 -49
- data/lib/datadog/appsec/reactive/operation.rb +0 -68
- data/lib/datadog/appsec/scope.rb +0 -58
- data/lib/datadog/core/crashtracking/agent_base_url.rb +0 -21
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.
|
4
|
+
version: 2.9.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:
|
11
|
+
date: 2025-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -31,6 +31,9 @@ dependencies:
|
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '3.3'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 3.3.7
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -38,34 +41,37 @@ dependencies:
|
|
38
41
|
- - "~>"
|
39
42
|
- !ruby/object:Gem::Version
|
40
43
|
version: '3.3'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 3.3.7
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: libddwaf
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
51
|
- - "~>"
|
46
52
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.
|
53
|
+
version: 1.18.0.0.0
|
48
54
|
type: :runtime
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
51
57
|
requirements:
|
52
58
|
- - "~>"
|
53
59
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
60
|
+
version: 1.18.0.0.0
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
62
|
name: libdatadog
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
65
|
- - "~>"
|
60
66
|
- !ruby/object:Gem::Version
|
61
|
-
version: 14.1.
|
67
|
+
version: 14.3.1.1.0
|
62
68
|
type: :runtime
|
63
69
|
prerelease: false
|
64
70
|
version_requirements: !ruby/object:Gem::Requirement
|
65
71
|
requirements:
|
66
72
|
- - "~>"
|
67
73
|
- !ruby/object:Gem::Version
|
68
|
-
version: 14.1.
|
74
|
+
version: 14.3.1.1.0
|
69
75
|
description: |
|
70
76
|
datadog is Datadog's client library for Ruby. It includes a suite of tools
|
71
77
|
which provide visibility into the performance and security of Ruby applications,
|
@@ -130,6 +136,8 @@ files:
|
|
130
136
|
- ext/datadog_profiling_native_extension/stack_recorder.h
|
131
137
|
- ext/datadog_profiling_native_extension/time_helpers.c
|
132
138
|
- ext/datadog_profiling_native_extension/time_helpers.h
|
139
|
+
- ext/datadog_profiling_native_extension/unsafe_api_calls_check.c
|
140
|
+
- ext/datadog_profiling_native_extension/unsafe_api_calls_check.h
|
133
141
|
- ext/libdatadog_api/crashtracker.c
|
134
142
|
- ext/libdatadog_api/datadog_ruby_common.c
|
135
143
|
- ext/libdatadog_api/datadog_ruby_common.h
|
@@ -151,6 +159,10 @@ files:
|
|
151
159
|
- lib/datadog/appsec/component.rb
|
152
160
|
- lib/datadog/appsec/configuration.rb
|
153
161
|
- lib/datadog/appsec/configuration/settings.rb
|
162
|
+
- lib/datadog/appsec/context.rb
|
163
|
+
- lib/datadog/appsec/contrib/active_record/instrumentation.rb
|
164
|
+
- lib/datadog/appsec/contrib/active_record/integration.rb
|
165
|
+
- lib/datadog/appsec/contrib/active_record/patcher.rb
|
154
166
|
- lib/datadog/appsec/contrib/auto_instrument.rb
|
155
167
|
- lib/datadog/appsec/contrib/devise/event.rb
|
156
168
|
- lib/datadog/appsec/contrib/devise/ext.rb
|
@@ -208,19 +220,16 @@ files:
|
|
208
220
|
- lib/datadog/appsec/monitor/gateway/watcher.rb
|
209
221
|
- lib/datadog/appsec/monitor/reactive/set_user.rb
|
210
222
|
- lib/datadog/appsec/processor.rb
|
211
|
-
- lib/datadog/appsec/processor/actions.rb
|
212
223
|
- lib/datadog/appsec/processor/context.rb
|
213
224
|
- lib/datadog/appsec/processor/rule_loader.rb
|
214
225
|
- lib/datadog/appsec/processor/rule_merger.rb
|
215
226
|
- lib/datadog/appsec/rate_limiter.rb
|
216
227
|
- lib/datadog/appsec/reactive/address_hash.rb
|
217
228
|
- lib/datadog/appsec/reactive/engine.rb
|
218
|
-
- lib/datadog/appsec/reactive/operation.rb
|
219
229
|
- lib/datadog/appsec/reactive/subscriber.rb
|
220
230
|
- lib/datadog/appsec/remote.rb
|
221
231
|
- lib/datadog/appsec/response.rb
|
222
232
|
- lib/datadog/appsec/sample_rate.rb
|
223
|
-
- lib/datadog/appsec/scope.rb
|
224
233
|
- lib/datadog/appsec/utils.rb
|
225
234
|
- lib/datadog/appsec/utils/http.rb
|
226
235
|
- lib/datadog/appsec/utils/http/media_range.rb
|
@@ -242,7 +251,7 @@ files:
|
|
242
251
|
- lib/datadog/core/configuration/option_definition.rb
|
243
252
|
- lib/datadog/core/configuration/options.rb
|
244
253
|
- lib/datadog/core/configuration/settings.rb
|
245
|
-
- lib/datadog/core/
|
254
|
+
- lib/datadog/core/contrib/rails/utils.rb
|
246
255
|
- lib/datadog/core/crashtracking/component.rb
|
247
256
|
- lib/datadog/core/crashtracking/tag_builder.rb
|
248
257
|
- lib/datadog/core/deprecations.rb
|
@@ -363,20 +372,25 @@ files:
|
|
363
372
|
- lib/datadog/core/workers/queue.rb
|
364
373
|
- lib/datadog/core/workers/runtime_metrics.rb
|
365
374
|
- lib/datadog/di.rb
|
375
|
+
- lib/datadog/di/base.rb
|
366
376
|
- lib/datadog/di/code_tracker.rb
|
367
377
|
- lib/datadog/di/component.rb
|
368
378
|
- lib/datadog/di/configuration.rb
|
369
379
|
- lib/datadog/di/configuration/settings.rb
|
380
|
+
- lib/datadog/di/contrib.rb
|
370
381
|
- lib/datadog/di/contrib/active_record.rb
|
382
|
+
- lib/datadog/di/contrib/railtie.rb
|
371
383
|
- lib/datadog/di/error.rb
|
372
384
|
- lib/datadog/di/extensions.rb
|
373
385
|
- lib/datadog/di/instrumenter.rb
|
386
|
+
- lib/datadog/di/preload.rb
|
374
387
|
- lib/datadog/di/probe.rb
|
375
388
|
- lib/datadog/di/probe_builder.rb
|
376
389
|
- lib/datadog/di/probe_manager.rb
|
377
390
|
- lib/datadog/di/probe_notification_builder.rb
|
378
391
|
- lib/datadog/di/probe_notifier_worker.rb
|
379
392
|
- lib/datadog/di/redactor.rb
|
393
|
+
- lib/datadog/di/remote.rb
|
380
394
|
- lib/datadog/di/serializer.rb
|
381
395
|
- lib/datadog/di/transport.rb
|
382
396
|
- lib/datadog/di/utils.rb
|
@@ -722,7 +736,6 @@ files:
|
|
722
736
|
- lib/datadog/tracing/contrib/rails/patcher.rb
|
723
737
|
- lib/datadog/tracing/contrib/rails/railtie.rb
|
724
738
|
- lib/datadog/tracing/contrib/rails/runner.rb
|
725
|
-
- lib/datadog/tracing/contrib/rails/utils.rb
|
726
739
|
- lib/datadog/tracing/contrib/rake/configuration/settings.rb
|
727
740
|
- lib/datadog/tracing/contrib/rake/ext.rb
|
728
741
|
- lib/datadog/tracing/contrib/rake/instrumentation.rb
|
@@ -898,9 +911,9 @@ licenses:
|
|
898
911
|
- Apache-2.0
|
899
912
|
metadata:
|
900
913
|
allowed_push_host: https://rubygems.org
|
901
|
-
changelog_uri: https://github.com/DataDog/dd-trace-rb/blob/v2.
|
902
|
-
source_code_uri: https://github.com/DataDog/dd-trace-rb/tree/v2.
|
903
|
-
post_install_message:
|
914
|
+
changelog_uri: https://github.com/DataDog/dd-trace-rb/blob/v2.9.0/CHANGELOG.md
|
915
|
+
source_code_uri: https://github.com/DataDog/dd-trace-rb/tree/v2.9.0
|
916
|
+
post_install_message:
|
904
917
|
rdoc_options: []
|
905
918
|
require_paths:
|
906
919
|
- lib
|
@@ -918,8 +931,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
918
931
|
- !ruby/object:Gem::Version
|
919
932
|
version: 2.0.0
|
920
933
|
requirements: []
|
921
|
-
rubygems_version: 3.5.
|
922
|
-
signing_key:
|
934
|
+
rubygems_version: 3.5.11
|
935
|
+
signing_key:
|
923
936
|
specification_version: 4
|
924
937
|
summary: Datadog tracing code for your Ruby applications
|
925
938
|
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
|
@@ -1,68 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'engine'
|
4
|
-
|
5
|
-
module Datadog
|
6
|
-
module AppSec
|
7
|
-
module Reactive
|
8
|
-
# Reactive Engine nested operation tracking
|
9
|
-
class Operation
|
10
|
-
attr_reader :reactive,
|
11
|
-
:parent,
|
12
|
-
:name
|
13
|
-
|
14
|
-
def initialize(name, parent = nil, reactive_engine = nil)
|
15
|
-
Datadog.logger.debug { "operation: #{name} initialize" }
|
16
|
-
@name = name
|
17
|
-
@parent = parent
|
18
|
-
@reactive = select_reactive_engine(reactive_engine, parent)
|
19
|
-
|
20
|
-
# TODO: concurrent store
|
21
|
-
# TODO: constant
|
22
|
-
Thread.current[:datadog_security_active_operation] = self
|
23
|
-
|
24
|
-
yield self if block_given?
|
25
|
-
ensure
|
26
|
-
finalize
|
27
|
-
end
|
28
|
-
|
29
|
-
# TODO: use structs instead of an arg splat
|
30
|
-
def subscribe(*addresses, &block)
|
31
|
-
reactive.subscribe(*addresses, &block)
|
32
|
-
end
|
33
|
-
|
34
|
-
def publish(address, data)
|
35
|
-
reactive.publish(address, data)
|
36
|
-
end
|
37
|
-
|
38
|
-
def finalize
|
39
|
-
Datadog.logger.debug { "operation: #{name} finalize" }
|
40
|
-
Thread.current[:datadog_security_active_operation] = parent
|
41
|
-
end
|
42
|
-
|
43
|
-
private
|
44
|
-
|
45
|
-
def select_reactive_engine(reactive, parent)
|
46
|
-
return reactive if reactive
|
47
|
-
|
48
|
-
return parent.reactive unless parent.nil?
|
49
|
-
|
50
|
-
Reactive::Engine.new
|
51
|
-
end
|
52
|
-
|
53
|
-
class << self
|
54
|
-
def active
|
55
|
-
Thread.current[:datadog_security_active_operation]
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
# For testing only.
|
61
|
-
def reset!
|
62
|
-
Thread.current[:datadog_security_active_operation] = nil
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
data/lib/datadog/appsec/scope.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Datadog
|
4
|
-
module AppSec
|
5
|
-
# Capture context essential to consistently call processor and report via traces
|
6
|
-
class Scope
|
7
|
-
attr_reader :trace, :service_entry_span, :processor_context
|
8
|
-
|
9
|
-
def initialize(trace, service_entry_span, processor_context)
|
10
|
-
@trace = trace
|
11
|
-
@service_entry_span = service_entry_span
|
12
|
-
@processor_context = processor_context
|
13
|
-
end
|
14
|
-
|
15
|
-
def finalize
|
16
|
-
@processor_context.finalize
|
17
|
-
end
|
18
|
-
|
19
|
-
class << self
|
20
|
-
def activate_scope(trace, service_entry_span, processor)
|
21
|
-
raise ActiveScopeError, 'another scope is active, nested scopes are not supported' if active_scope
|
22
|
-
|
23
|
-
context = processor.new_context
|
24
|
-
self.active_scope = new(trace, service_entry_span, context)
|
25
|
-
end
|
26
|
-
|
27
|
-
def deactivate_scope
|
28
|
-
raise InactiveScopeError, 'no scope is active, nested scopes are not supported' unless active_scope
|
29
|
-
|
30
|
-
scope = active_scope
|
31
|
-
|
32
|
-
reset_active_scope
|
33
|
-
|
34
|
-
scope.finalize
|
35
|
-
end
|
36
|
-
|
37
|
-
def active_scope
|
38
|
-
Thread.current[:datadog_appsec_active_scope]
|
39
|
-
end
|
40
|
-
|
41
|
-
private
|
42
|
-
|
43
|
-
def active_scope=(scope)
|
44
|
-
raise ArgumentError, 'not a Datadog::AppSec::Scope' unless scope.instance_of?(Scope)
|
45
|
-
|
46
|
-
Thread.current[:datadog_appsec_active_scope] = scope
|
47
|
-
end
|
48
|
-
|
49
|
-
def reset_active_scope
|
50
|
-
Thread.current[:datadog_appsec_active_scope] = nil
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
class InactiveScopeError < StandardError; end
|
55
|
-
class ActiveScopeError < StandardError; end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../configuration/ext'
|
4
|
-
|
5
|
-
module Datadog
|
6
|
-
module Core
|
7
|
-
module Crashtracking
|
8
|
-
# This module provides a method to resolve the base URL of the agent
|
9
|
-
module AgentBaseUrl
|
10
|
-
def self.resolve(agent_settings)
|
11
|
-
case agent_settings.adapter
|
12
|
-
when Datadog::Core::Configuration::Ext::Agent::HTTP::ADAPTER
|
13
|
-
"#{agent_settings.ssl ? 'https' : 'http'}://#{agent_settings.hostname}:#{agent_settings.port}/"
|
14
|
-
when Datadog::Core::Configuration::Ext::Agent::UnixSocket::ADAPTER
|
15
|
-
"unix://#{agent_settings.uds_path}"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|