yabeda-http_requests 0.2.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8f5c7fa7bfe5b47c64c40b7fcee8ebd9d35358a0c6f5b6dced6b5ed255282ab7
4
- data.tar.gz: 2a771d809057200cad55ffd88aa1d0f4183016c316d9c6836d7d6465b9163f5e
3
+ metadata.gz: b8f271bf0386cf54dbf378d7332235480aaac16b2739370314ae8bca7c1135ff
4
+ data.tar.gz: fc92f8a329aae59608dad648e97a5bc44cfbbe4aa38b480c9ee2573a96115410
5
5
  SHA512:
6
- metadata.gz: fd615c28e1a2bd5ab02974fc6fd3e69114717d450d02453f2fdeb3748d47125c8c2a2cc2b488cd98afbf0803c6c39df7b3f86461d56273530c8ddccef02142ac
7
- data.tar.gz: 6a410a70d61d54a26eeb3efa91b69aae96e30e6beccaac3ca14c0d7022c702eeb9ac6db9d43cbb642e3792ffe0a9a32d6051ec264123a2b768c2136bc83e5fe8
6
+ metadata.gz: 1f14ef60785c76dc6d1f1dd7129f5ef6cbbab2a7d07e19d2c6bda8968b3012314db9a067131bb75feade1fc93e5c0cf09b5247c70ebddc03476567267939cf40
7
+ data.tar.gz: a80a022901a4e7c6696f3aeb7aa4e5b5697c921bddb04420f6ae11bcdd2dac70e3280cfa86654ba673b36597ee4e42a4f92952cad9d8bba58fccf938f053b4d0
@@ -8,13 +8,17 @@ on:
8
8
  jobs:
9
9
  release:
10
10
  runs-on: ubuntu-latest
11
+ permissions:
12
+ contents: write
13
+ id-token: write
14
+ packages: write
11
15
  steps:
12
- - uses: actions/checkout@v2
16
+ - uses: actions/checkout@v4
13
17
  with:
14
18
  fetch-depth: 0 # Fetch current tag as annotated. See https://github.com/actions/checkout/issues/290
15
19
  - uses: ruby/setup-ruby@v1
16
20
  with:
17
- ruby-version: 2.7
21
+ ruby-version: "3.4"
18
22
  - name: "Extract data from tag: version, message, body"
19
23
  id: tag
20
24
  run: |
@@ -75,8 +79,8 @@ jobs:
75
79
  GEM_HOST_API_KEY: Bearer ${{ secrets.GITHUB_TOKEN }}
76
80
  run: |
77
81
  gem push yabeda-http_requests-${{ steps.tag.outputs.version }}.gem --host https://rubygems.pkg.github.com/${{ github.repository_owner }}
82
+ - name: Configure RubyGems Credentials
83
+ uses: rubygems/configure-rubygems-credentials@main
78
84
  - name: Publish to RubyGems
79
- env:
80
- GEM_HOST_API_KEY: "${{ secrets.RUBYGEMS_API_KEY }}"
81
85
  run: |
82
86
  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
@@ -1,4 +1,4 @@
1
- name: Run tests
1
+ name: Tests
2
2
 
3
3
  on:
4
4
  pull_request:
@@ -10,38 +10,29 @@ on:
10
10
 
11
11
  jobs:
12
12
  test:
13
- name: "Run tests"
14
- if: "! contains(toJSON(github.event.commits.latest.message), '[ci skip]')"
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 }}'
15
16
  runs-on: ubuntu-latest
17
+ continue-on-error: ${{ matrix.optional || false }}
16
18
  strategy:
17
19
  fail-fast: false
18
20
  matrix:
21
+ ruby:
22
+ - '2.7'
23
+ - '3.0'
24
+ - '3.1'
25
+ - '3.2'
26
+ - '3.3'
27
+ - '3.4'
19
28
  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
29
+ - ruby: head
30
+ - optional: true
28
31
  steps:
