yabeda-http_requests 0.1.2 → 0.2.1

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: b448798fe4c35a8a1952304f7bce322c779328698d46b3597e89bbc7e43c481e
4
+ data.tar.gz: 5a085a5d9bbe072b341dabe8b200d7aa168b1dff6223ecd5b61ab3c25113b59b
5
5
  SHA512:
6
- metadata.gz: 13ca203dbb2e22a66bab57b914cba89619d6e4c67b05acaf5c3b5f85838221701e1277eaab05c0b45277d1fb192c7c4cae32b6f0a7f0d4078d61ed40f46f4095
7
- data.tar.gz: 31c2a0b712ecd8d17b49d7dd7cabd121cdba354e793daecd7b7241734a1ad65dfbf98da4e7dd0dfd064bc5aa9a8c7d3231b71a21f54294479c40ccce9b25e0cc
6
+ metadata.gz: '08d94abf93699961c896aac0cec81eb0d2f50f76c13526a2b487e5c7835215c0deeceff78310d01df264a0b5279a63394a41bf8ca693c057d6c8956ea25f1370'
7
+ data.tar.gz: 7eb31a2e55f855b9bfce5fb3ebdec49564cbfd661aaf94d2e6a261e9c19fc0847009aa21730f69b5ffc9bcd946e7aa492f1283797c5781dafc45681eab183198
@@ -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,33 @@
1
+ name: Lint
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ paths:
8
+ - "gemfiles/*"
9
+ - "Gemfile"
10
+ - "**/*.rb"
11
+ - "**/*.gemspec"
12
+ - ".github/workflows/lint.yml"
13
+ pull_request:
14
+ paths:
15
+ - "gemfiles/*"
16
+ - "Gemfile"
17
+ - "**/*.rb"
18
+ - "**/*.gemspec"
19
+ - ".github/workflows/lint.yml"
20
+
21
+ jobs:
22
+ rubocop:
23
+ name: "RuboCop"
24
+ runs-on: ubuntu-latest
25
+ steps:
26
+ - uses: actions/checkout@v3
27
+ - uses: ruby/setup-ruby@v1
28
+ with:
29
+ ruby-version: 3.2
30
+ bundler-cache: true
31
+ - name: Lint Ruby code with RuboCop
32
+ run: |
33
+ bundle exec rubocop
@@ -0,0 +1,32 @@
1
+ name: Tests
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches:
7
+ - '**'
8
+ tags-ignore:
9
+ - 'v*'
10
+
11
+ jobs:
12
+ test:
13
+ # Skip running tests for local pull requests (use push event instead), run only for foreign ones
14
+ if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login != github.event.pull_request.base.repo.owner.login
15
+ name: 'Ruby ${{ matrix.ruby }}'
16
+ runs-on: ubuntu-latest
17
+ strategy:
18
+ fail-fast: false
19
+ matrix:
20
+ ruby:
21
+ - '2.7'
22
+ - '3.0'
23
+ - '3.1'
24
+ - '3.2'
25
+ steps:
26
+ - uses: actions/checkout@v3
27
+ - uses: ruby/setup-ruby@v1
28
+ with:
29
+ ruby-version: ${{ matrix.ruby }}
30
+ bundler-cache: true
31
+ - name: Run RSpec
32
+ run: bundle exec rspec
data/.rubocop.yml CHANGED
@@ -1,3 +1,6 @@
1
+ AllCops:
2
+ TargetRubyVersion: "2.5"
3
+
1
4
  Style/Documentation:
2
5
  Exclude:
3
6
  - 'example/**/*'
