datadog 2.2.0 → 2.3.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 +51 -2
- data/ext/datadog_profiling_loader/extconf.rb +15 -15
- data/ext/datadog_profiling_native_extension/clock_id.h +1 -0
- data/ext/datadog_profiling_native_extension/clock_id_from_pthread.c +1 -2
- data/ext/datadog_profiling_native_extension/clock_id_noop.c +1 -2
- data/ext/datadog_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +113 -43
- data/ext/datadog_profiling_native_extension/collectors_discrete_dynamic_sampler.c +49 -26
- data/ext/datadog_profiling_native_extension/collectors_discrete_dynamic_sampler.h +34 -4
- data/ext/datadog_profiling_native_extension/collectors_idle_sampling_helper.c +4 -0
- data/ext/datadog_profiling_native_extension/collectors_stack.c +49 -37
- data/ext/datadog_profiling_native_extension/collectors_stack.h +2 -2
- data/ext/datadog_profiling_native_extension/collectors_thread_context.c +81 -19
- data/ext/datadog_profiling_native_extension/collectors_thread_context.h +1 -0
- data/ext/datadog_profiling_native_extension/datadog_ruby_common.c +110 -0
- data/ext/datadog_profiling_native_extension/datadog_ruby_common.h +57 -0
- data/ext/datadog_profiling_native_extension/extconf.rb +65 -60
- data/ext/datadog_profiling_native_extension/heap_recorder.c +34 -6
- data/ext/datadog_profiling_native_extension/heap_recorder.h +3 -1
- data/ext/datadog_profiling_native_extension/helpers.h +6 -17
- data/ext/datadog_profiling_native_extension/http_transport.c +3 -3
- data/ext/datadog_profiling_native_extension/libdatadog_helpers.c +0 -86
- data/ext/datadog_profiling_native_extension/libdatadog_helpers.h +2 -23
- data/ext/datadog_profiling_native_extension/native_extension_helpers.rb +61 -172
- data/ext/datadog_profiling_native_extension/private_vm_api_access.c +64 -138
- data/ext/datadog_profiling_native_extension/private_vm_api_access.h +17 -11
- data/ext/datadog_profiling_native_extension/profiling.c +0 -2
- data/ext/datadog_profiling_native_extension/ruby_helpers.c +0 -33
- data/ext/datadog_profiling_native_extension/ruby_helpers.h +1 -26
- data/ext/datadog_profiling_native_extension/setup_signal_handler.h +1 -0
- data/ext/datadog_profiling_native_extension/stack_recorder.c +14 -2
- data/ext/datadog_profiling_native_extension/stack_recorder.h +1 -0
- data/ext/datadog_profiling_native_extension/time_helpers.c +0 -15
- data/ext/datadog_profiling_native_extension/time_helpers.h +36 -6
- data/ext/{datadog_profiling_native_extension → libdatadog_api}/crashtracker.c +19 -6
- data/ext/libdatadog_api/datadog_ruby_common.c +110 -0
- data/ext/libdatadog_api/datadog_ruby_common.h +57 -0
- data/ext/libdatadog_api/extconf.rb +108 -0
- data/ext/libdatadog_api/macos_development.md +26 -0
- data/ext/libdatadog_extconf_helpers.rb +130 -0
- data/lib/datadog/appsec/contrib/graphql/appsec_trace.rb +49 -0
- data/lib/datadog/appsec/contrib/graphql/gateway/multiplex.rb +73 -0
- data/lib/datadog/appsec/contrib/graphql/gateway/watcher.rb +68 -0
- data/lib/datadog/appsec/contrib/graphql/integration.rb +41 -0
- data/lib/datadog/appsec/contrib/graphql/patcher.rb +37 -0
- data/lib/datadog/appsec/contrib/graphql/reactive/multiplex.rb +59 -0
- data/lib/datadog/appsec/contrib/rack/gateway/request.rb +1 -1
- data/lib/datadog/appsec/processor/actions.rb +1 -1
- data/lib/datadog/appsec/response.rb +15 -1
- data/lib/datadog/appsec.rb +1 -0
- data/lib/datadog/core/configuration/components.rb +14 -12
- data/lib/datadog/core/configuration/settings.rb +54 -7
- data/lib/datadog/core/crashtracking/agent_base_url.rb +21 -0
- data/lib/datadog/core/crashtracking/component.rb +111 -0
- data/lib/datadog/core/crashtracking/tag_builder.rb +39 -0
- data/lib/datadog/core/diagnostics/environment_logger.rb +8 -11
- data/lib/datadog/core/telemetry/component.rb +49 -2
- data/lib/datadog/core/telemetry/emitter.rb +9 -11
- data/lib/datadog/core/telemetry/event.rb +32 -1
- data/lib/datadog/core/telemetry/ext.rb +1 -0
- data/lib/datadog/core/telemetry/http/adapters/net.rb +10 -12
- data/lib/datadog/core/telemetry/http/ext.rb +3 -0
- data/lib/datadog/core/telemetry/http/transport.rb +38 -9
- data/lib/datadog/core/telemetry/logging.rb +35 -0
- data/lib/datadog/core/utils/at_fork_monkey_patch.rb +102 -0
- data/lib/datadog/kit/appsec/events.rb +2 -4
- data/lib/datadog/opentelemetry/sdk/span_processor.rb +10 -0
- data/lib/datadog/opentelemetry/sdk/trace/span.rb +23 -0
- data/lib/datadog/profiling/collectors/code_provenance.rb +7 -7
- data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +17 -17
- data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +11 -13
- data/lib/datadog/profiling/collectors/info.rb +3 -3
- data/lib/datadog/profiling/collectors/thread_context.rb +4 -2
- data/lib/datadog/profiling/component.rb +69 -91
- data/lib/datadog/profiling/exporter.rb +3 -3
- data/lib/datadog/profiling/ext/dir_monkey_patches.rb +3 -3
- data/lib/datadog/profiling/ext.rb +21 -21
- data/lib/datadog/profiling/flush.rb +1 -1
- data/lib/datadog/profiling/http_transport.rb +8 -6
- data/lib/datadog/profiling/load_native_extension.rb +5 -5
- data/lib/datadog/profiling/preload.rb +1 -1
- data/lib/datadog/profiling/profiler.rb +5 -8
- data/lib/datadog/profiling/scheduler.rb +31 -25
- data/lib/datadog/profiling/tag_builder.rb +2 -2
- data/lib/datadog/profiling/tasks/exec.rb +5 -5
- data/lib/datadog/profiling/tasks/setup.rb +16 -35
- data/lib/datadog/profiling.rb +4 -5
- data/lib/datadog/tracing/contrib/active_record/events/sql.rb +1 -0
- data/lib/datadog/tracing/contrib/ext.rb +14 -0
- data/lib/datadog/tracing/contrib/graphql/unified_trace.rb +1 -1
- data/lib/datadog/tracing/contrib/graphql/unified_trace_patcher.rb +4 -1
- data/lib/datadog/tracing/contrib/lograge/patcher.rb +16 -0
- data/lib/datadog/tracing/contrib/mysql2/configuration/settings.rb +5 -0
- data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +17 -13
- data/lib/datadog/tracing/contrib/pg/configuration/settings.rb +5 -0
- data/lib/datadog/tracing/contrib/pg/instrumentation.rb +4 -1
- data/lib/datadog/tracing/contrib/propagation/sql_comment/ext.rb +28 -0
- data/lib/datadog/tracing/contrib/propagation/sql_comment/mode.rb +5 -1
- data/lib/datadog/tracing/contrib/propagation/sql_comment.rb +22 -10
- data/lib/datadog/tracing/contrib/trilogy/configuration/settings.rb +5 -0
- data/lib/datadog/tracing/contrib/trilogy/instrumentation.rb +4 -1
- data/lib/datadog/tracing/diagnostics/environment_logger.rb +14 -16
- data/lib/datadog/tracing/metadata/errors.rb +9 -1
- data/lib/datadog/tracing/metadata/ext.rb +4 -0
- data/lib/datadog/tracing/pipeline/span_filter.rb +2 -2
- data/lib/datadog/tracing/span.rb +9 -2
- data/lib/datadog/tracing/span_event.rb +41 -0
- data/lib/datadog/tracing/span_operation.rb +6 -2
- data/lib/datadog/tracing/transport/serializable_trace.rb +3 -0
- data/lib/datadog/version.rb +1 -1
- metadata +28 -10
- data/lib/datadog/profiling/crashtracker.rb +0 -91
- data/lib/datadog/profiling/ext/forking.rb +0 -98
@@ -52,6 +52,11 @@ module Datadog
|
|
52
52
|
o.default Contrib::Propagation::SqlComment::Ext::DISABLED
|
53
53
|
end
|
54
54
|
|
55
|
+
option :append_comment do |o|
|
56
|
+
o.type :bool
|
57
|
+
o.default false
|
58
|
+
end
|
59
|
+
|
55
60
|
option :peer_service do |o|
|
56
61
|
o.type :string, nilable: true
|
57
62
|
o.env Ext::ENV_PEER_SERVICE
|
@@ -114,7 +114,10 @@ module Datadog
|
|
114
114
|
Contrib::Analytics.set_sample_rate(span, analytics_sample_rate) if analytics_enabled?
|
115
115
|
|
116
116
|
if sql
|
117
|
-
propagation_mode = Contrib::Propagation::SqlComment::Mode.new(
|
117
|
+
propagation_mode = Contrib::Propagation::SqlComment::Mode.new(
|
118
|
+
comment_propagation,
|
119
|
+
datadog_configuration[:append_comment]
|
120
|
+
)
|
118
121
|
Contrib::Propagation::SqlComment.annotate!(span, propagation_mode)
|
119
122
|
propagated_sql_statement = Contrib::Propagation::SqlComment.prepend_comment(
|
120
123
|
sql,
|
@@ -20,10 +20,38 @@ module Datadog
|
|
20
20
|
# The value should be `true` when `full` mode
|
21
21
|
TAG_DBM_TRACE_INJECTED = '_dd.dbm_trace_injected'
|
22
22
|
|
23
|
+
# Database service/sql span service (i.e. the service executing the actual query)
|
24
|
+
#
|
25
|
+
# If fake services are disabled:
|
26
|
+
# This value will be the same as the parent service
|
27
|
+
#
|
28
|
+
# If fake services are enabled:
|
29
|
+
# This value is NOT the same as the parent service
|
30
|
+
#
|
31
|
+
# This should NOT be overridden by peer.service.
|
23
32
|
KEY_DATABASE_SERVICE = 'dddbs'
|
33
|
+
|
34
|
+
# The global service environment (e.g. DD_ENV)
|
24
35
|
KEY_ENVIRONMENT = 'dde'
|
36
|
+
|
37
|
+
# The global service name (e.g. DD_SERVICE)
|
25
38
|
KEY_PARENT_SERVICE = 'ddps'
|
39
|
+
|
40
|
+
# The global service version (e.g. DD_VERSION)
|
26
41
|
KEY_VERSION = 'ddpv'
|
42
|
+
|
43
|
+
# The hostname of the database server, as provided to the database client upon instantiation.
|
44
|
+
# @see Datadog::Tracing::Metadata::Ext::TAG_PEER_HOSTNAME
|
45
|
+
KEY_HOSTNAME = 'ddh'
|
46
|
+
|
47
|
+
# @see Datadog::Tracing::Contrib::Ext::DB::TAG_INSTANCE
|
48
|
+
KEY_DB_NAME = 'dddb'
|
49
|
+
|
50
|
+
# Users can use this attribute to specify the identity of the dependency/database they are connecting to.
|
51
|
+
# We should grab this attribute only if the user is EXPLICITLY specifying it.
|
52
|
+
# @see Datadog::Tracing::Metadata::Ext::TAG_PEER_SERVICE
|
53
|
+
KEY_PEER_SERVICE = 'ddprs'
|
54
|
+
|
27
55
|
KEY_TRACEPARENT = 'traceparent'
|
28
56
|
end
|
29
57
|
end
|
@@ -8,7 +8,7 @@ module Datadog
|
|
8
8
|
module Propagation
|
9
9
|
# Implements sql comment propagation related contracts.
|
10
10
|
module SqlComment
|
11
|
-
Mode = Struct.new(:mode) do
|
11
|
+
Mode = Struct.new(:mode, :append) do
|
12
12
|
def enabled?
|
13
13
|
service? || full?
|
14
14
|
end
|
@@ -20,6 +20,10 @@ module Datadog
|
|
20
20
|
def full?
|
21
21
|
mode == Ext::FULL
|
22
22
|
end
|
23
|
+
|
24
|
+
def append?
|
25
|
+
append
|
26
|
+
end
|
23
27
|
end
|
24
28
|
end
|
25
29
|
end
|
@@ -22,16 +22,28 @@ module Datadog
|
|
22
22
|
def self.prepend_comment(sql, span_op, trace_op, mode)
|
23
23
|
return sql unless mode.enabled?
|
24
24
|
|
25
|
+
config = Datadog.configuration
|
26
|
+
|
27
|
+
parent_service = config.service
|
28
|
+
peer_service = span_op.get_tag(Tracing::Metadata::Ext::TAG_PEER_SERVICE)
|
29
|
+
|
25
30
|
tags = {
|
26
|
-
Ext::
|
27
|
-
Ext::
|
28
|
-
Ext::
|
29
|
-
Ext::
|
31
|
+
Ext::KEY_ENVIRONMENT => config.env,
|
32
|
+
Ext::KEY_PARENT_SERVICE => parent_service,
|
33
|
+
Ext::KEY_VERSION => config.version,
|
34
|
+
Ext::KEY_HOSTNAME => span_op.get_tag(Tracing::Metadata::Ext::TAG_PEER_HOSTNAME),
|
35
|
+
Ext::KEY_DB_NAME => span_op.get_tag(Contrib::Ext::DB::TAG_INSTANCE),
|
36
|
+
Ext::KEY_PEER_SERVICE => peer_service,
|
30
37
|
}
|
31
38
|
|
39
|
+
db_service = peer_service || span_op.service
|
40
|
+
if parent_service != db_service # Only set if it's different from parent_service; otherwise it's redundant
|
41
|
+
tags[Ext::KEY_DATABASE_SERVICE] = db_service
|
42
|
+
end
|
43
|
+
|
32
44
|
if mode.full?
|
33
45
|
# When tracing is disabled, trace_operation is a dummy object that does not contain data to build traceparent
|
34
|
-
if
|
46
|
+
if config.tracing.enabled
|
35
47
|
tags[Ext::KEY_TRACEPARENT] =
|
36
48
|
Tracing::Distributed::TraceContext.new(fetcher: nil).send(:build_traceparent, trace_op.to_digest)
|
37
49
|
else
|
@@ -42,11 +54,11 @@ module Datadog
|
|
42
54
|
end
|
43
55
|
end
|
44
56
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
57
|
+
if mode.append?
|
58
|
+
"#{sql} #{Comment.new(tags)}"
|
59
|
+
else
|
60
|
+
"#{Comment.new(tags)} #{sql}"
|
61
|
+
end
|
50
62
|
end
|
51
63
|
end
|
52
64
|
end
|
@@ -46,6 +46,11 @@ module Datadog
|
|
46
46
|
o.default Contrib::Propagation::SqlComment::Ext::DISABLED
|
47
47
|
end
|
48
48
|
|
49
|
+
option :append_comment do |o|
|
50
|
+
o.type :bool
|
51
|
+
o.default false
|
52
|
+
end
|
53
|
+
|
49
54
|
option :peer_service do |o|
|
50
55
|
o.type :string, nilable: true
|
51
56
|
o.env Ext::ENV_PEER_SERVICE
|
@@ -49,13 +49,16 @@ module Datadog
|
|
49
49
|
# Set analytics sample rate
|
50
50
|
Contrib::Analytics.set_sample_rate(span, analytics_sample_rate) if analytics_enabled?
|
51
51
|
|
52
|
+
span.set_tag(Contrib::Ext::DB::TAG_INSTANCE, connection_options[:database])
|
52
53
|
span.set_tag(Ext::TAG_DB_NAME, connection_options[:database])
|
53
54
|
span.set_tag(Tracing::Metadata::Ext::NET::TAG_TARGET_HOST, connection_options[:host])
|
54
55
|
span.set_tag(Tracing::Metadata::Ext::NET::TAG_TARGET_PORT, connection_options[:port])
|
55
56
|
|
56
57
|
Contrib::SpanAttributeSchema.set_peer_service!(span, Ext::PEER_SERVICE_SOURCES)
|
57
58
|
|
58
|
-
propagation_mode = Contrib::Propagation::SqlComment::Mode.new(
|
59
|
+
propagation_mode = Contrib::Propagation::SqlComment::Mode.new(
|
60
|
+
comment_propagation, datadog_configuration[:append_comment]
|
61
|
+
)
|
59
62
|
|
60
63
|
Contrib::Propagation::SqlComment.annotate!(span, propagation_mode)
|
61
64
|
sql = Contrib::Propagation::SqlComment.prepend_comment(
|
@@ -14,8 +14,8 @@ module Datadog
|
|
14
14
|
|
15
15
|
def self.collect_and_log!(responses: nil)
|
16
16
|
if log?
|
17
|
-
|
18
|
-
|
17
|
+
log_configuration!('TRACING', EnvironmentCollector.collect_config!.to_json)
|
18
|
+
log_debug!('TRACING INTEGRATIONS', EnvironmentCollector.collect_integrations_settings!.to_json)
|
19
19
|
|
20
20
|
if responses
|
21
21
|
err_data = EnvironmentCollector.collect_errors!(responses)
|
@@ -40,7 +40,6 @@ module Datadog
|
|
40
40
|
sampling_rules: sampling_rules,
|
41
41
|
integrations_loaded: integrations_loaded,
|
42
42
|
partial_flushing_enabled: partial_flushing_enabled,
|
43
|
-
**instrumented_integrations_settings
|
44
43
|
}
|
45
44
|
end
|
46
45
|
|
@@ -128,6 +127,18 @@ module Datadog
|
|
128
127
|
!!Datadog.configuration.tracing.partial_flush.enabled
|
129
128
|
end
|
130
129
|
|
130
|
+
def collect_integrations_settings!
|
131
|
+
instrumented_integrations.each_with_object({}) do |(name, integration), result|
|
132
|
+
integration.configuration.to_h.each do |setting, value|
|
133
|
+
next if setting == :tracer # Skip internal objects
|
134
|
+
|
135
|
+
# Convert value to a string to avoid custom #to_json
|
136
|
+
# handlers possibly causing errors.
|
137
|
+
result[:"#{name}_#{setting}"] = value.to_s
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
131
142
|
private
|
132
143
|
|
133
144
|
def instrumented_integrations
|
@@ -139,19 +150,6 @@ module Datadog
|
|
139
150
|
|
140
151
|
Datadog.configuration.tracing.instrumented_integrations
|
141
152
|
end
|
142
|
-
|
143
|
-
# Capture all active integration settings into "integrationName_settingName: value" entries.
|
144
|
-
def instrumented_integrations_settings
|
145
|
-
instrumented_integrations.flat_map do |name, integration|
|
146
|
-
integration.configuration.to_h.flat_map do |setting, value|
|
147
|
-
next [] if setting == :tracer # Skip internal Ruby objects
|
148
|
-
|
149
|
-
# Convert value to a string to avoid custom #to_json
|
150
|
-
# handlers possibly causing errors.
|
151
|
-
[[:"integration_#{name}_#{setting}", value.to_s]]
|
152
|
-
end
|
153
|
-
end.to_h
|
154
|
-
end
|
155
153
|
end
|
156
154
|
end
|
157
155
|
end
|
@@ -10,8 +10,16 @@ module Datadog
|
|
10
10
|
# Adds error tagging behavior
|
11
11
|
# @public_api
|
12
12
|
module Errors
|
13
|
-
# Mark the span with the given error.
|
14
13
|
def set_error(e)
|
14
|
+
Datadog::Core.log_deprecation do
|
15
|
+
'Errors.set_error(..) is deprecated. ' \
|
16
|
+
'Use Errors.set_error_tags(..) instead.'
|
17
|
+
end
|
18
|
+
set_error_tags(e)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Mark the span with the given error.
|
22
|
+
def set_error_tags(e)
|
15
23
|
e = Core::Error.build_from(e)
|
16
24
|
|
17
25
|
set_tag(Ext::Errors::TAG_TYPE, e.type) unless e.type.empty?
|
@@ -14,6 +14,10 @@ module Datadog
|
|
14
14
|
# Type of operation being performed (e.g. )
|
15
15
|
TAG_OPERATION = 'operation'
|
16
16
|
# Hostname of external service interacted with
|
17
|
+
#
|
18
|
+
# This tag also doesn't strictly need to be a “hostname”. It can be a raw IP address and in some cases it
|
19
|
+
# can even be a unix domain socket (i.e. postgres client setting host=/var/run/postgres).
|
20
|
+
# It should be whatever the client uses to point at the server it’s trying to talk to.
|
17
21
|
TAG_PEER_HOSTNAME = 'peer.hostname'
|
18
22
|
# Name of external service that performed the work
|
19
23
|
TAG_PEER_SERVICE = 'peer.service'
|
@@ -10,8 +10,8 @@ module Datadog
|
|
10
10
|
# This processor executes the configured `operation` for each {Datadog::Tracing::Span}
|
11
11
|
# in a {Datadog::Tracing::TraceSegment}.
|
12
12
|
#
|
13
|
-
# If `operation` returns a truthy value for a span, that span is
|
14
|
-
# otherwise the span is
|
13
|
+
# If `operation` returns a truthy value for a span, that span is dropped,
|
14
|
+
# otherwise the span is kept.
|
15
15
|
#
|
16
16
|
# @public_api
|
17
17
|
class SpanFilter < SpanProcessor
|
data/lib/datadog/tracing/span.rb
CHANGED
@@ -27,6 +27,7 @@ module Datadog
|
|
27
27
|
:resource,
|
28
28
|
:service,
|
29
29
|
:links,
|
30
|
+
:events,
|
30
31
|
:type,
|
31
32
|
:start_time,
|
32
33
|
:status,
|
@@ -45,6 +46,7 @@ module Datadog
|
|
45
46
|
# * +parent_id+: the identifier of the parent span
|
46
47
|
# * +trace_id+: the identifier of the root span for this trace
|
47
48
|
# * +service_entry+: whether it is a service entry span.
|
49
|
+
# * +events+: the list of events that occurred while a span was active.
|
48
50
|
def initialize(
|
49
51
|
name,
|
50
52
|
duration: nil,
|
@@ -60,7 +62,8 @@ module Datadog
|
|
60
62
|
type: nil,
|
61
63
|
trace_id: nil,
|
62
64
|
service_entry: nil,
|
63
|
-
links: nil
|
65
|
+
links: nil,
|
66
|
+
events: nil
|
64
67
|
)
|
65
68
|
@name = Core::Utils::SafeDup.frozen_or_dup(name)
|
66
69
|
@service = Core::Utils::SafeDup.frozen_or_dup(service)
|
@@ -90,6 +93,8 @@ module Datadog
|
|
90
93
|
|
91
94
|
@links = links || []
|
92
95
|
|
96
|
+
@events = events || []
|
97
|
+
|
93
98
|
# Mark with the service entry span metric, if applicable
|
94
99
|
set_metric(Metadata::Ext::TAG_TOP_LEVEL, 1.0) if service_entry
|
95
100
|
end
|
@@ -112,7 +117,7 @@ module Datadog
|
|
112
117
|
|
113
118
|
def set_error(e)
|
114
119
|
@status = Metadata::Ext::Errors::STATUS
|
115
|
-
|
120
|
+
set_error_tags(e)
|
116
121
|
end
|
117
122
|
|
118
123
|
# Spans with the same ID are considered the same span
|
@@ -149,6 +154,8 @@ module Datadog
|
|
149
154
|
h[:duration] = duration_nano
|
150
155
|
end
|
151
156
|
|
157
|
+
h[:meta]['events'] = @events.map(&:to_hash).to_json unless @events.empty?
|
158
|
+
|
152
159
|
h
|
153
160
|
end
|
154
161
|
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'time'
|
4
|
+
|
5
|
+
module Datadog
|
6
|
+
module Tracing
|
7
|
+
# Represents a timestamped annotation on a span. It is analogous to structured log message.
|
8
|
+
# @public_api
|
9
|
+
class SpanEvent
|
10
|
+
# @!attribute [r] name
|
11
|
+
# @return [Integer]
|
12
|
+
attr_reader :name
|
13
|
+
|
14
|
+
# @!attribute [r] attributes
|
15
|
+
# @return [Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}]
|
16
|
+
attr_reader :attributes
|
17
|
+
|
18
|
+
# @!attribute [r] time_unix_nano
|
19
|
+
# @return [Integer]
|
20
|
+
attr_reader :time_unix_nano
|
21
|
+
|
22
|
+
def initialize(
|
23
|
+
name,
|
24
|
+
attributes: nil,
|
25
|
+
time_unix_nano: nil
|
26
|
+
)
|
27
|
+
@name = name
|
28
|
+
@attributes = attributes || {}
|
29
|
+
# OpenTelemetry SDK stores span event timestamps in nanoseconds (not seconds).
|
30
|
+
# We will do the same here to avoid unnecessary conversions and inconsistencies.
|
31
|
+
@time_unix_nano = time_unix_nano || (Time.now.to_r * 1_000_000_000).to_i
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_hash
|
35
|
+
h = { name: @name, time_unix_nano: @time_unix_nano }
|
36
|
+
h[:attributes] = attributes unless @attributes.empty?
|
37
|
+
h
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -35,7 +35,7 @@ module Datadog
|
|
35
35
|
:start_time,
|
36
36
|
:trace_id,
|
37
37
|
:type
|
38
|
-
attr_accessor :links, :status
|
38
|
+
attr_accessor :links, :status, :span_events
|
39
39
|
|
40
40
|
def initialize(
|
41
41
|
name,
|
@@ -49,6 +49,7 @@ module Datadog
|
|
49
49
|
trace_id: nil,
|
50
50
|
type: nil,
|
51
51
|
links: nil,
|
52
|
+
span_events: nil,
|
52
53
|
id: nil
|
53
54
|
)
|
54
55
|
# Ensure dynamically created strings are UTF-8 encoded.
|
@@ -68,6 +69,8 @@ module Datadog
|
|
68
69
|
@status = 0
|
69
70
|
# stores array of span links
|
70
71
|
@links = links || []
|
72
|
+
# stores array of span events
|
73
|
+
@span_events = span_events || []
|
71
74
|
|
72
75
|
# start_time and end_time track wall clock. In Ruby, wall clock
|
73
76
|
# has less accuracy than monotonic clock, so if possible we look to only use wall clock
|
@@ -265,7 +268,7 @@ module Datadog
|
|
265
268
|
|
266
269
|
def set_error(e)
|
267
270
|
@status = Metadata::Ext::Errors::STATUS
|
268
|
-
|
271
|
+
set_error_tags(e)
|
269
272
|
end
|
270
273
|
|
271
274
|
# Return a string representation of the span.
|
@@ -455,6 +458,7 @@ module Datadog
|
|
455
458
|
type: @type,
|
456
459
|
trace_id: @trace_id,
|
457
460
|
links: @links,
|
461
|
+
events: @span_events,
|
458
462
|
service_entry: parent.nil? || (service && parent.service != service)
|
459
463
|
)
|
460
464
|
end
|
@@ -72,6 +72,9 @@ module Datadog
|
|
72
72
|
packer.write_map_header(number_of_elements_to_write) # Set header with how many elements in the map
|
73
73
|
end
|
74
74
|
|
75
|
+
# serialize span events as meta tags
|
76
|
+
span.set_tag('events', span.events.map(&:to_hash).to_json) if span.events.any?
|
77
|
+
|
75
78
|
# DEV: We use strings as keys here, instead of symbols, as
|
76
79
|
# DEV: MessagePack will ultimately convert them to strings.
|
77
80
|
# DEV: By providing strings directly, we skip this indirection operation.
|
data/lib/datadog/version.rb
CHANGED
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.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Datadog, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 11.0.0.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:
|
68
|
+
version: 11.0.0.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,
|
@@ -77,6 +77,7 @@ executables:
|
|
77
77
|
extensions:
|
78
78
|
- ext/datadog_profiling_native_extension/extconf.rb
|
79
79
|
- ext/datadog_profiling_loader/extconf.rb
|
80
|
+
- ext/libdatadog_api/extconf.rb
|
80
81
|
extra_rdoc_files: []
|
81
82
|
files:
|
82
83
|
- CHANGELOG.md
|
@@ -106,7 +107,8 @@ files:
|
|
106
107
|
- ext/datadog_profiling_native_extension/collectors_stack.h
|
107
108
|
- ext/datadog_profiling_native_extension/collectors_thread_context.c
|
108
109
|
- ext/datadog_profiling_native_extension/collectors_thread_context.h
|
109
|
-
- ext/datadog_profiling_native_extension/
|
110
|
+
- ext/datadog_profiling_native_extension/datadog_ruby_common.c
|
111
|
+
- ext/datadog_profiling_native_extension/datadog_ruby_common.h
|
110
112
|
- ext/datadog_profiling_native_extension/extconf.rb
|
111
113
|
- ext/datadog_profiling_native_extension/heap_recorder.c
|
112
114
|
- ext/datadog_profiling_native_extension/heap_recorder.h
|
@@ -126,6 +128,12 @@ files:
|
|
126
128
|
- ext/datadog_profiling_native_extension/stack_recorder.h
|
127
129
|
- ext/datadog_profiling_native_extension/time_helpers.c
|
128
130
|
- ext/datadog_profiling_native_extension/time_helpers.h
|
131
|
+
- ext/libdatadog_api/crashtracker.c
|
132
|
+
- ext/libdatadog_api/datadog_ruby_common.c
|
133
|
+
- ext/libdatadog_api/datadog_ruby_common.h
|
134
|
+
- ext/libdatadog_api/extconf.rb
|
135
|
+
- ext/libdatadog_api/macos_development.md
|
136
|
+
- ext/libdatadog_extconf_helpers.rb
|
129
137
|
- lib/datadog.rb
|
130
138
|
- lib/datadog/appsec.rb
|
131
139
|
- lib/datadog/appsec/assets.rb
|
@@ -150,6 +158,12 @@ files:
|
|
150
158
|
- lib/datadog/appsec/contrib/devise/patcher/registration_controller_patch.rb
|
151
159
|
- lib/datadog/appsec/contrib/devise/resource.rb
|
152
160
|
- lib/datadog/appsec/contrib/devise/tracking.rb
|
161
|
+
- lib/datadog/appsec/contrib/graphql/appsec_trace.rb
|
162
|
+
- lib/datadog/appsec/contrib/graphql/gateway/multiplex.rb
|
163
|
+
- lib/datadog/appsec/contrib/graphql/gateway/watcher.rb
|
164
|
+
- lib/datadog/appsec/contrib/graphql/integration.rb
|
165
|
+
- lib/datadog/appsec/contrib/graphql/patcher.rb
|
166
|
+
- lib/datadog/appsec/contrib/graphql/reactive/multiplex.rb
|
153
167
|
- lib/datadog/appsec/contrib/integration.rb
|
154
168
|
- lib/datadog/appsec/contrib/patcher.rb
|
155
169
|
- lib/datadog/appsec/contrib/rack/ext.rb
|
@@ -223,6 +237,9 @@ files:
|
|
223
237
|
- lib/datadog/core/configuration/option_definition.rb
|
224
238
|
- lib/datadog/core/configuration/options.rb
|
225
239
|
- lib/datadog/core/configuration/settings.rb
|
240
|
+
- lib/datadog/core/crashtracking/agent_base_url.rb
|
241
|
+
- lib/datadog/core/crashtracking/component.rb
|
242
|
+
- lib/datadog/core/crashtracking/tag_builder.rb
|
226
243
|
- lib/datadog/core/deprecations.rb
|
227
244
|
- lib/datadog/core/diagnostics/environment_logger.rb
|
228
245
|
- lib/datadog/core/diagnostics/health.rb
|
@@ -291,6 +308,7 @@ files:
|
|
291
308
|
- lib/datadog/core/telemetry/http/ext.rb
|
292
309
|
- lib/datadog/core/telemetry/http/response.rb
|
293
310
|
- lib/datadog/core/telemetry/http/transport.rb
|
311
|
+
- lib/datadog/core/telemetry/logging.rb
|
294
312
|
- lib/datadog/core/telemetry/metric.rb
|
295
313
|
- lib/datadog/core/telemetry/metrics_collection.rb
|
296
314
|
- lib/datadog/core/telemetry/metrics_manager.rb
|
@@ -310,6 +328,7 @@ files:
|
|
310
328
|
- lib/datadog/core/transport/request.rb
|
311
329
|
- lib/datadog/core/transport/response.rb
|
312
330
|
- lib/datadog/core/utils.rb
|
331
|
+
- lib/datadog/core/utils/at_fork_monkey_patch.rb
|
313
332
|
- lib/datadog/core/utils/base64.rb
|
314
333
|
- lib/datadog/core/utils/duration.rb
|
315
334
|
- lib/datadog/core/utils/forking.rb
|
@@ -357,11 +376,9 @@ files:
|
|
357
376
|
- lib/datadog/profiling/collectors/stack.rb
|
358
377
|
- lib/datadog/profiling/collectors/thread_context.rb
|
359
378
|
- lib/datadog/profiling/component.rb
|
360
|
-
- lib/datadog/profiling/crashtracker.rb
|
361
379
|
- lib/datadog/profiling/exporter.rb
|
362
380
|
- lib/datadog/profiling/ext.rb
|
363
381
|
- lib/datadog/profiling/ext/dir_monkey_patches.rb
|
364
|
-
- lib/datadog/profiling/ext/forking.rb
|
365
382
|
- lib/datadog/profiling/flush.rb
|
366
383
|
- lib/datadog/profiling/http_transport.rb
|
367
384
|
- lib/datadog/profiling/load_native_extension.rb
|
@@ -818,6 +835,7 @@ files:
|
|
818
835
|
- lib/datadog/tracing/sampling/span/rule_parser.rb
|
819
836
|
- lib/datadog/tracing/sampling/span/sampler.rb
|
820
837
|
- lib/datadog/tracing/span.rb
|
838
|
+
- lib/datadog/tracing/span_event.rb
|
821
839
|
- lib/datadog/tracing/span_link.rb
|
822
840
|
- lib/datadog/tracing/span_operation.rb
|
823
841
|
- lib/datadog/tracing/sync_writer.rb
|
@@ -852,8 +870,8 @@ licenses:
|
|
852
870
|
- Apache-2.0
|
853
871
|
metadata:
|
854
872
|
allowed_push_host: https://rubygems.org
|
855
|
-
changelog_uri: https://github.com/DataDog/dd-trace-rb/blob/v2.
|
856
|
-
source_code_uri: https://github.com/DataDog/dd-trace-rb/tree/v2.
|
873
|
+
changelog_uri: https://github.com/DataDog/dd-trace-rb/blob/v2.3.0/CHANGELOG.md
|
874
|
+
source_code_uri: https://github.com/DataDog/dd-trace-rb/tree/v2.3.0
|
857
875
|
post_install_message:
|
858
876
|
rdoc_options: []
|
859
877
|
require_paths:
|
@@ -872,7 +890,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
872
890
|
- !ruby/object:Gem::Version
|
873
891
|
version: 2.0.0
|
874
892
|
requirements: []
|
875
|
-
rubygems_version: 3.
|
893
|
+
rubygems_version: 3.5.16
|
876
894
|
signing_key:
|
877
895
|
specification_version: 4
|
878
896
|
summary: Datadog tracing code for your Ruby applications
|
@@ -1,91 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'libdatadog'
|
4
|
-
|
5
|
-
module Datadog
|
6
|
-
module Profiling
|
7
|
-
# Used to report Ruby VM crashes.
|
8
|
-
# The interesting bits are implemented as native code and using libdatadog.
|
9
|
-
#
|
10
|
-
# NOTE: The crashtracker native state is a singleton; so even if you create multiple instances of `Crashtracker`
|
11
|
-
# and start them, it only works as "last writer wins". Same for stop -- there's only one state, so calling stop
|
12
|
-
# on it will stop the crash tracker, regardless of which instance started it.
|
13
|
-
#
|
14
|
-
# Methods prefixed with _native_ are implemented in `crashtracker.c`
|
15
|
-
class Crashtracker
|
16
|
-
private
|
17
|
-
|
18
|
-
attr_reader \
|
19
|
-
:exporter_configuration,
|
20
|
-
:tags_as_array,
|
21
|
-
:path_to_crashtracking_receiver_binary,
|
22
|
-
:ld_library_path,
|
23
|
-
:upload_timeout_seconds
|
24
|
-
|
25
|
-
public
|
26
|
-
|
27
|
-
def initialize(
|
28
|
-
exporter_configuration:,
|
29
|
-
tags:,
|
30
|
-
upload_timeout_seconds:,
|
31
|
-
path_to_crashtracking_receiver_binary: Libdatadog.path_to_crashtracking_receiver_binary,
|
32
|
-
ld_library_path: Libdatadog.ld_library_path
|
33
|
-
)
|
34
|
-
@exporter_configuration = exporter_configuration
|
35
|
-
@tags_as_array = tags.to_a
|
36
|
-
@upload_timeout_seconds = upload_timeout_seconds
|
37
|
-
@path_to_crashtracking_receiver_binary = path_to_crashtracking_receiver_binary
|
38
|
-
@ld_library_path = ld_library_path
|
39
|
-
end
|
40
|
-
|
41
|
-
def start
|
42
|
-
start_or_update_on_fork(action: :start)
|
43
|
-
end
|
44
|
-
|
45
|
-
def reset_after_fork
|
46
|
-
start_or_update_on_fork(action: :update_on_fork)
|
47
|
-
end
|
48
|
-
|
49
|
-
def stop
|
50
|
-
begin
|
51
|
-
self.class._native_stop
|
52
|
-
Datadog.logger.debug('Crash tracking stopped successfully')
|
53
|
-
rescue => e
|
54
|
-
Datadog.logger.error("Failed to stop crash tracking: #{e.message}")
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
def start_or_update_on_fork(action:)
|
61
|
-
unless path_to_crashtracking_receiver_binary
|
62
|
-
Datadog.logger.warn(
|
63
|
-
"Cannot #{action} profiling crash tracking as no path_to_crashtracking_receiver_binary was found"
|
64
|
-
)
|
65
|
-
return
|
66
|
-
end
|
67
|
-
|
68
|
-
unless ld_library_path
|
69
|
-
Datadog.logger.warn(
|
70
|
-
"Cannot #{action} profiling crash tracking as no ld_library_path was found"
|
71
|
-
)
|
72
|
-
return
|
73
|
-
end
|
74
|
-
|
75
|
-
begin
|
76
|
-
self.class._native_start_or_update_on_fork(
|
77
|
-
action: action,
|
78
|
-
exporter_configuration: exporter_configuration,
|
79
|
-
path_to_crashtracking_receiver_binary: path_to_crashtracking_receiver_binary,
|
80
|
-
ld_library_path: ld_library_path,
|
81
|
-
tags_as_array: tags_as_array,
|
82
|
-
upload_timeout_seconds: Integer(upload_timeout_seconds),
|
83
|
-
)
|
84
|
-
Datadog.logger.debug("Crash tracking #{action} successful")
|
85
|
-
rescue => e
|
86
|
-
Datadog.logger.error("Failed to #{action} crash tracking: #{e.message}")
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|