newrelic_gvl 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9d7d3d1e3a1f33185ab589571adb3ede1294c9e927de0da447161d8a5950a617
4
+ data.tar.gz: 746c08559b04aa4f8cf1cefffca2fc5df63413530606e7f48523651aa77fb959
5
+ SHA512:
6
+ metadata.gz: bb3cf946338066a9f918fe48e919c9e0eecac63f429618468b28c649ecfef33bb170a5e72752321f56431c7e3a9d4be99f12d8c958cf439179ae00cb0c131767
7
+ data.tar.gz: 8aed237b54ee3ec2dfee686b491c9f864933c1e0405480c04b2fb69bcbfe485875f30a61da4c04c2c508a6e510e06267301d41b17bdee4e8fb4b247290348473
data/.standard.yml ADDED
@@ -0,0 +1,3 @@
1
+ # For available configuration options, see:
2
+ # https://github.com/testdouble/standard
3
+ ruby_version: 2.6
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-02-02
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in newrelic_gvl.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "minitest"
11
+ gem "standard", "~> 1.3"
12
+
13
+ gem "mocha", "~> 2.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,60 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ newrelic_gvl (0.1.0)
5
+ gvltools (> 0)
6
+ newrelic_rpm (> 0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.4.2)
12
+ gvltools (0.1.0)
13
+ json (2.6.3)
14
+ language_server-protocol (3.17.0.3)
15
+ minitest (5.17.0)
16
+ mocha (2.0.2)
17
+ ruby2_keywords (>= 0.0.5)
18
+ newrelic_rpm (8.15.0)
19
+ parallel (1.22.1)
20
+ parser (3.2.0.0)
21
+ ast (~> 2.4.1)
22
+ rainbow (3.1.1)
23
+ rake (13.0.6)
24
+ regexp_parser (2.6.2)
25
+ rexml (3.2.5)
26
+ rubocop (1.42.0)
27
+ json (~> 2.3)
28
+ parallel (~> 1.10)
29
+ parser (>= 3.1.2.1)
30
+ rainbow (>= 2.2.2, < 4.0)
31
+ regexp_parser (>= 1.8, < 3.0)
32
+ rexml (>= 3.2.5, < 4.0)
33
+ rubocop-ast (>= 1.24.1, < 2.0)
34
+ ruby-progressbar (~> 1.7)
35
+ unicode-display_width (>= 1.4.0, < 3.0)
36
+ rubocop-ast (1.24.1)
37
+ parser (>= 3.1.1.0)
38
+ rubocop-performance (1.15.2)
39
+ rubocop (>= 1.7.0, < 2.0)
40
+ rubocop-ast (>= 0.4.0)
41
+ ruby-progressbar (1.11.0)
42
+ ruby2_keywords (0.0.5)
43
+ standard (1.22.1)
44
+ language_server-protocol (~> 3.17.0.2)
45
+ rubocop (= 1.42.0)
46
+ rubocop-performance (= 1.15.2)
47
+ unicode-display_width (2.4.2)
48
+
49
+ PLATFORMS
50
+ x86_64-darwin-21
51
+
52
+ DEPENDENCIES
53
+ minitest
54
+ mocha (~> 2.0)
55
+ newrelic_gvl!
56
+ rake (~> 13.0)
57
+ standard (~> 1.3)
58
+
59
+ BUNDLED WITH
60
+ 2.3.15
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # NewRelic GVL Stats
2
+
3
+ Ruby 3.2.0 allows for tracking of GVL status. This gem utilizes that API via [gvltools](https://github.com/Shopify/gvltools) to report GVL status for Sidekiq jobs and Rack requests.
4
+
5
+ ## Installation
6
+
7
+ Install the gem and add to the application's Gemfile by executing:
8
+
9
+ $ bundle add newrelic_gvl
10
+
11
+ If bundler is not being used to manage dependencies, install the gem by executing:
12
+
13
+ $ gem install newrelic_gvl
14
+
15
+ ## Usage
16
+
17
+ For rails:
18
+
19
+ ```
20
+ config.middleware.use NewrelicGvl::Rack::Middleware
21
+ ```
22
+
23
+ For sidekiq:
24
+
25
+ ```
26
+ Sidekiq.configure_server do |config|
27
+ config.server_middleware do |chain|
28
+ chain.add NewrelicGvl::Sidekiq::Middleware
29
+ end
30
+ end
31
+ ```
32
+
33
+ ## Development
34
+
35
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
36
+
37
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
38
+
39
+ ## Contributing
40
+
41
+ Bug reports and pull requests are welcome on GitHub at https://github.com/gstark/newrelic_gvl.
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "minitest/test_task"
5
+ require "standard/rake"
6
+
7
+ Minitest::TestTask.create(:test) do |t|
8
+ t.libs << "test"
9
+ t.libs << "lib"
10
+ t.warning = false
11
+ t.test_globs = FileList["test/test_helper.rb", "test/**/*_spec.rb"]
12
+ end
13
+
14
+ task default: :test
@@ -0,0 +1,20 @@
1
+ require "gvltools"
2
+
3
+ module NewrelicGvl
4
+ module Rack
5
+ class Middleware
6
+ def initialize(app)
7
+ @app = app
8
+ end
9
+
10
+ def call(env)
11
+ before = GVLTools::LocalTimer.monotonic_time
12
+ @app.call(env).tap do |response|
13
+ wait_in_ms = (GVLTools::LocalTimer.monotonic_time - before) / 1_000_000.0
14
+
15
+ NewRelic::Agent.add_custom_attributes({gvl_wait: wait_in_ms})
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,19 @@
1
+ require "gvltools"
2
+
3
+ module NewrelicGvl
4
+ module Sidekiq
5
+ class Middleware
6
+ include Sidekiq::ClientMiddleware if defined?(Sidekiq::ClientMiddleware)
7
+
8
+ def call(_worker, _job, _queue, _redis_pool)
9
+ before = GVLTools::LocalTimer.monotonic_time
10
+
11
+ yield
12
+ ensure
13
+ wait_in_ms = (GVLTools::LocalTimer.monotonic_time - before) / 1_000_000.0
14
+
15
+ NewRelic::Agent.add_custom_attributes({gvl_wait: wait_in_ms})
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NewrelicGvl
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NewrelicGvl
4
+ class Error < StandardError; end
5
+ end
6
+
7
+ require_relative "newrelic_gvl/version"
8
+ require_relative "newrelic_gvl/sidekiq/middleware"
9
+ require_relative "newrelic_gvl/rack/middleware"
@@ -0,0 +1,4 @@
1
+ module NewrelicGvl
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: newrelic_gvl
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Gavin Stark
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-02-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gvltools
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: newrelic_rpm
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: NewRelic middleware that measures time spent waiting on the GVL
42
+ email:
43
+ - gavin@gstark.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".standard.yml"
49
+ - CHANGELOG.md
50
+ - Gemfile
51
+ - Gemfile.lock
52
+ - README.md
53
+ - Rakefile
54
+ - lib/newrelic_gvl.rb
55
+ - lib/newrelic_gvl/rack/middleware.rb
56
+ - lib/newrelic_gvl/sidekiq/middleware.rb
57
+ - lib/newrelic_gvl/version.rb
58
+ - sig/newrelic_gvl.rbs
59
+ homepage: https://github.com/gstark/newrelic_gvl
60
+ licenses: []
61
+ metadata:
62
+ homepage_uri: https://github.com/gstark/newrelic_gvl
63
+ source_code_uri: https://github.com/gstark/newrelic_gvl
64
+ changelog_uri: https://github.com/gstark/newrelic_gvl/blob/main/CHANGELOG.md
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: 2.6.0
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubygems_version: 3.0.3
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: NewRelic middleware that measures time spent waiting on the GVL
84
+ test_files: []