rorvswild 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e75768f7cf7390cfb3c36192245897160fb1529
4
- data.tar.gz: 83570aeb82387bec304eb5998f49ac72c2c23f00
3
+ metadata.gz: f54f409b8f0d1dedb0891da5a680d7a701a67a2d
4
+ data.tar.gz: bb647ca3ce47cc27fd6279dd25fbabae7d48ab15
5
5
  SHA512:
6
- metadata.gz: 73d40d8b2d14317b7fb16ee61942c6212580951c2d337fe407c5d9765e0076c7950006f2401f87985750fbbd6439dfcda40321bd394edf713f802e33c869fe52
7
- data.tar.gz: 24ec5bad1f5b8f0dfcafcb37fc3b7b30c4581829673b540c294ff93d0cab79ec2f5f83694ad839dbceee28fb0ec5047b8268cc8ad248f4ffb8bbaa675c10dffb
6
+ metadata.gz: af4176a3d8b8e48db393dfb0001c616184a98ca885163fb566f98bd089deac147eea471a372d0821d4120153088d0ec83af23007d69aad557e2f9d1d6b9ea185
7
+ data.tar.gz: 3b35e6030188581d2a8e239aa7163742665fd6401f38788f8046e62668fd79ba13858466254a22a2a32f631519f03562b721dcd92c52bb24daaf839f7b03066f
@@ -1,3 +1,3 @@
1
1
  class Rorvswild
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/rorvswild.rb CHANGED
@@ -45,20 +45,24 @@ module RorVsWild
45
45
  request[:other_runtime] = compute_duration(start, finish) - request[:db_runtime] - request[:view_runtime]
46
46
  request[:params] = params_filter.filter(payload[:params]) if error
47
47
  Thread.new { post_request }
48
- rescue => ex
49
- Rails.logger.error("[RorVsWild] " + ex.inspect)
50
- Rails.logger.error("[RorVsWild] " + ex.backtrace.join("\n[RorVsWild] "))
48
+ rescue => exception
49
+ log_error(exception)
51
50
  end
52
51
 
53
52
  def after_sql_query(name, start, finish, id, payload)
54
53
  return if !queries || payload[:name] == "EXPLAIN".freeze
55
54
  runtime, sql, plan = compute_duration(start, finish), nil, nil
56
55
  file, line, method = extract_file_and_line_from_call_stack(caller)
56
+
57
+ if !file # I have no idea of the origin of the query, so at least we log the SQL.
58
+ file, line, method = ["Unknow", 0, "Unknow"]
59
+ sql = payload[:sql]
60
+ end
61
+
57
62
  plan = explain(sql = payload[:sql], payload[:binds]) if runtime > sql_threshold
58
63
  queries << {file: file, line: line, sql: sql, plan: plan, runtime: runtime}
59
- rescue => ex
60
- Rails.logger.error("[RorVsWild] " + ex.inspect)
61
- Rails.logger.error("[RorVsWild] " + ex.backtrace.join("\n[RorVsWild] "))
64
+ rescue => exception
65
+ log_error(exception)
62
66
  end
63
67
 
64
68
  def after_view_rendering(name, start, finish, id, payload)
@@ -107,11 +111,15 @@ module RorVsWild
107
111
 
108
112
  def post_request
109
113
  post("/requests", request: request.merge(queries: slowest_queries, views: slowest_views, error: error))
114
+ rescue => exception
115
+ log_error(exception)
110
116
  end
111
117
 
112
118
  def extract_file_and_line_from_call_stack(stack)
113
- file, line, method = (stack.find { |str| str.include?(Rails.root.to_s) } ||
114
- stack.find { |str| str.include?("(irb):") }).split(":")
119
+ location = stack.find { |str| str.include?(Rails.root.to_s) } ||
120
+ stack.find { |str| !str.include?("/active_support/notifications/") } # Origin of the call comes from a gem probably
121
+ return unless location # Ok I have no idea
122
+ file, line, method = location.split(":")
115
123
  file.sub!(Rails.root.to_s, "")
116
124
  method.sub!("block in ", "")
117
125
  method.sub!("in `", "")
@@ -130,7 +138,7 @@ module RorVsWild
130
138
  def post(path, data)
131
139
  uri = URI(api_url + path)
132
140
  Net::HTTP.start(uri.host, uri.port) do |http|
133
- post = Net::HTTP::Post.new(uri)
141
+ post = Net::HTTP::Post.new(uri.path)
134
142
  post.content_type = "application/json"
135
143
  post.basic_auth(app_id, api_key)
136
144
  post.body = data.to_json
@@ -141,5 +149,14 @@ module RorVsWild
141
149
  def params_filter
142
150
  @params_filter ||= ActionDispatch::Http::ParameterFilter.new(Rails.application.config.filter_parameters)
143
151
  end
152
+
153
+ def logger
154
+ Rails.logger
155
+ end
156
+
157
+ def log_error(exception)
158
+ logger.error("[RorVsWild] " + exception.inspect)
159
+ logger.error("[RorVsWild] " + exception.backtrace.join("\n[RorVsWild] "))
160
+ end
144
161
  end
145
162
  end
data/rorvswild.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Rorvswild::VERSION
9
9
  spec.authors = ["Alexis Bernard"]
10
10
  spec.email = ["alexis@bernard.io"]
11
- spec.summary = "RorVsWild tracks response time of your Rails application."
12
- spec.description = "RorVsWild helps you to improve the response time, by pointing out any slow request, query and view."
11
+ spec.summary = "RorVsWild tracks response time of Rails applications."
12
+ spec.description = "RorVsWild helps to improve the response time, by pointing out any slow request, query and view."
13
13
  spec.homepage = "http://www.rorvswild.com"
14
14
  spec.license = "MIT"
15
15
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rorvswild
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexis Bernard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-06 00:00:00.000000000 Z
11
+ date: 2014-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,8 +24,8 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.6'
27
- description: RorVsWild helps you to improve the response time, by pointing out any
28
- slow request, query and view.
27
+ description: RorVsWild helps to improve the response time, by pointing out any slow
28
+ request, query and view.
29
29
  email:
30
30
  - alexis@bernard.io
31
31
  executables: []
@@ -63,5 +63,5 @@ rubyforge_project:
63
63
  rubygems_version: 2.2.2
64
64
  signing_key:
65
65
  specification_version: 4
66
- summary: RorVsWild tracks response time of your Rails application.
66
+ summary: RorVsWild tracks response time of Rails applications.
67
67
  test_files: []