baseline_red_rpm 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2f48e985c64b6fe5ef0768cd698bdff34087adaf
4
- data.tar.gz: 616121b88979893ded3bdc189d275621aee00f34
2
+ SHA256:
3
+ metadata.gz: bbe846afd5e21455189a3cd36e1de25cd9cd3762d81d3abccaee1c731fa2f909
4
+ data.tar.gz: 9779e986323a331505d8af5c14a32aeaa53c83370b2fb4bbebad096fd061f29d
5
5
  SHA512:
6
- metadata.gz: 472252bfc20315849876f30e1c9cff7a7916f53ffa0ffa300812344215168733ba4044d02127870ae0730f0568ef2a69f5eae0baa1c290c46ee71777ac1c9fc5
7
- data.tar.gz: f1460dd9d695924e8ffcc177ba4ac96962dac1f73f2ea77e5a5378a551d7947be8bb6672c22053e80fbb0c5d921868a732ed29580c48fcc14128a57843a7fdf1
6
+ metadata.gz: 4144a1f7f3236e8b3078531acc6ce2bd343b04f2e55965009528bdab1aa86b1933a1d8f990bb1e99e779495de35ad34392797408894a6ef1d0d79b8f77e8932f
7
+ data.tar.gz: b85bda34c12ee20e75a66e6086e13ccee2d24bf3927ac9c986c4b830c5b7c53fc7e5b14420fb0223bdb722a58a818182d05950430beb0a7fd6668734b70331d3
@@ -15,6 +15,7 @@ module BaselineRedRpm
15
15
  :application_name,
16
16
  :instrumentation,
17
17
  :agent_disabled,
18
+ :sample_memory,
18
19
  :ignore_paths
19
20
 
20
21
  def initialize
@@ -24,7 +25,7 @@ module BaselineRedRpm
24
25
  def reload
25
26
  ::BaselineRedRpm.mutex.synchronize do
26
27
  self.app_root = app_root ? Pathname.new(app_root.to_s) : nil
27
- self.host ||= default_if_blank(ENV["BASELINE_RED_HOST"], "http://localhost:5000")
28
+ self.host ||= default_if_blank(ENV["BASELINE_RED_HOST"], "https://baseline.red")
28
29
  self.ssl ||= default_if_blank(ENV["BASELINE_RED_SSL"], false)
29
30
  self.license_key ||= default_if_blank(ENV["BASELINE_RED_LICENSE_KEY"], nil)
30
31
  self.application_name ||= "Default"
@@ -32,6 +33,7 @@ module BaselineRedRpm
32
33
  self.sample_threshold ||= 0 # Minimum amount of duration to sample
33
34
  self.flush_interval ||= 60 # In seconds
34
35
  self.agent_disabled ||= default_if_blank(ENV["BASELINE_RED_AGENT_DISABLED"], false)
36
+ self.sample_memory ||= false
35
37
  self.ignore_paths ||= /\/assets/
36
38
  self.instrumentation = {
37
39
  :rack => { :enabled => true, :backtrace => :app, :source => true, :trace_middleware => false },
@@ -7,6 +7,8 @@ require 'base64'
7
7
  module BaselineRedRpm
8
8
  module Reporters
9
9
  class JsonClient
10
+ attr_accessor :sample_memory
11
+
10
12
  def initialize(opts = { :url => nil, :collector => nil, :flush_interval => nil })
11
13
  @collector = opts[:collector]
12
14
  @flush_interval = opts[:flush_interval]
@@ -16,7 +18,11 @@ module BaselineRedRpm
16
18
  def start
17
19
  @thread = Thread.new do
18
20
  loop do
19
- emit_batch(@collector.retrieve)
21
+ memory_stats = MemoryProfiler.stop
22
+
23
+ emit_batch(@collector.retrieve, memory_stats)
24
+
25
+ start_memory_profiler
20
26
  sleep @flush_interval
21
27
  end
22
28
  end
@@ -29,10 +35,18 @@ module BaselineRedRpm
29
35
 
30
36
  private
31
37
 
32
- def compress_body(data)
38
+ def start_memory_profiler
39
+ return unless BaselineRedRpm.config.sample_memory
40
+ if Time.now.utc - BaselineRedRpm.config.sample_memory < 5.minutes
41
+ MemoryProfiler.start
42
+ end
43
+ end
44
+
45
+ def compress_body(data, memory_stats)
33
46
  body = MessagePack.pack({
34
47
  "name" => BaselineRedRpm.config.application_name,
35
48
  "host" => BaselineRedRpm.host,
49
+ "memory_stats" => memory_stats,
36
50
  "data" => data
37
51
  })
38
52
 
@@ -40,7 +54,7 @@ module BaselineRedRpm
40
54
  Base64.encode64(compressed_body)
41
55
  end
42
56
 
43
- def emit_batch(spans)
57
+ def emit_batch(spans, memory_stats)
44
58
  return if spans.empty?
45
59
 
46
60
  sock = Net::HTTP.new(@spans_uri.host, @spans_uri.port)
@@ -50,7 +64,7 @@ module BaselineRedRpm
50
64
  "Accept-Encoding" => "gzip",
51
65
  "User-Agent" => "gzip"
52
66
  })
53
- request.body = compress_body(spans)
67
+ request.body = compress_body(spans, memory_stats)
54
68
  request.content_type = "application/octet-stream"
55
69
 
56
70
  response = sock.start do |http|
@@ -60,6 +74,10 @@ module BaselineRedRpm
60
74
 
61
75
  if response.code != 202
62
76
  STDERR.puts(response.body)
77
+ elsif response.code == 200
78
+ json = JSON.parse(response.body)
79
+ BaselineRedRpm.config.sample_memory =
80
+ json['sample_memory'].present? ? Time.parse(json['sample_memory']) : nil
63
81
  end
64
82
  rescue => e
65
83
  STDERR.puts("Error emitting spans batch: #{e.message}\n#{e.backtrace.join("\n")}")
@@ -73,6 +73,8 @@ module BaselineRedRpm
73
73
  collector: collector,
74
74
  flush_interval: config.flush_interval
75
75
  )
76
+ @sender.sample_memory = config.sample_memory
77
+ @sender
76
78
  end
77
79
 
78
80
  def tracer
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baseline_red_rpm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Jones
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-24 00:00:00.000000000 Z
11
+ date: 2018-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -204,8 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
204
  - !ruby/object:Gem::Version
205
205
  version: '0'
206
206
  requirements: []
207
- rubyforge_project:
208
- rubygems_version: 2.6.13
207
+ rubygems_version: 3.0.1
209
208
  signing_key:
210
209
  specification_version: 4
211
210
  summary: Baseline Red Ruby Agent