wildsight 0.1.19 → 0.1.20

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
2
  SHA1:
3
- metadata.gz: f9f718b43a5208321225ed5cfcb015b19a66fd79
4
- data.tar.gz: ec33cba5ffc3a921e27a17d535bb9d5b5c3ebaeb
3
+ metadata.gz: 6ee42269fa992f53798cec753fcca9badb6fad51
4
+ data.tar.gz: 7f13c14c90891d7f58bb557e7a8187b8a23810a6
5
5
  SHA512:
6
- metadata.gz: 14153d97fc2a2068edce6bb26eb193f1acf9afe7f1bc0702085e51271267ca6ad1276d617f20cb1428844e709d8d3f0176e20540ae764f8e63bd4ee60d4f6f4f
7
- data.tar.gz: a215ffc0e1ad8565eab667554169fc80a7c7ec639b9dfc68d64dca1314b359277e1ac0e5cbb13fdded89b6872a80766d88c1aa4957bb0b4ee6de8cd30c9ee188
6
+ metadata.gz: 295b99bd465d01440b07add3deea6281707366171589b867e365fc0b30e288e0e8105a17c27700c669ba94ce6d33f47654abe203007d8284c29295af34e14297
7
+ data.tar.gz: 3a1563a2cea1d09fae697c808c1cba0c5e1ae11aa5d72b650793c7edecae346d0a4582f1dae70ffa06a06c141146379fe34f1a0817e4a258d7a6ac5061b170fb
@@ -51,8 +51,8 @@ module Wildsight
51
51
  @contexts.delete(name)
52
52
  end
53
53
 
54
- def submit(event)
55
- @events << event
54
+ def submit(type, event)
55
+ (@events[type] ||= []) << event
56
56
  if @events.size > @config['agent']['threshold']
57
57
  self.logger.log(:debug) { 'Uploading collected data' }
58
58
  upload
@@ -60,7 +60,7 @@ module Wildsight
60
60
  end
61
61
 
62
62
  def upload
63
- payload, @events = @events, []
63
+ payload, @events = @events, {}
64
64
  @transport.send(payload) if payload != nil && payload.size > 0
65
65
  end
66
66
 
@@ -70,7 +70,7 @@ module Wildsight
70
70
  @logger = Wildsight::Agent::Logger.new(@config)
71
71
  @logger.log(:debug) { 'Logger initialized' }
72
72
 
73
- @events = []
73
+ @events = {}
74
74
  @contexts = {}
75
75
 
76
76
  @transport = Wildsight::Transport.detect.new(self, @config)
@@ -33,9 +33,27 @@ module Wildsight
33
33
  thread.thread_variable_set('wildsight.context', nil)
34
34
  end
35
35
 
36
- def report(series, payload = {}, profiler = nil)
37
- occurred = DateTime.now
38
- @agent.submit({series: "ruby|#{series}", context: @name, occurred: occurred, payload: payload, profiler: profiler})
36
+ def event(series, data, occurred = DateTime.now, source = Wildsight.source, host = Wildsight.host)
37
+ @agent.submit(:events, {
38
+ host: host,
39
+ source: source,
40
+ series: series,
41
+ context: @name,
42
+ occurred: occurred,
43
+ data: data
44
+ })
45
+ end
46
+
47
+ def metric(series, value, data = {}, occurred = DateTime.now, source = Wildsight.source, host = Wildsight.host)
48
+ @agent.submit(:metrics, {
49
+ host: host,
50
+ source: source,
51
+ series: series,
52
+ context: @name,
53
+ occurred: occurred,
54
+ value: value,
55
+ data: data
56
+ })
39
57
  end
40
58
 
41
59
  def profiler
@@ -14,12 +14,11 @@ module Wildsight
14
14
  def call(severity, time, progname, msg)
15
15
  payload = {
16
16
  :severity => severity,
17
- :occurred => time,
18
17
  :facility => progname,
19
18
  :message => msg.to_s.strip
20
19
  }
21
20
  context = @context || Wildsight::Context.detect
22
- context.report(:log, payload) if context
21
+ context.event(:log, payload) if context
23
22
  return nil
24
23
  end
25
24
 
@@ -12,7 +12,7 @@ module Wildsight
12
12
  response = context.profiler.duration(:rails) { @app.call(env) }
13
13
  return response
14
14
  rescue Exception => e
15
- context.report(:exception, extract(e))
15
+ context.event(:exception, extract(e))
16
16
  raise e
17
17
  end
18
18
 
@@ -50,9 +50,11 @@ module Wildsight
50
50
  RESPONSE_EXCLUDE_KEYS.each { |key| context.data[:rack][:response][:headers].delete(key) }
51
51
  end
52
52
 
53
- profiler = METRICS.inject({}) { |c, name| c[name] = context.profiler.data[name]; c }
53
+ context.event(:action_controller, context.data[:rack])
54
54
 
55
- context.report(:action_controller, context.data[:rack], profiler)
55
+ context.profiler.data.keys.each do |key|
56
+ context.metric(key, context.profiler.data[key][:duration])
57
+ end
56
58
 
57
59
  return response
58
60
  ensure
@@ -99,7 +99,7 @@ module Wildsight
99
99
  :connection => args[4][:connection_id].to_s,
100
100
  :duration => (args[2] - args[1]) * 1000
101
101
  }
102
- context.report(:active_record, event)
102
+ context.event(:active_record, event)
103
103
  end
104
104
  end
105
105
 
@@ -1,3 +1,3 @@
1
1
  module Wildsight
2
- VERSION = '0.1.19'
2
+ VERSION = '0.1.20'
3
3
  end
@@ -1,5 +1,27 @@
1
1
  require 'wildsight/version'
2
2
 
3
+ require 'socket'
4
+
5
+ module Wildsight
6
+
7
+ def self.source=(value)
8
+ @source = value
9
+ end
10
+
11
+ def self.source
12
+ @source ||= 'ruby'
13
+ end
14
+
15
+ def self.host=(value)
16
+ @host = value
17
+ end
18
+
19
+ def self.host
20
+ @host ||= Socket.gethostname
21
+ end
22
+
23
+ end
24
+
3
25
  require 'wildsight/transport/transport'
4
26
  require 'wildsight/metrics/metrics'
5
27
  require 'wildsight/profiler/profiler'
@@ -7,13 +29,18 @@ require 'wildsight/context/context'
7
29
  require 'wildsight/context/logger'
8
30
  require 'wildsight/agent/agent'
9
31
 
32
+
10
33
  if defined?(Rack)
34
+ Wildsight.source = 'rack'
35
+
11
36
  require 'wildsight/rack/rack'
12
37
  require 'wildsight/rack/top_middleware'
13
38
  require 'wildsight/rack/bottom_middleware'
14
39
  end
15
40
 
16
41
  if defined?(Rails)
42
+ Wildsight.source = 'rails'
43
+
17
44
  require 'wildsight/rails/action_controller'
18
45
  require 'wildsight/rails/active_record'
19
46
  require 'wildsight/rails/railtie'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wildsight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.19
4
+ version: 0.1.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marek Jelen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-07-22 00:00:00.000000000 Z
12
+ date: 2016-07-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json