activerecord-connection_pool_instrumenter 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: cd5d23f327f81d5a1f2cae36bc88b7a65c86816e792d0405f4ce36f2fd3427ef
4
+ data.tar.gz: 8f9d3356d36c370a54c753358dba6379d9780c2ed42f18460b20944ac8042449
5
+ SHA512:
6
+ metadata.gz: 3d5ad9fb65cec3e256af887ccda58d95d4b6db3e97b1f06a535a44be522d6fd41f6d1d75f4ec399eaff5d2ec4643e75862419c688ea1a13ccda4944bd898c137
7
+ data.tar.gz: 278b9044823659f706b591f03611263ac139f2fd1934af00dc585dcaa142049a6404fa0c6e62272f0f08bee3dbcd093ac4e4d7ea02177436294e9bbbe7eadae5
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in activerecord-connection_pool_instrumenter.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
@@ -0,0 +1,29 @@
1
+ # Activerecord::ConnectionPoolInstrumenter
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'activerecord-connection_pool_instrumenter'
9
+ ```
10
+
11
+ And then execute `bundle install`
12
+
13
+ ## Usage
14
+
15
+ Include in your application:
16
+
17
+ ```
18
+ require 'activerecord/connection_pool_instrumenter'
19
+ Activerecord::ConnectionPoolInstrumenter.instrument(statsd: statsd, prefix: 'your_app.db.connection_pool')
20
+ ```
21
+
22
+ ## Development
23
+
24
+ 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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
25
+
26
+ ## Contributing
27
+
28
+ Bug reports and pull requests are welcome on GitHub at https://github.com/salemove/activerecord-connection_pool_instrumenter.
29
+
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/activerecord/connection_pool_instrumenter/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'activerecord-connection_pool_instrumenter'
7
+ spec.version = Activerecord::ConnectionPoolInstrumenter::VERSION
8
+ spec.authors = ['Glia TechMovers']
9
+ spec.email = ['techmovers@glia.com']
10
+ spec.summary = 'Metrics about the activerecord connection pool usage'
11
+ spec.homepage = 'https://github.com/salemove/activerecord-connection_pool_instrumenter'
12
+
13
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
14
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
15
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
+ spec.require_paths = ['lib']
17
+
18
+ spec.add_dependency 'concurrent-ruby', '~> 1.1'
19
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'activerecord/connection_pool_instrumenter/version'
4
+
5
+ module Activerecord
6
+ module ConnectionPoolInstrumenter
7
+ def self.instrument(
8
+ statsd:,
9
+ connection_pool: ActiveRecord::Base.connection_pool,
10
+ prefix: 'db.connection_pool',
11
+ execution_interval: 1.second,
12
+ execution_timeout: 1.second
13
+ )
14
+ Concurrent::TimerTask.execute(
15
+ execution_interval: execution_interval,
16
+ timeout_interval: execution_timeout
17
+ ) do
18
+ # ActiveRecord::Base.connection_pool.stat returns
19
+ # { size: 15, connections: 1, busy: 1, dead: 0, idle: 0, waiting: 0, checkout_timeout: 5 }
20
+ connection_pool.stat.each_pair do |metric, value|
21
+ statsd.gauge([prefix, metric].join('.'), value)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Activerecord
4
+ module ConnectionPoolInstrumenter
5
+ VERSION = '0.1.0'
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activerecord-connection_pool_instrumenter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Glia TechMovers
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-06-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: concurrent-ruby
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.1'
27
+ description:
28
+ email:
29
+ - techmovers@glia.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - Gemfile
36
+ - README.md
37
+ - Rakefile
38
+ - activerecord-connection_pool_instrumenter.gemspec
39
+ - lib/activerecord/connection_pool_instrumenter.rb
40
+ - lib/activerecord/connection_pool_instrumenter/version.rb
41
+ homepage: https://github.com/salemove/activerecord-connection_pool_instrumenter
42
+ licenses: []
43
+ metadata: {}
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubygems_version: 3.0.3
60
+ signing_key:
61
+ specification_version: 4
62
+ summary: Metrics about the activerecord connection pool usage
63
+ test_files: []