29
- - uses: actions/checkout@v2
30
- - uses: actions/cache@v2
32
+ - uses: actions/checkout@v4
33
+ - uses: ruby/setup-ruby@v1
31
34
  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
35
+ ruby-version: ${{ matrix.ruby }}
36
+ bundler-cache: true
46
37
  - name: Run RSpec
47
38
  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 CHANGED
@@ -5,6 +5,18 @@ 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.3.0 - 2025-10-20
9
+
10
+ ### Added
11
+
12
+ - Ability to configure histogram bucket sizes for the `response_duration` metric. [#10](https://github.com/yabeda-rb/yabeda-http_requests/pull/10) by [@ryan-dyer-sp][]
13
+
14
+ ## 0.2.1 - 2023-12-14
15
+
16
+ ### Fixed
17
+
18
+ - Ensure http method is always uppercase. [@webmat], [#6](https://github.com/yabeda-rb/yabeda-http_requests/pull/6)
19
+
8
20
  ## 0.2.0 - 2021-01-25
9
21
 
10
22
  ### Fixed
@@ -36,3 +48,5 @@ Initial release.
36
48
  [@dreikanter]: https://github.com/dreikanter "Alex Musayev"
37
49
  [@danmarcab]: https://github.com/danmarcab "Daniel Marín"
38
50
  [@Envek]: https://github.com/Envek "Andrey Novikov"
51
+ [@webmat]: https://github.com/webmat "Mathieu Martin"
52
+ [@ryan-dyer-sp]: https://github.com/ryan-dyer-sp "Ryan"
data/Gemfile CHANGED
@@ -4,6 +4,8 @@ source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
6
 
7
+ gem 'yabeda', '>= 0.13.0'
8
+
7
9
  gem 'byebug'
8
10
  gem 'rake', '~> 12.0'
9
11
  gem 'rspec', '~> 3.0'
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
 
@@ -67,6 +67,14 @@ Follow the [yabeda-external-http-requests](http://localhost:3000/d/OGd-oEXWz/yab
67
67
  Finally, after a couple of minutes when data collected you will see the following:
68
68
  ![Monitor external HTTP calls with Grafana](docs/dashboard.png)
69
69
 
70
+ ## Configuration
71
+
72
+ Configuration is handled by [anyway_config] gem. With it you can load settings from environment variables (upcased and prefixed with `YABEDA_HTTP_REQUESTS_`), YAML files, and other sources. See [anyway_config] docs for details.
73
+
74
+ | Config key | Type | Default | Description |
75
+ | -----------| ----- | ------- | ------------------------------------------- |
76
+ | `buckets` | array | [] | Set buckets to be used by histogram metrics |
77
+
70
78
  ## Development with Docker
71
79
 
72
80
  Get local development environment working and tests running is very easy with docker-compose:
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'anyway'
4
+
5
+ module Yabeda
6
+ module HttpRequests
7
+ # yabeda-http-requests configuration
8
+ class Config < ::Anyway::Config
9
+ config_name :yabeda_http_requests
10
+
11
+ attr_config :buckets
12
+ end
13
+ end
14
+ end
@@ -10,7 +10,7 @@ module Yabeda
10
10
  {
11
11
  host: data_item.request.host,
12
12
  port: data_item.request.port,
13
- method: data_item.request.method
13
+ method: data_item.request.method.upcase
14
14
  }
15
15
  )
16
16
  end
@@ -28,7 +28,7 @@ module Yabeda
28
28
  {
29
29
  host: data_item.request.host,
30
30
  port: data_item.request.port,
31
- method: data_item.request.method,
31
+ method: data_item.request.method.upcase,
32
32
  status: data_item.response.status
33
33
  }
34
34
  )
@@ -38,7 +38,7 @@ module Yabeda
38
38
  labels = {
39
39
  host: data_item.request.host,
40
40
  port: data_item.request.port,
41
- method: data_item.request.method,
41
+ method: data_item.request.method.upcase,
42
42
  status: data_item.response.status
43
43
  }
44
44
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yabeda
4
4
  module HttpRequests
5
- VERSION = '0.2.0'
5
+ VERSION = '0.3.0'
6
6
  end
7
7
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'yabeda/http_requests/version'
4
4
  require 'yabeda/http_requests/sniffer'
5
+ require 'yabeda/http_requests/config'
5
6
  require 'yabeda'
6
7
  require 'sniffer'
7
8
 
@@ -16,22 +17,22 @@ module Yabeda
16
17
  ].freeze