data/CHANGELOG.md ADDED
@@ -0,0 +1,45 @@
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.1 - 2023-12-14
9
+
10
+ ### Fixed
11
+
12
+ - Ensure http method is always uppercase. [@webmat], [#6](https://github.com/yabeda-rb/yabeda-http_requests/pull/6)
13
+
14
+ ## 0.2.0 - 2021-01-25
15
+
16
+ ### Fixed
17
+
18
+ - Ruby 3.0 compatibility due to keyword arguments behavior change. [@danmarcab], [#3](https://github.com/yabeda-rb/yabeda-http_requests/pull/3)
19
+ - Sniffer middleware chain execution. [@dreikanter], [#2](https://github.com/yabeda-rb/yabeda-http_requests/pull/2)
20
+
21
+ ### Removed
22
+
23
+ - 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]
24
+
25
+ ## 0.1.2 - 2020-03-26
26
+
27
+ ### Fixed
28
+
29
+ - Error related to constant search. [@dsalahutdinov]
30
+
31
+ ## 0.1.1 - 2020-03-23
32
+
33
+ ### Fixed
34
+
35
+ - Memory bloat problem due to requests and responses history stored by Sniffer. [@dsalahutdinov]
36
+
37
+ ## 0.1.0 - 2020-03-19
38
+
39
+ Initial release.
40
+
41
+ [@dsalahutdinov]: https://github.com/dsalahutdinov "Dmitry Salahutdinov"
42
+ [@dreikanter]: https://github.com/dreikanter "Alex Musayev"
43
+ [@danmarcab]: https://github.com/danmarcab "Daniel Marín"
44
+ [@Envek]: https://github.com/Envek "Andrey Novikov"
45
+ [@webmat]: https://github.com/webmat "Mathieu Martin"
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  alt="Sponsored by Amplifr" src="https://amplifr-direct.s3-eu-west-1.amazonaws.com/social_images/image/37b580d9-3668-4005-8d5a-137de3a3e77c.png" />
4
4
  </a>
5
5
 
6
- # Yabeda::HttpRequests
6
+ # ![Yabeda::HttpRequests](./yabeda-http_requests-logo.png)
7
7
 
8
8
  Built-in metrics for external services HTTP calls! This gem is a Part of the [yabeda](https://github.com/yabeda-rb/yabeda) suite.
9
9
 
@@ -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
 
@@ -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.upcase
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.upcase,
32
+ status: data_item.response.status
33
+ }
28
34
  )
29
35
  end
30
36
 
@@ -32,7 +38,7 @@ module Yabeda
32
38
  labels = {
33
39
  host: data_item.request.host,
34
40
  port: data_item.request.port,
35
- method: data_item.request.method,
41
+ method: data_item.request.method.upcase,
36
42
  status: data_item.response.status
37
43
  }
38
44
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yabeda
4
4
  module HttpRequests
5
- VERSION = '0.1.2'
5
+ VERSION = '0.2.1'
6
6
  end
7
7
  end
@@ -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
Binary file
@@ -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.1
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: 2023-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sniffer
@@ -45,10 +45,13 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - ".github/workflows/build-release.yml"
49
+ - ".github/workflows/lint.yaml"
50
+ - ".github/workflows/test.yml"
48
51
  - ".gitignore"
49
52
  - ".rspec"
50
53
  - ".rubocop.yml"
51
- - ".travis.yml"
54
+ - CHANGELOG.md
52
55
  - Gemfile
53
56
  - LICENSE.txt
54
57
  - README.md
@@ -59,6 +62,7 @@ files:
59
62
  - lib/yabeda/http_requests.rb
60
63
  - lib/yabeda/http_requests/sniffer.rb
61
64
  - lib/yabeda/http_requests/version.rb
65
+ - yabeda-http_requests-logo.png
62
66
  - yabeda-http_requests.gemspec
63
67
  homepage: https://github.com/yabeda-rb/yabeda-http_requests
64
68
  licenses:
@@ -74,14 +78,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
74
78
  requirements:
75
79
  - - ">="
76
80
  - !ruby/object:Gem::Version
77
- version: 2.3.0
81
+ version: '2.5'
78
82
  required_rubygems_version: !ruby/object:Gem::Requirement
79
83
  requirements:
80
84
  - - ">="
81
85
  - !ruby/object:Gem::Version
82
86
  version: '0'
83
87
  requirements: []
84
- rubygems_version: 3.1.2
88
+ rubygems_version: 3.1.6
85
89
  signing_key:
86
90
  specification_version: 4
87
91
  summary: Monitoring of external services HTTP/HTTPS calls
data/.travis.yml DELETED
@@ -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