scout_rails 1.1.5.pre3 → 1.1.5.pre4

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,6 +4,9 @@ class ScoutRails::Store
4
4
 
5
5
  # Limits the size of the metric hash to prevent a metric explosion.
6
6
  MAX_SIZE = 1000
7
+
8
+ # Limit the number of samples that we store metrics with to prevent writing too much data to the layaway file if there are are many processes and many slow samples.
9
+ MAX_SAMPLES_TO_STORE_METRICS = 10
7
10
 
8
11
  attr_accessor :metric_hash
9
12
  attr_accessor :transaction_hash
@@ -193,7 +196,17 @@ class ScoutRails::Store
193
196
  metric_hash
194
197
  end
195
198
 
199
+ # Merges samples together, removing transaction sample metrics from samples if the > MAX_SAMPLES_TO_STORE_METRICS
196
200
  def merge_samples(old_samples)
201
+ # need transaction lock here?
197
202
  self.samples += old_samples
203
+ if trim_samples = self.samples[MAX_SAMPLES_TO_STORE_METRICS..-1]
204
+ ScoutRails::Agent.instance.logger.debug "Trimming metrics from #{trim_samples.size} samples."
205
+ i = MAX_SAMPLES_TO_STORE_METRICS
206
+ trim_samples.each do |sample|
207
+ self.samples[i] = sample.clear_metrics!
208
+ end
209
+ end
210
+ self.samples
198
211
  end
199
212
  end # class Store
@@ -25,4 +25,10 @@ class ScoutRails::TransactionSample
25
25
  @total_call_time = total_call_time
26
26
  @metrics = metrics
27
27
  end
28
+
29
+ # Used to remove metrics when the payload will be too large.
30
+ def clear_metrics!
31
+ @metrics = nil
32
+ self
33
+ end
28
34
  end
@@ -1,3 +1,3 @@
1
1
  module ScoutRails
2
- VERSION = "1.1.5.pre3"
2
+ VERSION = "1.1.5.pre4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scout_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5.pre3
4
+ version: 1.1.5.pre4
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors: