lib/sqreen/runner.rb in sqreen-1.18.6-java vs lib/sqreen/runner.rb in sqreen-1.19.0.beta1
- old
+ new
@@ -1,5 +1,7 @@
+# typed: ignore
+
# Copyright (c) 2015 Sqreen. All Rights Reserved.
# Please refer to our terms for more information: https://www.sqreen.com/terms.html
require 'ipaddr'
require 'timeout'
@@ -16,12 +18,13 @@
require 'sqreen/metrics_store'
require 'sqreen/deliveries/simple'
require 'sqreen/deliveries/batch'
require 'sqreen/performance_notifications/metrics'
require 'sqreen/performance_notifications/binned_metrics'
-require 'sqreen/instrumentation'
+require 'sqreen/legacy/instrumentation'
require 'sqreen/call_countable'
+require 'sqreen/weave/legacy/instrumentation'
module Sqreen
@features = {}
@queue = nil
@@ -115,12 +118,17 @@
raise(Sqreen::TokenNotFoundException, 'no token found') unless @token
register_exit_cb if set_at_exit
self.metrics_engine = MetricsStore.new
- @instrumenter = Instrumentation.new(metrics_engine)
+ if @configuration.get(:weave)
+ @instrumenter = Sqreen::Weave::Legacy::Instrumentation.new(metrics_engine)
+ else
+ @instrumenter = Sqreen::Legacy::Instrumentation.new(metrics_engine)
+ end
+
Sqreen.log.debug "Using token #{@token}"
response = create_session(session_class)
wanted_features = response.fetch('features', {})
conf_initial_features = configuration.get(:initial_features)
unless conf_initial_features.nil?
@@ -233,20 +241,19 @@
end
def remove_instrumentation(_context_infos = {})
Sqreen.log.debug 'Removing instrumentation'
instrumenter.remove_all_callbacks
- Sqreen::Actions::Repository.instance.clear
+ Sqreen::Actions::Repository.clear
Sqreen.log.debug 'Instrumentation removed'
true
end
def reload_rules(_context_infos = {})
Sqreen.log.debug 'Reloading rules'
rulespack_id, rules = load_rules
instrumenter.remove_all_callbacks
- Sqreen::Actions::Repository.instance.clear
@framework.instrument_when_ready!(instrumenter, rules)
Sqreen.log.debug 'Rules reloaded'
rulespack_id.to_s
end
@@ -302,16 +309,22 @@
def features=(features)
Sqreen.update_features(features)
session.request_compression = features['request_compression'] if session
self.performance_metrics_period = features['performance_metrics_period']
+
+ unless @configuration.get(:weave)
+
config_binned_metrics(features['perf_level'] || DEFAULT_PERF_LEVEL,
features['perf_base'] || PerformanceNotifications::BinnedMetrics::DEFAULT_PERF_BASE,
features['perf_unit'] || PerformanceNotifications::BinnedMetrics::DEFAULT_PERF_UNIT,
features['perf_pct_base'] || PerformanceNotifications::BinnedMetrics::DEFAULT_PERF_PCT_BASE,
features['perf_pct_unit'] || PerformanceNotifications::BinnedMetrics::DEFAULT_PERF_PCT_UNIT,
)
+
+ end
+
self.call_counts_metrics_period = features['call_counts_metrics_period']
hd = features['heartbeat_delay'].to_i
self.heartbeat_delay = hd if hd > 0
return if features['batch_size'].nil?
batch_events(features['batch_size'], features['max_staleness'])
@@ -454,17 +467,16 @@
private
def load_actions(hashes)
unsupported = Set.new
- repos = Sqreen::Actions::Repository.instance
- repos.clear
+ new_repos = Sqreen::Actions::Repository.new
actions = hashes.map do |h|
begin
act = Sqreen::Actions.deserialize_action(h)
- repos.add h['parameters'], act
+ new_repos.add h['parameters'], act
act
rescue Sqreen::Actions::UnknownActionType => e
Sqreen.log.warn("Unsupported action type: #{e.action_type}")
unsupported << e.action_type
nil
@@ -473,9 +485,11 @@
end
end
actions = actions.reject(&:nil?)
Sqreen.log.debug("Added #{actions.size} valid actions")
+
+ Sqreen::Actions::Repository.current = new_repos
unsupported
end
end
end