Module: Datadog::Tracing::Diagnostics::EnvironmentCollector
- Defined in:
- lib/datadog/tracing/diagnostics/environment_logger.rb
Overview
Collects environment information for Tracing diagnostic logging
Class Method Summary collapse
-
.agent_error(responses) ⇒ String
Error returned by Datadog agent during a tracer flush attempt.
-
.agent_url ⇒ String?
Target agent URL for trace flushing.
-
.analytics_enabled ⇒ Boolean?
Analytics enabled in configuration.
- .collect_config! ⇒ Object
- .collect_errors!(responses) ⇒ Object
- .collect_integrations_settings! ⇒ Object
- .enabled ⇒ Boolean?
-
.integrations_loaded ⇒ String?
Concatenated list of integrations activated, with their gem version.
-
.partial_flushing_enabled ⇒ Boolean?
Partial flushing enabled in configuration.
-
.sample_rate ⇒ Numeric?
Tracer sample rate configured.
-
.sampling_rules ⇒ Hash?
DEV: We currently only support SimpleRule instances.
Class Method Details
.agent_error(responses) ⇒ String
Error returned by Datadog agent during a tracer flush attempt
71 72 73 74 75 76 77 |
# File 'lib/datadog/tracing/diagnostics/environment_logger.rb', line 71 def agent_error(responses) error_responses = responses.reject(&:ok?) return nil if error_responses.empty? error_responses.map(&:inspect).join(',') end |
.agent_url ⇒ String?
Returns target agent URL for trace flushing.
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/datadog/tracing/diagnostics/environment_logger.rb', line 58 def agent_url # Retrieve the effect agent URL, regardless of how it was configured transport = Tracing.send(:tracer).writer.transport # return `nil` with IO transport return unless transport.respond_to?(:client) adapter = transport.client.api.adapter adapter.url end |
.analytics_enabled ⇒ Boolean?
Returns analytics enabled in configuration.
80 81 82 |
# File 'lib/datadog/tracing/diagnostics/environment_logger.rb', line 80 def analytics_enabled !!Datadog.configuration.tracing.analytics.enabled end |
.collect_config! ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/datadog/tracing/diagnostics/environment_logger.rb', line 34 def collect_config! { enabled: enabled, agent_url: agent_url, analytics_enabled: analytics_enabled, sample_rate: sample_rate, sampling_rules: sampling_rules, integrations_loaded: integrations_loaded, partial_flushing_enabled: partial_flushing_enabled, } end |
.collect_errors!(responses) ⇒ Object
46 47 48 49 50 |
# File 'lib/datadog/tracing/diagnostics/environment_logger.rb', line 46 def collect_errors!(responses) { agent_error: agent_error(responses) } end |
.collect_integrations_settings! ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/datadog/tracing/diagnostics/environment_logger.rb', line 130 def collect_integrations_settings! instrumented_integrations.each_with_object({}) do |(name, integration), result| integration.configuration.to_h.each do |setting, value| next if setting == :tracer # Skip internal objects # Convert value to a string to avoid custom #to_json # handlers possibly causing errors. result[:"#{name}_#{setting}"] = value.to_s end end end |
.enabled ⇒ Boolean?
53 54 55 |
# File 'lib/datadog/tracing/diagnostics/environment_logger.rb', line 53 def enabled !!Datadog.configuration.tracing.enabled end |
.integrations_loaded ⇒ String?
Concatenated list of integrations activated, with their gem version. Example: “[email protected],[email protected]”
118 119 120 121 122 123 |
# File 'lib/datadog/tracing/diagnostics/environment_logger.rb', line 118 def integrations_loaded integrations = instrumented_integrations return if integrations.empty? integrations.map { |name, integration| "#{name}@#{integration.class.version}" }.join(',') end |
.partial_flushing_enabled ⇒ Boolean?
Returns partial flushing enabled in configuration.
126 127 128 |
# File 'lib/datadog/tracing/diagnostics/environment_logger.rb', line 126 def partial_flushing_enabled !!Datadog.configuration.tracing.partial_flush.enabled end |
.sample_rate ⇒ Numeric?
Returns tracer sample rate configured.
85 86 87 88 89 90 |
# File 'lib/datadog/tracing/diagnostics/environment_logger.rb', line 85 def sample_rate sampler = Datadog.configuration.tracing.sampler return nil unless sampler sampler.sample_rate(nil) rescue nil end |
.sampling_rules ⇒ Hash?
DEV: We currently only support SimpleRule instances. DEV: These are the most commonly used rules. DEV: We should expand support for other rules in the future, DEV: although it is tricky to serialize arbitrary rules.
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/datadog/tracing/diagnostics/environment_logger.rb', line 98 def sampling_rules sampler = Datadog.configuration.tracing.sampler return nil unless sampler.is_a?(Tracing::Sampling::PrioritySampler) && sampler.priority_sampler.is_a?(Tracing::Sampling::RuleSampler) sampler.priority_sampler.rules.map do |rule| next unless rule.is_a?(Tracing::Sampling::SimpleRule) { name: rule.matcher.name, service: rule.matcher.service, sample_rate: rule.sampler.sample_rate(nil) } end.compact end |