17
18
 
18
19
  Yabeda.configure do
20
+ config = ::Yabeda::HttpRequests::Config.new
21
+ buckets = config.buckets || LONG_RUNNING_REQUEST_BUCKETS
22
+
19
23
  group :http
20
24
 
21
25
  counter :request_total,
22
- comment: 'A counter of the total number of external HTTP \
23
- requests.',
26
+ comment: 'A counter of the total number of external HTTP requests.',
24
27
  tags: %i[host port method]
25
28
  counter :response_total,
26
- comment: 'A counter of the total number of external HTTP \
27
- responses.',
29
+ comment: 'A counter of the total number of external HTTP responses.',
28
30
  tags: %i[host port method status]
29
31
 
30
32
  histogram :response_duration, tags: %i[host port method status],
31
33
  unit: :milliseconds,
32
- buckets: LONG_RUNNING_REQUEST_BUCKETS,
33
- comment: "A histogram of the response \
34
- duration (milliseconds)."
34
+ buckets: buckets,
35
+ comment: 'A histogram of the response duration (milliseconds).'
35
36
 
36
37
  ::Sniffer.config do |c|
37
38
  c.enabled = true
Binary file
@@ -26,6 +26,8 @@ Gem::Specification.new do |spec|
26
26
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
27
  spec.require_paths = ['lib']
28
28
 
29
+ spec.add_dependency 'anyway_config', '>= 1.3', '< 3.0'
30
+
29
31
  spec.add_runtime_dependency 'sniffer'
30
32
  spec.add_runtime_dependency 'yabeda'
31
33
  end
metadata CHANGED
@@ -1,15 +1,34 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yabeda-http_requests
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Salahutdinov
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2021-01-25 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: anyway_config
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '1.3'
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: '1.3'
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: '3.0'
13
32
  - !ruby/object:Gem::Dependency
14
33
  name: sniffer
15
34
  requirement: !ruby/object:Gem::Requirement
@@ -46,6 +65,7 @@ extensions: []
46
65
  extra_rdoc_files: []
47
66
  files:
48
67
  - ".github/workflows/build-release.yml"
68
+ - ".github/workflows/lint.yaml"
49
69
  - ".github/workflows/test.yml"
50
70
  - ".gitignore"
51
71
  - ".rspec"
@@ -59,8 +79,10 @@ files:
59
79
  - bin/setup
60
80
  - docker-compose.yml
61
81
  - lib/yabeda/http_requests.rb
82
+ - lib/yabeda/http_requests/config.rb
62
83
  - lib/yabeda/http_requests/sniffer.rb
63
84
  - lib/yabeda/http_requests/version.rb
85
+ - yabeda-http_requests-logo.png
64
86
  - yabeda-http_requests.gemspec
65
87
  homepage: https://github.com/yabeda-rb/yabeda-http_requests
66
88
  licenses:
@@ -68,7 +90,6 @@ licenses:
68
90
  metadata:
69
91
  homepage_uri: https://github.com/yabeda-rb/yabeda-http_requests
70
92
  source_code_uri: https://github.com/yabeda-rb/yabeda-http_requests
71
- post_install_message:
72
93
  rdoc_options: []
73
94
  require_paths:
74
95
  - lib
@@ -83,8 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
104
  - !ruby/object:Gem::Version
84
105
  version: '0'
85
106
  requirements: []
86
- rubygems_version: 3.1.4
87
- signing_key:
107
+ rubygems_version: 3.6.9
88
108
  specification_version: 4
89
109
  summary: Monitoring of external services HTTP/HTTPS calls
90
110
  test_files: []