app_profiler 0.1.7 → 0.1.9
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6411e547488321b7d7de4fb7cc2d19c48ac462559331ac79b1e161ac11339fe7
|
4
|
+
data.tar.gz: 8f78938dfcdf37ee184371c6772db42cbca73e547aaab2e904ec51135cb4b69a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 992474693598d4ff50a51d703143d593cb32156fa12f1e9d65fedd6489d5ff5a8d4d6a823a608dca814a64d505a85dc74a36000a07c0c4803377b9ba28cf5457
|
7
|
+
data.tar.gz: f184c40a906cc4cf2989becfd0cf5e8dab28c17a3f2a7cf6ad51da3e244a69d58a60bfc8c8b5011d3bcf955602cce24f36dd2122990104e1d2645b3e76a4fc01
|
data/lib/app_profiler/railtie.rb
CHANGED
@@ -37,6 +37,9 @@ module AppProfiler
|
|
37
37
|
AppProfiler.upload_queue_max_length = app.config.app_profiler.upload_queue_max_length || 10
|
38
38
|
AppProfiler.upload_queue_interval_secs = app.config.app_profiler.upload_queue_interval_secs || 5
|
39
39
|
AppProfiler.profile_file_prefix = app.config.app_profiler.profile_file_prefix || DefaultProfilePrefix
|
40
|
+
AppProfiler.profile_enqueue_success = app.config.app_profiler.profile_enqueue_success
|
41
|
+
AppProfiler.profile_enqueue_failure = app.config.app_profiler.profile_enqueue_failure
|
42
|
+
AppProfiler.after_process_queue = app.config.app_profiler.after_process_queue
|
40
43
|
end
|
41
44
|
|
42
45
|
initializer "app_profiler.add_middleware" do |app|
|
@@ -60,7 +63,7 @@ module AppProfiler
|
|
60
63
|
private
|
61
64
|
|
62
65
|
def default_middleware_action
|
63
|
-
if Rails.env.development?
|
66
|
+
if Rails.env.development? || Rails.env.test?
|
64
67
|
Middleware::ViewAction
|
65
68
|
else
|
66
69
|
Middleware::UploadAction
|
@@ -37,8 +37,10 @@ module AppProfiler
|
|
37
37
|
@queue ||= init_queue
|
38
38
|
begin
|
39
39
|
@queue.push(profile, true) # non-blocking push, raises ThreadError if queue is full
|
40
|
+
AppProfiler.profile_enqueue_success&.call
|
40
41
|
rescue ThreadError
|
41
42
|
AppProfiler.logger.info("[AppProfiler] upload queue is full, profile discarded")
|
43
|
+
AppProfiler.profile_enqueue_failure&.call(profile)
|
42
44
|
end
|
43
45
|
end
|
44
46
|
end
|
@@ -80,7 +82,12 @@ module AppProfiler
|
|
80
82
|
|
81
83
|
return unless queue
|
82
84
|
|
83
|
-
|
85
|
+
num_success = 0
|
86
|
+
num_failures = 0
|
87
|
+
queue.size.times do
|
88
|
+
queue.pop(false).upload ? num_success += 1 : num_failures += 1
|
89
|
+
end
|
90
|
+
AppProfiler.after_process_queue&.call(num_success, num_failures)
|
84
91
|
end
|
85
92
|
|
86
93
|
def gcs_filename(profile)
|
data/lib/app_profiler/version.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
gem "rails-html-sanitizer", ">= 1.6.0"
|
3
4
|
require "rails-html-sanitizer"
|
4
5
|
|
5
6
|
module AppProfiler
|
6
7
|
module Viewer
|
7
8
|
class SpeedscopeRemoteViewer < BaseViewer
|
8
9
|
class BaseMiddleware
|
9
|
-
class Sanitizer < Rails::
|
10
|
+
class Sanitizer < Rails::HTML::Sanitizer.best_supported_vendor.safe_list_sanitizer
|
10
11
|
self.allowed_tags = Set.new([
|
11
12
|
"strong", "em", "b", "i", "p", "code", "pre", "tt", "samp", "kbd", "var", "sub",
|
12
13
|
"sup", "dfn", "cite", "big", "small", "address", "hr", "br", "div", "span", "h1",
|
data/lib/app_profiler.rb
CHANGED
@@ -55,6 +55,9 @@ module AppProfiler
|
|
55
55
|
mattr_accessor :upload_queue_max_length, default: 10
|
56
56
|
mattr_accessor :upload_queue_interval_secs, default: 5
|
57
57
|
mattr_accessor :profile_file_prefix, default: DefaultProfilePrefix
|
58
|
+
mattr_reader :profile_enqueue_success, default: nil
|
59
|
+
mattr_reader :profile_enqueue_failure, default: nil
|
60
|
+
mattr_reader :after_process_queue, default: nil
|
58
61
|
|
59
62
|
class << self
|
60
63
|
def run(*args, &block)
|
@@ -88,6 +91,30 @@ module AppProfiler
|
|
88
91
|
@@profile_url_formatter = block # rubocop:disable Style/ClassVars
|
89
92
|
end
|
90
93
|
|
94
|
+
def profile_enqueue_success=(handler)
|
95
|
+
if handler && (!handler.is_a?(Proc) || (handler.lambda? && handler.arity != 0))
|
96
|
+
raise ArgumentError, "profile_enqueue_success must be proc or a lambda that accepts no argument"
|
97
|
+
end
|
98
|
+
|
99
|
+
@@profile_enqueue_success = handler # rubocop:disable Style/ClassVars
|
100
|
+
end
|
101
|
+
|
102
|
+
def profile_enqueue_failure=(handler)
|
103
|
+
if handler && (!handler.is_a?(Proc) || (handler.lambda? && handler.arity != 1))
|
104
|
+
raise ArgumentError, "profile_enqueue_failure must be a proc or a lambda that accepts one argument"
|
105
|
+
end
|
106
|
+
|
107
|
+
@@profile_enqueue_failure = handler # rubocop:disable Style/ClassVars
|
108
|
+
end
|
109
|
+
|
110
|
+
def after_process_queue=(handler)
|
111
|
+
if handler && (!handler.is_a?(Proc) || (handler.lambda? && handler.arity != 2))
|
112
|
+
raise ArgumentError, "after_process_queue must be a proc or a lambda that accepts two arguments"
|
113
|
+
end
|
114
|
+
|
115
|
+
@@after_process_queue = handler # rubocop:disable Style/ClassVars
|
116
|
+
end
|
117
|
+
|
91
118
|
def profile_url(upload)
|
92
119
|
return unless AppProfiler.profile_url_formatter
|
93
120
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: app_profiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gannon McGibbon
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2023-
|
16
|
+
date: 2023-12-08 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: activesupport
|
@@ -175,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
175
|
- !ruby/object:Gem::Version
|
176
176
|
version: '0'
|
177
177
|
requirements: []
|
178
|
-
rubygems_version: 3.4.
|
178
|
+
rubygems_version: 3.4.22
|
179
179
|
signing_key:
|
180
180
|
specification_version: 4
|
181
181
|
summary: Collect performance profiles for your Rails application.
|