ddtrace 1.13.0 → 1.14.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +50 -1
- data/ext/ddtrace_profiling_native_extension/native_extension_helpers.rb +15 -0
- data/lib/datadog/appsec/configuration/settings.rb +7 -1
- data/lib/datadog/core/configuration/agent_settings_resolver.rb +9 -5
- data/lib/datadog/core/configuration/components.rb +2 -0
- data/lib/datadog/core/configuration/settings.rb +25 -2
- data/lib/datadog/core/diagnostics/environment_logger.rb +130 -234
- data/lib/datadog/core/environment/execution.rb +65 -0
- data/lib/datadog/core/telemetry/collector.rb +10 -2
- data/lib/datadog/profiling/component.rb +14 -4
- data/lib/datadog/profiling/diagnostics/environment_logger.rb +39 -0
- data/lib/datadog/profiling/exporter.rb +4 -4
- data/lib/datadog/profiling/flush.rb +2 -4
- data/lib/datadog/profiling/http_transport.rb +9 -2
- data/lib/datadog/profiling.rb +1 -0
- data/lib/datadog/tracing/component.rb +2 -1
- data/lib/datadog/tracing/contrib/active_record/configuration/resolver.rb +18 -11
- data/lib/datadog/tracing/contrib/active_record/utils.rb +1 -1
- data/lib/datadog/tracing/contrib/elasticsearch/patcher.rb +99 -102
- data/lib/datadog/tracing/contrib/http/instrumentation.rb +5 -2
- data/lib/datadog/tracing/contrib/lograge/instrumentation.rb +1 -17
- data/lib/datadog/tracing/contrib/rails/log_injection.rb +6 -3
- data/lib/datadog/tracing/contrib/rails/patcher.rb +1 -1
- data/lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb +3 -20
- data/lib/datadog/tracing/contrib/utils/quantization/http.rb +9 -9
- data/lib/datadog/tracing/contrib.rb +1 -0
- data/lib/datadog/tracing/correlation.rb +20 -0
- data/lib/datadog/tracing/diagnostics/environment_logger.rb +159 -0
- data/lib/datadog/tracing/workers/trace_writer.rb +1 -1
- data/lib/ddtrace/version.rb +1 -1
- metadata +9 -6
@@ -0,0 +1,159 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
require 'json'
|
5
|
+
require 'rbconfig'
|
6
|
+
require_relative '../../core/diagnostics/environment_logger'
|
7
|
+
|
8
|
+
module Datadog
|
9
|
+
module Tracing
|
10
|
+
module Diagnostics
|
11
|
+
# Collects and logs Tracing diagnostic and error information
|
12
|
+
module EnvironmentLogger
|
13
|
+
extend Core::Diagnostics::EnvironmentLogging
|
14
|
+
|
15
|
+
def self.collect_and_log!(responses: nil)
|
16
|
+
log_once! do
|
17
|
+
env_data = EnvironmentCollector.collect_config!
|
18
|
+
log_configuration!('TRACING', env_data.to_json)
|
19
|
+
|
20
|
+
if responses
|
21
|
+
err_data = EnvironmentCollector.collect_errors!(responses)
|
22
|
+
err_data.reject! { |_, v| v.nil? } # Remove empty values from hash output
|
23
|
+
log_error!('TRACING', 'Agent Error', err_data.to_json) unless err_data.empty?
|
24
|
+
end
|
25
|
+
end
|
26
|
+
rescue => e
|
27
|
+
logger.warn("Failed to collect tracing environment information: #{e} Location: #{Array(e.backtrace).first}")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Collects environment information for Tracing diagnostic logging
|
32
|
+
module EnvironmentCollector
|
33
|
+
class << self
|
34
|
+
def collect_config!
|
35
|
+
{
|
36
|
+
enabled: enabled,
|
37
|
+
agent_url: agent_url,
|
38
|
+
analytics_enabled: analytics_enabled,
|
39
|
+
sample_rate: sample_rate,
|
40
|
+
sampling_rules: sampling_rules,
|
41
|
+
integrations_loaded: integrations_loaded,
|
42
|
+
partial_flushing_enabled: partial_flushing_enabled,
|
43
|
+
priority_sampling_enabled: priority_sampling_enabled,
|
44
|
+
**instrumented_integrations_settings
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
def collect_errors!(responses)
|
49
|
+
{
|
50
|
+
agent_error: agent_error(responses)
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
# @return [Boolean, nil]
|
55
|
+
def enabled
|
56
|
+
!!Datadog.configuration.tracing.enabled
|
57
|
+
end
|
58
|
+
|
59
|
+
# @return [String, nil] target agent URL for trace flushing
|
60
|
+
def agent_url
|
61
|
+
# Retrieve the effect agent URL, regardless of how it was configured
|
62
|
+
transport = Tracing.send(:tracer).writer.transport
|
63
|
+
|
64
|
+
# return `nil` with IO transport
|
65
|
+
return unless transport.respond_to?(:client)
|
66
|
+
|
67
|
+
adapter = transport.client.api.adapter
|
68
|
+
adapter.url
|
69
|
+
end
|
70
|
+
|
71
|
+
# Error returned by Datadog agent during a tracer flush attempt
|
72
|
+
# @return [String] concatenated list of transport errors
|
73
|
+
def agent_error(responses)
|
74
|
+
error_responses = responses.reject(&:ok?)
|
75
|
+
|
76
|
+
return nil if error_responses.empty?
|
77
|
+
|
78
|
+
error_responses.map(&:inspect).join(',')
|
79
|
+
end
|
80
|
+
|
81
|
+
# @return [Boolean, nil] analytics enabled in configuration
|
82
|
+
def analytics_enabled
|
83
|
+
!!Datadog.configuration.tracing.analytics.enabled
|
84
|
+
end
|
85
|
+
|
86
|
+
# @return [Numeric, nil] tracer sample rate configured
|
87
|
+
def sample_rate
|
88
|
+
sampler = Datadog.configuration.tracing.sampler
|
89
|
+
return nil unless sampler
|
90
|
+
|
91
|
+
sampler.sample_rate(nil) rescue nil
|
92
|
+
end
|
93
|
+
|
94
|
+
# DEV: We currently only support SimpleRule instances.
|
95
|
+
# DEV: These are the most commonly used rules.
|
96
|
+
# DEV: We should expand support for other rules in the future,
|
97
|
+
# DEV: although it is tricky to serialize arbitrary rules.
|
98
|
+
#
|
99
|
+
# @return [Hash, nil] sample rules configured
|
100
|
+
def sampling_rules
|
101
|
+
sampler = Datadog.configuration.tracing.sampler
|
102
|
+
return nil unless sampler.is_a?(Tracing::Sampling::PrioritySampler) &&
|
103
|
+
sampler.priority_sampler.is_a?(Tracing::Sampling::RuleSampler)
|
104
|
+
|
105
|
+
sampler.priority_sampler.rules.map do |rule|
|
106
|
+
next unless rule.is_a?(Tracing::Sampling::SimpleRule)
|
107
|
+
|
108
|
+
{
|
109
|
+
name: rule.matcher.name,
|
110
|
+
service: rule.matcher.service,
|
111
|
+
sample_rate: rule.sampler.sample_rate(nil)
|
112
|
+
}
|
113
|
+
end.compact
|
114
|
+
end
|
115
|
+
|
116
|
+
# Concatenated list of integrations activated, with their gem version.
|
117
|
+
# Example: "rails@6.0.3,rack@2.2.3"
|
118
|
+
#
|
119
|
+
# @return [String, nil]
|
120
|
+
def integrations_loaded
|
121
|
+
integrations = instrumented_integrations
|
122
|
+
return if integrations.empty?
|
123
|
+
|
124
|
+
integrations.map { |name, integration| "#{name}@#{integration.class.version}" }.join(',')
|
125
|
+
end
|
126
|
+
|
127
|
+
# @return [Boolean, nil] partial flushing enabled in configuration
|
128
|
+
def partial_flushing_enabled
|
129
|
+
!!Datadog.configuration.tracing.partial_flush.enabled
|
130
|
+
end
|
131
|
+
|
132
|
+
# @return [Boolean, nil] priority sampling enabled in configuration
|
133
|
+
def priority_sampling_enabled
|
134
|
+
!!Datadog.configuration.tracing.priority_sampling
|
135
|
+
end
|
136
|
+
|
137
|
+
private
|
138
|
+
|
139
|
+
def instrumented_integrations
|
140
|
+
Datadog.configuration.tracing.instrumented_integrations
|
141
|
+
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
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
@@ -57,7 +57,7 @@ module Datadog
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
# TODO: Register `Datadog::
|
60
|
+
# TODO: Register `Datadog::Tracing::Diagnostics::EnvironmentLogger.collect_and_log!`
|
61
61
|
# TODO: as a flush_completed subscriber when the `TraceWriter`
|
62
62
|
# TODO: instantiation code is implemented.
|
63
63
|
def flush_completed
|
data/lib/ddtrace/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ddtrace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.14.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: 2023-
|
11
|
+
date: 2023-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -244,6 +244,7 @@ files:
|
|
244
244
|
- lib/datadog/core/environment/cgroup.rb
|
245
245
|
- lib/datadog/core/environment/class_count.rb
|
246
246
|
- lib/datadog/core/environment/container.rb
|
247
|
+
- lib/datadog/core/environment/execution.rb
|
247
248
|
- lib/datadog/core/environment/ext.rb
|
248
249
|
- lib/datadog/core/environment/gc.rb
|
249
250
|
- lib/datadog/core/environment/identity.rb
|
@@ -378,6 +379,7 @@ files:
|
|
378
379
|
- lib/datadog/profiling/collectors/stack.rb
|
379
380
|
- lib/datadog/profiling/collectors/thread_context.rb
|
380
381
|
- lib/datadog/profiling/component.rb
|
382
|
+
- lib/datadog/profiling/diagnostics/environment_logger.rb
|
381
383
|
- lib/datadog/profiling/encoding/profile.rb
|
382
384
|
- lib/datadog/profiling/event.rb
|
383
385
|
- lib/datadog/profiling/events/stack.rb
|
@@ -800,6 +802,7 @@ files:
|
|
800
802
|
- lib/datadog/tracing/contrib/utils/quantization/hash.rb
|
801
803
|
- lib/datadog/tracing/contrib/utils/quantization/http.rb
|
802
804
|
- lib/datadog/tracing/correlation.rb
|
805
|
+
- lib/datadog/tracing/diagnostics/environment_logger.rb
|
803
806
|
- lib/datadog/tracing/diagnostics/ext.rb
|
804
807
|
- lib/datadog/tracing/diagnostics/health.rb
|
805
808
|
- lib/datadog/tracing/distributed/b3_multi.rb
|
@@ -892,7 +895,7 @@ licenses:
|
|
892
895
|
metadata:
|
893
896
|
allowed_push_host: https://rubygems.org
|
894
897
|
changelog_uri: https://github.com/DataDog/dd-trace-rb/blob/master/CHANGELOG.md
|
895
|
-
post_install_message:
|
898
|
+
post_install_message:
|
896
899
|
rdoc_options: []
|
897
900
|
require_paths:
|
898
901
|
- lib
|
@@ -910,8 +913,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
910
913
|
- !ruby/object:Gem::Version
|
911
914
|
version: 2.0.0
|
912
915
|
requirements: []
|
913
|
-
rubygems_version: 3.4.
|
914
|
-
signing_key:
|
916
|
+
rubygems_version: 3.4.5
|
917
|
+
signing_key:
|
915
918
|
specification_version: 4
|
916
919
|
summary: Datadog tracing code for your Ruby applications
|
917
920
|
test_files: []
|