yabeda-rails 0.7.1 → 0.7.2

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: 7c4f9d9b4773c74b1ec6227a70b8799f817ce4d5e053b368e6136fb82a51df4f
4
- data.tar.gz: 9353bc44438ce046037fb9a459fbd95395a56e01349fa3fba4c35deaac02a262
3
+ metadata.gz: e5a74f3febe6bcdda7d43527a9b9acb71434e58f2abc5518b2a68c609541bf89
4
+ data.tar.gz: f223f9a5df2d1a224e77cec0a9e09357eaeccf0532f5a6c4b8859c82ed4ab909
5
5
  SHA512:
6
- metadata.gz: be508869519495bf6ed889ab9fcd2285299d8d791e32d77835c0e3a073be5351055c24f831bca665a9683f76c9036969cb58021afe0ac530e1a1268309f6240f
7
- data.tar.gz: cada1bfb298d4a29322375d16719c1d52c95944b42434260be1cca6a8b6d4c7db2bb73e95a9e49118188ba6f1a58d0701806be6e63b0de5aec350ece877f2ce8
6
+ metadata.gz: 8d2cf3ed506addf2aabcd6bebeaf77fdc80d29ea091a2f8f4d9ef550e3bc74e33a9a4faad6e82ec3ea7f280311a80860f985a6f971fcaa1847b86e7d5907bc95
7
+ data.tar.gz: de1ebbcfbfc3e9423a9033b1080426dd0466e665a9485dd13bc5df4bc60b982c049f156ec8499b38cbca3e26a0ffec2dba571b7f252ee7e7daf299e1ff81070c
@@ -0,0 +1,82 @@
1
+ name: Build and release gem to RubyGems
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - v*
7
+
8
+ jobs:
9
+ release:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+ with:
14
+ fetch-depth: 0 # Fetch current tag as annotated. See https://github.com/actions/checkout/issues/290
15
+ - uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: 2.7
18
+ - name: "Extract data from tag: version, message, body"
19
+ id: tag
20
+ run: |
21
+ git fetch --tags --force # Really fetch annotated tag. See https://github.com/actions/checkout/issues/290#issuecomment-680260080
22
+ echo ::set-output name=version::${GITHUB_REF#refs/tags/v}
23
+ echo ::set-output name=subject::$(git for-each-ref $GITHUB_REF --format='%(contents:subject)')
24
+ BODY="$(git for-each-ref $GITHUB_REF --format='%(contents:body)')"
25
+ # Extract changelog entries between this and previous version headers
26
+ escaped_version=$(echo ${GITHUB_REF#refs/tags/v} | sed -e 's/[]\/$*.^[]/\\&/g')
27
+ changelog=$(awk "BEGIN{inrelease=0} /## ${escaped_version}/{inrelease=1;next} /## [0-9]+\.[0-9]+\.[0-9]+/{inrelease=0;exit} {if (inrelease) print}" CHANGELOG.md)
28
+ # Multiline body for release. See https://github.community/t/set-output-truncates-multiline-strings/16852/5
29
+ BODY="${BODY}"$'\n'"${changelog}"
30
+ BODY="${BODY//'%'/'%25'}"
31
+ BODY="${BODY//$'\n'/'%0A'}"
32
+ BODY="${BODY//$'\r'/'%0D'}"
33
+ echo "::set-output name=body::$BODY"
34
+ # Add pre-release option if tag name has any suffix after vMAJOR.MINOR.PATCH
35
+ if [[ ${GITHUB_REF#refs/tags/} =~ ^v[0-9]+\.[0-9]+\.[0-9]+.+ ]]; then
36
+ echo ::set-output name=prerelease::true
37
+ fi
38
+ - name: Build gem
39
+ run: gem build
40
+ - name: Calculate checksums
41
+ run: sha256sum yabeda-rails-${{ steps.tag.outputs.version }}.gem > SHA256SUM
42
+ - name: Check version
43
+ run: ls -l yabeda-rails-${{ steps.tag.outputs.version }}.gem
44
+ - name: Create Release
45
+ id: create_release
46
+ uses: actions/create-release@v1
47
+ env:
48
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49
+ with:
50
+ tag_name: ${{ github.ref }}
51
+ release_name: ${{ steps.tag.outputs.subject }}
52
+ body: ${{ steps.tag.outputs.body }}
53
+ draft: false
54
+ prerelease: ${{ steps.tag.outputs.prerelease }}
55
+ - name: Upload built gem as release asset
56
+ uses: actions/upload-release-asset@v1
57
+ env:
58
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59
+ with:
60
+ upload_url: ${{ steps.create_release.outputs.upload_url }}
61
+ asset_path: yabeda-rails-${{ steps.tag.outputs.version }}.gem
62
+ asset_name: yabeda-rails-${{ steps.tag.outputs.version }}.gem
63
+ asset_content_type: application/x-tar
64
+ - name: Upload checksums as release asset
65
+ uses: actions/upload-release-asset@v1
66
+ env:
67
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68
+ with:
69
+ upload_url: ${{ steps.create_release.outputs.upload_url }}
70
+ asset_path: SHA256SUM
71
+ asset_name: SHA256SUM
72
+ asset_content_type: text/plain
73
+ - name: Publish to GitHub packages
74
+ env:
75
+ GEM_HOST_API_KEY: Bearer ${{ secrets.GITHUB_TOKEN }}
76
+ run: |
77
+ gem push yabeda-rails-${{ steps.tag.outputs.version }}.gem --host https://rubygems.pkg.github.com/${{ github.repository_owner }}
78
+ - name: Publish to RubyGems
79
+ env:
80
+ GEM_HOST_API_KEY: "${{ secrets.RUBYGEMS_API_KEY }}"
81
+ run: |
82
+ gem push yabeda-rails-${{ steps.tag.outputs.version }}.gem
@@ -0,0 +1,47 @@
1
+ name: Run tests
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches:
7
+ - '**'
8
+ tags-ignore:
9
+ - 'v*'
10
+
11
+ jobs:
12
+ test:
13
+ name: "Run tests"
14
+ if: "! contains(toJSON(github.event.commits.latest.message), '[ci skip]')"
15
+ runs-on: ubuntu-latest
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ include:
20
+ - ruby: 3.0
21
+ - ruby: 2.7
22
+ - ruby: 2.6
23
+ - ruby: 2.5
24
+ container:
25
+ image: ruby:${{ matrix.ruby }}
26
+ env:
27
+ CI: true
28
+ steps:
29
+ - uses: actions/checkout@v2
30
+ - uses: actions/cache@v2
31
+ with:
32
+ path: vendor/bundle
33
+ key: bundle-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}-${{ hashFiles('**/Gemfile') }}
34
+ restore-keys: |
35
+ bundle-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}-${{ hashFiles('**/Gemfile') }}
36
+ bundle-${{ matrix.ruby }}-
37
+ - name: Upgrade Bundler to 2.0 (for older Rubies)
38
+ run: gem install bundler -v '~> 2.0'
39
+ - name: Bundle install
40
+ run: |
41
+ bundle config path vendor/bundle
42
+ bundle install
43
+ bundle update
44
+ - name: Run Rubocop
45
+ run: bundle exec rubocop
46
+ - name: Run RSpec
47
+ run: bundle exec rspec
data/.rubocop.yml CHANGED
@@ -3,16 +3,13 @@ require:
3
3
  - rubocop-rspec
4
4
 
5
5
  AllCops:
6
- TargetRubyVersion: 2.3
6
+ TargetRubyVersion: 2.4
7
7
 
8
8
  Metrics/BlockLength:
9
9
  Exclude:
10
10
  - "Gemfile"
11
11
  - "spec/**/*"
12
12
 
13
- Style/BracesAroundHashParameters:
14
- EnforcedStyle: context_dependent
15
-
16
13
  Style/StringLiterals:
17
14
  EnforcedStyle: double_quotes
18
15
 
data/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## 0.7.2 - 2021-03-15
9
+
10
+ ### Fixed
11
+
12
+ - Fix undesirable overwrite of metric tags when global `default_tag` is declared with one of tag names that are being used by yabeda-rails, like `controller`. [@liaden] in [#19](https://github.com/yabeda-rb/yabeda-rails/pull/19)
13
+
8
14
  ## 0.7.1 - 2020-10-02
9
15
 
10
16
  ### Changed
@@ -58,3 +64,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
58
64
  - Initial release of evil-metrics-rails gem. @Envek
59
65
 
60
66
  Basic metrics for request durations by controller, action, status, format, and method. ActiveRecord and ActionView timings.
67
+
68
+ [@liaden]: https://github.com/liaden "Joel Johnson"
data/Gemfile CHANGED
@@ -11,6 +11,6 @@ group :development, :test do
11
11
  gem "pry"
12
12
  gem "pry-byebug", platform: :mri
13
13
 
14
- gem "rubocop"
14
+ gem "rubocop", "~> 1.8"
15
15
  gem "rubocop-rspec"
16
16
  end
data/README.md CHANGED
@@ -83,6 +83,38 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
83
83
 
84
84
  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).
85
85
 
86
+ ### Releasing
87
+
88
+ 1. Bump version number in `lib/yabeda/rails/version.rb`
89
+
90
+ In case of pre-releases keep in mind [rubygems/rubygems#3086](https://github.com/rubygems/rubygems/issues/3086) and check version with command like `Gem::Version.new(Yabeda::Rails::VERSION).to_s`
91
+
92
+ 2. Fill `CHANGELOG.md` with missing changes, add header with version and date.
93
+
94
+ 3. Make a commit:
95
+
96
+ ```sh
97
+ git add lib/yabeda/rails/version.rb CHANGELOG.md
98
+ version=$(ruby -r ./lib/yabeda/rails/version.rb -e "puts Gem::Version.new(Yabeda::Rails::VERSION)")
99
+ git commit --message="${version}: " --edit
100
+ ```
101
+
102
+ 4. Create annotated tag:
103
+
104
+ ```sh
105
+ git tag v${version} --annotate --message="${version}: " --edit --sign
106
+ ```
107
+
108
+ 5. Fill version name into subject line and (optionally) some description (list of changes will be taken from changelog and appended automatically)
109
+
110
+ 6. Push it:
111
+
112
+ ```sh
113
+ git push --follow-tags
114
+ ```
115
+
116
+ 7. You're done!
117
+
86
118
  ## Contributing
87
119
 
88
120
  Bug reports and pull requests are welcome on GitHub at https://github.com/yabeda-rb/yabeda-rails.
data/lib/yabeda/rails.rb CHANGED
@@ -1,9 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "yabeda"
4
+ require "rails"
4
5
  require "yabeda/rails/railtie"
5
6
 
6
7
  module Yabeda
8
+ # Minimal set of Rails-specific metrics for using with Yabeda
7
9
  module Rails
8
10
  LONG_RUNNING_REQUEST_BUCKETS = [
9
11
  0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, # standard
@@ -19,6 +21,8 @@ module Yabeda
19
21
  controller_handlers << block
20
22
  end
21
23
 
24
+ # Declare metrics and install event handlers for collecting themya
25
+ # rubocop: disable Metrics/MethodLength, Metrics/BlockLength, Metrics/AbcSize
22
26
  def install!
23
27
  Yabeda.configure do
24
28
  group :rails
@@ -47,7 +51,8 @@ module Yabeda
47
51
  status: event.payload[:status],
48
52
  format: event.payload[:format],
49
53
  method: event.payload[:method].downcase,
50
- }.merge!(event.payload.slice(*Yabeda.default_tags.keys))
54
+ }
55
+ labels.merge!(event.payload.slice(*Yabeda.default_tags.keys - labels.keys))
51
56
 
52
57
  rails_requests_total.increment(labels)
53
58
  rails_request_duration.measure(labels, Yabeda::Rails.ms2s(event.duration))
@@ -60,9 +65,10 @@ module Yabeda
60
65
  end
61
66
  end
62
67
  end
68
+ # rubocop: enable Metrics/MethodLength, Metrics/BlockLength, Metrics/AbcSize
63
69
 
64
- def ms2s(ms)
65
- (ms.to_f / 1000).round(3)
70
+ def ms2s(milliseconds)
71
+ (milliseconds.to_f / 1000).round(3)
66
72
  end
67
73
  end
68
74
  end
@@ -12,7 +12,7 @@ module Yabeda
12
12
  end
13
13
 
14
14
  def puma_server?
15
- ::Rails.const_defined?('Puma::CLI')
15
+ ::Rails.const_defined?("Puma::CLI")
16
16
  end
17
17
 
18
18
  def unicorn_server?
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yabeda
4
4
  module Rails
5
- VERSION = "0.7.1"
5
+ VERSION = "0.7.2"
6
6
  end
7
7
  end
data/yabeda-rails.gemspec CHANGED
@@ -22,8 +22,10 @@ Gem::Specification.new do |spec|
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ["lib"]
24
24
 
25
- spec.add_dependency "yabeda", "~> 0.8"
25
+ spec.required_ruby_version = ">= 2.4"
26
+
26
27
  spec.add_dependency "rails"
28
+ spec.add_dependency "yabeda", "~> 0.8"
27
29
 
28
30
  spec.add_development_dependency "bundler", "~> 2.0"
29
31
  spec.add_development_dependency "rake", "~> 13.0"
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yabeda-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Novikov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-02 00:00:00.000000000 Z
11
+ date: 2021-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: yabeda
14
+ name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0.8'
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0.8'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rails
28
+ name: yabeda
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '0.8'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '0.8'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -87,10 +87,11 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
+ - ".github/workflows/build-release.yml"
91
+ - ".github/workflows/test.yml"
90
92
  - ".gitignore"
91
93
  - ".rspec"
92
94
  - ".rubocop.yml"
93
- - ".travis.yml"
94
95
  - CHANGELOG.md
95
96
  - Gemfile
96
97
  - LICENSE.txt
@@ -114,14 +115,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
114
115
  requirements:
115
116
  - - ">="
116
117
  - !ruby/object:Gem::Version
117
- version: '0'
118
+ version: '2.4'
118
119
  required_rubygems_version: !ruby/object:Gem::Requirement
119
120
  requirements:
120
121
  - - ">="
121
122
  - !ruby/object:Gem::Version
122
123
  version: '0'
123
124
  requirements: []
124
- rubygems_version: 3.1.2
125
+ rubygems_version: 3.1.4
125
126
  signing_key:
126
127
  specification_version: 4
127
128
  summary: Extensible metrics for monitoring Ruby on Rails application
data/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.7.1
5
- before_install: gem install bundler -v 2.0