app_profiler 0.3.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e78035c478029d4ad4de636efab44240957c2bd05ea761dc9fe28b753b4fa1d3
4
- data.tar.gz: c4d6659a31eaa7440c6c8a2550c9cf41fbadb567426cae7c6bd0cd4442e8039a
3
+ metadata.gz: b5ca2ed69abcd8cba935914ee16e8427fa8070fb3b0eecb488b06a027a64667a
4
+ data.tar.gz: fbcd17ddeeabfbbb8fe52c69d8744b0a8c73a9cd54ed6cd248f40e1c1a8f2662
5
5
  SHA512:
6
- metadata.gz: 45610912af0b6952b2c104d27bfc3bf2b37b92f91d2c873bdf9e2bfc43498529decf9568af63b9ee47d84794dd921dbf6312de11aac272be296f99416d5f2b31
7
- data.tar.gz: 29ee1a661cc8c81274fbdb7f6123ce90d7dbeaa351ca3b16a8a6bfe933ec3f68385bfe0f2d0afb2ae6c49ba59fa318d733bd23d6cf7724a3d03f1246e36b65ca
6
+ metadata.gz: f41e6a149770dbffc1f85f3b280ef91cfc3c2ab966f6d9c8ce943c6c46e3ae2a2784b2864d2a8163593c83d0c116af1919598cc0576831423c5ed825a90b0770
7
+ data.tar.gz: d12e52408d4d5aedc048661bc96d35f55f038c1eeaedc01c6ed4b31612298d8203c33e5449d935a677a4ec3b75e0cc4c3cc938ae186a3a29c49d245da8093128
@@ -3,8 +3,27 @@
3
3
  module AppProfiler
4
4
  module Backend
5
5
  class BaseBackend
6
- def run(params = {}, &block)
7
- raise NotImplementedError
6
+ def run(params = {})
7
+ started = start(params)
8
+ start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
9
+
10
+ yield
11
+
12
+ return unless started
13
+
14
+ duration = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start_time
15
+
16
+ stop
17
+ results_data = results
18
+
19
+ if results_data
20
+ results_data.metadata[:duration] = duration
21
+ end
22
+
23
+ results_data
24
+ ensure
25
+ # Only stop the profiler if profiling was started in this context.
26
+ stop if started
8
27
  end
9
28
 
10
29
  def start(params = {})
@@ -22,20 +22,6 @@ module AppProfiler
22
22
  end
23
23
  end
24
24
 
25
- def run(params = {})
26
- started = start(params)
27
-
28
- yield
29
-
30
- return unless started
31
-
32
- stop
33
- results
34
- ensure
35
- # Only stop the profiler if profiling was started in this context.
36
- stop if started
37
- end
38
-
39
25
  def start(params = {})
40
26
  # Do not start the profiler if StackProf was started somewhere else.
41
27
  return false if running?
@@ -21,20 +21,6 @@ module AppProfiler
21
21
  end
22
22
  end
23
23
 
24
- def run(params = {})
25
- started = start(params)
26
-
27
- yield
28
-
29
- return unless started
30
-
31
- stop
32
- results
33
- ensure
34
- # Only stop the profiler if profiling was started in this context.
35
- stop if started
36
- end
37
-
38
24
  def start(params = {})
39
25
  # Do not start the profiler if we already have a collector started somewhere else.
40
26
  return false if running?
@@ -47,6 +47,10 @@ module AppProfiler
47
47
  metadata[PROFILE_ID_METADATA_KEY]
48
48
  end
49
49
 
50
+ def duration
51
+ metadata[:duration]
52
+ end
53
+
50
54
  def upload
51
55
  AppProfiler.storage.upload(self).tap do |upload|
52
56
  if upload && defined?(upload.url)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AppProfiler
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
data/lib/app_profiler.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require "active_support"
4
4
  require "active_support/core_ext/class"
5
5
  require "active_support/core_ext/module"
6
+ require "active_support/core_ext/time/zones"
6
7
  require "logger"
7
8
  require "app_profiler/version"
8
9
 
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.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gannon McGibbon
@@ -12,7 +12,7 @@ authors:
12
12
  - Scott Francis
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2025-02-24 00:00:00.000000000 Z
15
+ date: 2025-04-10 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activesupport
@@ -201,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
201
  - !ruby/object:Gem::Version
202
202
  version: '0'
203
203
  requirements: []
204
- rubygems_version: 3.6.3
204
+ rubygems_version: 3.6.6
205
205
  specification_version: 4
206
206
  summary: Collect performance profiles for your Rails application.
207
207
  test_files: []