rorvswild 1.6.5 → 1.7.0
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 +4 -4
- data/lib/rorvswild/agent.rb +5 -0
- data/lib/rorvswild/client.rb +1 -1
- data/lib/rorvswild/deployment.rb +1 -1
- data/lib/rorvswild/installer.rb +12 -0
- data/lib/rorvswild/local/middleware.rb +3 -1
- data/lib/rorvswild/plugin/middleware.rb +22 -4
- data/lib/rorvswild/queue.rb +4 -2
- data/lib/rorvswild/version.rb +1 -1
- data/lib/rorvswild.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0dc87868138ecb496f99d1d4adc670f0776b3fe4fa8312ec8c9126e33800c62
|
4
|
+
data.tar.gz: 05334e640532cefa98e18c895d2c599d45714812ed948dd5150748df0d139722
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1476eb8421864a1cdfc904988204b5da750249d1054d72ee0a1d2ab1a07a1aba14fe9851ee54a66f9f7cae442f9e025b216f5b1d99fc73f26474f2c3e8a0347
|
7
|
+
data.tar.gz: 66e61e2d41d97d42a80e8f6854badd6cd1247449a8a1e3192415885864bdca62339aff4b23640edd067f8931f4e9c1f81bbda84ec4df975e61be3e34df1556ed
|
data/lib/rorvswild/agent.rb
CHANGED
@@ -133,6 +133,10 @@ module RorVsWild
|
|
133
133
|
current_data[:error_context] = hash if current_data
|
134
134
|
end
|
135
135
|
|
136
|
+
def send_server_timing=(boolean)
|
137
|
+
current_data[:send_server_timing] = boolean if current_data
|
138
|
+
end
|
139
|
+
|
136
140
|
def current_data
|
137
141
|
Thread.current[:rorvswild_data]
|
138
142
|
end
|
@@ -182,6 +186,7 @@ module RorVsWild
|
|
182
186
|
|
183
187
|
def queue_request
|
184
188
|
(data = cleanup_data) && data[:name] && queue.push_request(data)
|
189
|
+
data
|
185
190
|
end
|
186
191
|
|
187
192
|
def queue_job
|
data/lib/rorvswild/client.rb
CHANGED
@@ -11,7 +11,7 @@ module RorVsWild
|
|
11
11
|
CERTIFICATE_AUTHORITIES_PATH = File.expand_path("../../../cacert.pem", __FILE__)
|
12
12
|
DEFAULT_TIMEOUT = 10
|
13
13
|
|
14
|
-
attr_reader :api_url, :api_key, :timeout, :threads
|
14
|
+
attr_reader :api_url, :api_key, :timeout, :threads, :config
|
15
15
|
|
16
16
|
def initialize(config)
|
17
17
|
Kernel.at_exit(&method(:at_exit))
|
data/lib/rorvswild/deployment.rb
CHANGED
data/lib/rorvswild/installer.rb
CHANGED
@@ -48,7 +48,9 @@ production:
|
|
48
48
|
# - Redis
|
49
49
|
# - Resque
|
50
50
|
# - Sidekiq
|
51
|
+
#
|
51
52
|
# logger: log/rorvswild.log # By default it uses Rails.logger or Logger.new(STDOUT)
|
53
|
+
#
|
52
54
|
# # Deployment tracking is working without any actions from your part if the Rails app
|
53
55
|
# # is inside a Git repositoriy, is deployed via Capistrano.
|
54
56
|
# # In the other cases, you can provide the following details.
|
@@ -57,6 +59,16 @@ production:
|
|
57
59
|
# description: <%= "Eventually if you have a description such as a Git message" %>
|
58
60
|
# author: <%= "Author's name of the deployment" %>
|
59
61
|
# email: <%= "emailOf@theAuthor.example" %>
|
62
|
+
#
|
63
|
+
# Sampling allows to send a fraction of jobs and requests.
|
64
|
+
# If your app is sending hundred of millions of requests per month,
|
65
|
+
# you will probably get the same precision if you send only a fraction of it.
|
66
|
+
# Thus, it decreases the bill at the end of the month. It's also a mitigation if
|
67
|
+
# your app is a target of a DoS. There are 2 parameters to dissociate requests and jobs.
|
68
|
+
# Indeed, for an app handling a lot of request but very few jobs, it makes sens to sample
|
69
|
+
# the former but not the latter.
|
70
|
+
# request_sampling_rate: 0.25 # 25% of requests are sent
|
71
|
+
# job_sampling_rate: 0.5 # 50% of jobs are sent
|
60
72
|
YAML
|
61
73
|
end
|
62
74
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RorVsWild
|
2
4
|
module Local
|
3
5
|
class Middleware
|
@@ -99,7 +101,7 @@ module RorVsWild
|
|
99
101
|
end
|
100
102
|
|
101
103
|
def empty_html_page
|
102
|
-
"<!DOCTYPE html>\n<html><head></head><body></body></html>"
|
104
|
+
"<!DOCTYPE html>\n<html><head></head><body></body></html>".dup
|
103
105
|
end
|
104
106
|
|
105
107
|
def log_incompatible_middleware_warning
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RorVsWild
|
2
4
|
module Plugin
|
3
5
|
class Middleware
|
@@ -13,19 +15,35 @@ module RorVsWild
|
|
13
15
|
|
14
16
|
def call(env)
|
15
17
|
RorVsWild.agent.start_request
|
16
|
-
RorVsWild.agent.current_data[:path] = env["ORIGINAL_FULLPATH"
|
18
|
+
RorVsWild.agent.current_data[:path] = env["ORIGINAL_FULLPATH"]
|
17
19
|
section = RorVsWild::Section.start
|
18
20
|
section.file, section.line = rails_engine_location
|
19
|
-
section.command = "Rails::Engine#call"
|
20
|
-
@app.call(env)
|
21
|
+
section.command = "Rails::Engine#call"
|
22
|
+
code, headers, body = @app.call(env)
|
23
|
+
[code, headers, body]
|
21
24
|
ensure
|
22
25
|
RorVsWild::Section.stop
|
23
|
-
RorVsWild.agent.stop_request
|
26
|
+
inject_server_timing(RorVsWild.agent.stop_request, headers)
|
24
27
|
end
|
25
28
|
|
26
29
|
def rails_engine_location
|
27
30
|
@rails_engine_location = ::Rails::Engine.instance_method(:call).source_location
|
28
31
|
end
|
32
|
+
|
33
|
+
def format_server_timing(sections)
|
34
|
+
sections.sort_by(&:self_runtime).reverse.map do |section|
|
35
|
+
if section.kind == "view"
|
36
|
+
"#{section.kind};dur=#{section.self_runtime};desc=\"#{section.file}\""
|
37
|
+
else
|
38
|
+
"#{section.kind};dur=#{section.self_runtime};desc=\"#{section.file}:#{section.line}\""
|
39
|
+
end
|
40
|
+
end.join(", ")
|
41
|
+
end
|
42
|
+
|
43
|
+
def inject_server_timing(data, headers)
|
44
|
+
return if !data || !data[:send_server_timing] || !(sections = data[:sections])
|
45
|
+
headers["Server-Timing"] = format_server_timing(sections)
|
46
|
+
end
|
29
47
|
end
|
30
48
|
end
|
31
49
|
end
|
data/lib/rorvswild/queue.rb
CHANGED
@@ -14,15 +14,17 @@ module RorVsWild
|
|
14
14
|
@client = client
|
15
15
|
@mutex = Mutex.new
|
16
16
|
@metrics = RorVsWild::Metrics.new if defined?(Metrics)
|
17
|
+
@request_sampling_rate = client.config[:request_sampling_rate]
|
18
|
+
@job_sampling_rate = client.config[:job_sampling_rate]
|
17
19
|
Kernel.at_exit { flush }
|
18
20
|
end
|
19
21
|
|
20
22
|
def push_job(data)
|
21
|
-
push_to(jobs, data)
|
23
|
+
push_to(jobs, data) if !@job_sampling_rate || rand <= @job_sampling_rate
|
22
24
|
end
|
23
25
|
|
24
26
|
def push_request(data)
|
25
|
-
push_to(requests, data)
|
27
|
+
push_to(requests, data) if !@request_sampling_rate || rand <= @request_sampling_rate
|
26
28
|
end
|
27
29
|
|
28
30
|
def push_to(array, data)
|
data/lib/rorvswild/version.rb
CHANGED
data/lib/rorvswild.rb
CHANGED
@@ -50,6 +50,10 @@ module RorVsWild
|
|
50
50
|
agent.merge_error_context(hash) if agent
|
51
51
|
end
|
52
52
|
|
53
|
+
def self.send_server_timing=(boolean)
|
54
|
+
agent.send_server_timing = boolean if agent
|
55
|
+
end
|
56
|
+
|
53
57
|
def self.initialize_logger(destination = nil)
|
54
58
|
if destination.respond_to?(:info) && destination.respond_to?(:warn) && destination.respond_to?(:error)
|
55
59
|
destination
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rorvswild
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexis Bernard
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-04-
|
12
|
+
date: 2024-04-22 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Performances and errors insights for rails developers.
|
15
15
|
email:
|