yabeda-http_requests 0.1.2 → 0.2.0

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: 2e88ed961b6fdf5bf867af58791f09cf2181e5eefdea74f85524a227bf76f9df
4
- data.tar.gz: e0894e32de707a0ba65cc29b13f52aa7dd3559dfba4bda8e782761142a32c003
3
+ metadata.gz: 8f5c7fa7bfe5b47c64c40b7fcee8ebd9d35358a0c6f5b6dced6b5ed255282ab7
4
+ data.tar.gz: 2a771d809057200cad55ffd88aa1d0f4183016c316d9c6836d7d6465b9163f5e
5
5
  SHA512:
6
- metadata.gz: 13ca203dbb2e22a66bab57b914cba89619d6e4c67b05acaf5c3b5f85838221701e1277eaab05c0b45277d1fb192c7c4cae32b6f0a7f0d4078d61ed40f46f4095
7
- data.tar.gz: 31c2a0b712ecd8d17b49d7dd7cabd121cdba354e793daecd7b7241734a1ad65dfbf98da4e7dd0dfd064bc5aa9a8c7d3231b71a21f54294479c40ccce9b25e0cc
6
+ metadata.gz: fd615c28e1a2bd5ab02974fc6fd3e69114717d450d02453f2fdeb3748d47125c8c2a2cc2b488cd98afbf0803c6c39df7b3f86461d56273530c8ddccef02142ac
7
+ data.tar.gz: 6a410a70d61d54a26eeb3efa91b69aae96e30e6beccaac3ca14c0d7022c702eeb9ac6db9d43cbb642e3792ffe0a9a32d6051ec264123a2b768c2136bc83e5fe8
@@ -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-http_requests-${{ steps.tag.outputs.version }}.gem > SHA256SUM
42
+ - name: Check version
43
+ run: ls -l yabeda-http_requests-${{ 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-http_requests-${{ steps.tag.outputs.version }}.gem
62
+ asset_name: yabeda-http_requests-${{ 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-http_requests-${{ 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-http_requests-${{ 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
@@ -0,0 +1,38 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6
+ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7
+
8
+ ## 0.2.0 - 2021-01-25
9
+
10
+ ### Fixed
11
+
12
+ - Ruby 3.0 compatibility due to keyword arguments behavior change. [@danmarcab], [#3](https://github.com/yabeda-rb/yabeda-http_requests/pull/3)
13
+ - Sniffer middleware chain execution. [@dreikanter], [#2](https://github.com/yabeda-rb/yabeda-http_requests/pull/2)
14
+
15
+ ### Removed
16
+
17
+ - Support for Ruby 2.3 and 2.4 as they've reached their End of Life and Sniffer supports only 2.5 and newer anyway. [@Envek]
18
+
19
+ ## 0.1.2 - 2020-03-26
20
+
21
+ ### Fixed
22
+
23
+ - Error related to constant search. [@dsalahutdinov]
24
+
25
+ ## 0.1.1 - 2020-03-23
26
+
27
+ ### Fixed
28
+
29
+ - Memory bloat problem due to requests and responses history stored by Sniffer. [@dsalahutdinov]
30
+
31
+ ## 0.1.0 - 2020-03-19
32
+
33
+ Initial release.
34
+
35
+ [@dsalahutdinov]: https://github.com/dsalahutdinov "Dmitry Salahutdinov"
36
+ [@dreikanter]: https://github.com/dreikanter "Alex Musayev"
37
+ [@danmarcab]: https://github.com/danmarcab "Daniel Marín"
38
+ [@Envek]: https://github.com/Envek "Andrey Novikov"
data/README.md CHANGED
@@ -79,6 +79,37 @@ docker-compose run app bundle exec rspec
79
79
 
80
80
  Bug reports and pull requests are welcome on GitHub at https://github.com/yabeda-rb/yabeda-http_requests.
81
81
 
82
+ ### Releasing
83
+
84
+ 1. Bump version number in `lib/yabeda/http_requests/version.rb`
85
+
86
+ 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::VERSION).to_s`
87
+
88
+ 2. Fill `CHANGELOG.md` with missing changes, add header with version and date.
89
+
90
+ 3. Make a commit:
91
+
92
+ ```sh
93
+ git add lib/yabeda/http_requests/version.rb CHANGELOG.md
94
+ version=$(ruby -r ./lib/yabeda/http_requests/version.rb -e "puts Gem::Version.new(Yabeda::HttpRequests::VERSION)")
95
+ git commit --message="${version}: " --edit
96
+ ```
97
+
98
+ 4. Create annotated tag:
99
+
100
+ ```sh
101
+ git tag v${version} --annotate --message="${version}: " --edit --sign
102
+ ```
103
+
104
+ 5. Fill version name into subject line and (optionally) some description (list of changes will be taken from changelog and appended automatically)
105
+
106
+ 6. Push it:
107
+
108
+ ```sh
109
+ git push --follow-tags
110
+ ```
111
+
112
+ 7. GitHub Actions will create a new release, build and push gem into RubyGems! You're done!
82
113
 
83
114
  ## License
84
115
 
@@ -10,15 +10,14 @@ module Yabeda
10
10
  module HttpRequests
11
11
  SNIFFER_STORAGE_SIZE = 0
12
12
 
13
- # rubocop: disable Metrics/BlockLength
13
+ LONG_RUNNING_REQUEST_BUCKETS = [
14
+ 0.5, 1, 2.5, 5, 10, 25, 50, 100, 250, 500, 1000, # standard
15
+ 30_000, 60_000, 120_000, 300_000, 600_000 # slow queries
16
+ ].freeze
17
+
14
18
  Yabeda.configure do
15
19
  group :http
16
20
 
17
- LONG_RUNNING_REQUEST_BUCKETS = [
18
- 0.5, 1, 2.5, 5, 10, 25, 50, 100, 250, 500, 1000, # standard
19
- 30_000, 60_000, 120_000, 300_000, 600_000 # slow queries
20
- ].freeze
21
-
22
21
  counter :request_total,
23
22
  comment: 'A counter of the total number of external HTTP \
24
23
  requests.',
@@ -43,6 +42,5 @@ module Yabeda
43
42
  end
44
43
  end
45
44
  end
46
- # rubocop: enable Metrics/BlockLength
47
45
  end
48
46
  end
@@ -5,14 +5,18 @@ module Yabeda
5
5
  # Middleware for sniffer gem
6
6
  class Sniffer
7
7
  def request(data_item)
8
+ yield
8
9
  Yabeda.http_request_total.increment(
9
- host: data_item.request.host,
10
- port: data_item.request.port,
11
- method: data_item.request.method
10
+ {
11
+ host: data_item.request.host,
12
+ port: data_item.request.port,
13
+ method: data_item.request.method
14
+ }
12
15
  )
13
16
  end
14
17
 
15
18
  def response(data_item)
19
+ yield
16
20
  log_http_response_total(data_item)
17
21
  log_http_response_duration(data_item)
18
22
  end
@@ -21,10 +25,12 @@ module Yabeda
21
25
 
22
26
  def log_http_response_total(data_item)
23
27
  Yabeda.http_response_total.increment(
24
- host: data_item.request.host,
25
- port: data_item.request.port,
26
- method: data_item.request.method,
27
- status: data_item.response.status
28
+ {
29
+ host: data_item.request.host,
30
+ port: data_item.request.port,
31
+ method: data_item.request.method,
32
+ status: data_item.response.status
33
+ }
28
34
  )
29
35
  end
30
36
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yabeda
4
4
  module HttpRequests
5
- VERSION = '0.1.2'
5
+ VERSION = '0.2.0'
6
6
  end
7
7
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = 'Extends Yabeda metrics to collect external calls'
13
13
  spec.homepage = 'https://github.com/yabeda-rb/yabeda-http_requests'
14
14
  spec.license = 'MIT'
15
- spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.5')
16
16
 
17
17
  spec.metadata['homepage_uri'] = spec.homepage
18
18
  spec.metadata['source_code_uri'] = 'https://github.com/yabeda-rb/yabeda-http_requests'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yabeda-http_requests
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Salahutdinov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-26 00:00:00.000000000 Z
11
+ date: 2021-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sniffer
@@ -45,10 +45,12 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - ".github/workflows/build-release.yml"
49
+ - ".github/workflows/test.yml"
48
50
  - ".gitignore"
49
51
  - ".rspec"
50
52
  - ".rubocop.yml"
51
- - ".travis.yml"
53
+ - CHANGELOG.md
52
54
  - Gemfile
53
55
  - LICENSE.txt
54
56
  - README.md
@@ -74,14 +76,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
74
76
  requirements:
75
77
  - - ">="
76
78
  - !ruby/object:Gem::Version
77
- version: 2.3.0
79
+ version: '2.5'
78
80
  required_rubygems_version: !ruby/object:Gem::Requirement
79
81
  requirements:
80
82
  - - ">="
81
83
  - !ruby/object:Gem::Version
82
84
  version: '0'
83
85
  requirements: []
84
- rubygems_version: 3.1.2
86
+ rubygems_version: 3.1.4
85
87
  signing_key:
86
88
  specification_version: 4
87
89
  summary: Monitoring of external services HTTP/HTTPS calls
@@ -1,6 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.7.0
6
- before_install: gem install bundler -v 2.1.2