yabeda-anycable 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.
- checksums.yaml +7 -0
- data/.github/workflows/release.yml +82 -0
- data/.github/workflows/test.yml +45 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.rubocop.yml +33 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +86 -0
- data/LICENSE.txt +21 -0
- data/README.md +91 -0
- data/Rakefile +12 -0
- data/bin/console +11 -0
- data/bin/setup +8 -0
- data/lib/yabeda/anycable.rb +34 -0
- data/lib/yabeda/anycable/middleware.rb +21 -0
- data/lib/yabeda/anycable/version.rb +7 -0
- data/yabeda-anycable-logo.png +0 -0
- data/yabeda-anycable.gemspec +33 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e76796d4558c166a201eee2af2e0c794ec2417dc53826330b437fca2f9dae3b2
|
4
|
+
data.tar.gz: b27eb4bb731973a3cb37cdbb12e843a2a03bcd92dd6bf1ff8cbffd8054481296
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 390c3093be23828016551909a4cc4678311ca5573830b2be42ce9ff024c02666007e0211e7a04f255edb5ea340f7d96269efd5cd42e82c5c3144f7e68f4e5698
|
7
|
+
data.tar.gz: 20ed44d8f1cdeb5fcaecf593bcc35068be2a2fc82a57dc71da2f0db22f024c8aeb2245c32baa541e7cc1d3416f5019e1afbdee559ac159a8b3a7a5e9764bf7a9
|
@@ -0,0 +1,82 @@
|
|
1
|
+
name: Publish release and push 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: "3.0"
|
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-anycable-${{ steps.tag.outputs.version }}.gem > SHA256SUM
|
42
|
+
- name: Check version
|
43
|
+
run: ls -l yabeda-anycable-${{ 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-anycable-${{ steps.tag.outputs.version }}.gem
|
62
|
+
asset_name: yabeda-anycable-${{ 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-anycable-${{ 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-anycable-${{ steps.tag.outputs.version }}.gem
|
@@ -0,0 +1,45 @@
|
|
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
|
+
runs-on: ubuntu-latest
|
15
|
+
strategy:
|
16
|
+
fail-fast: false
|
17
|
+
matrix:
|
18
|
+
include:
|
19
|
+
- ruby: "3.0"
|
20
|
+
- ruby: "2.7"
|
21
|
+
- ruby: "2.6"
|
22
|
+
container:
|
23
|
+
image: ruby:${{ matrix.ruby }}
|
24
|
+
env:
|
25
|
+
CI: true
|
26
|
+
steps:
|
27
|
+
- uses: actions/checkout@v2
|
28
|
+
- uses: actions/cache@v2
|
29
|
+
with:
|
30
|
+
path: vendor/bundle
|
31
|
+
key: bundle-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}-${{ hashFiles('**/Gemfile') }}
|
32
|
+
restore-keys: |
|
33
|
+
bundle-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}-${{ hashFiles('**/Gemfile') }}
|
34
|
+
bundle-${{ matrix.ruby }}-
|
35
|
+
- name: Upgrade Bundler to 2.0 (for older Rubies)
|
36
|
+
run: gem install bundler -v '~> 2.0'
|
37
|
+
- name: Bundle install
|
38
|
+
run: |
|
39
|
+
bundle config path vendor/bundle
|
40
|
+
bundle install
|
41
|
+
bundle update
|
42
|
+
- name: Run Rubocop
|
43
|
+
run: bundle exec rubocop
|
44
|
+
- name: Run RSpec
|
45
|
+
run: bundle exec rspec
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.6
|
3
|
+
|
4
|
+
Style/StringLiterals:
|
5
|
+
Enabled: true
|
6
|
+
EnforcedStyle: double_quotes
|
7
|
+
|
8
|
+
Style/StringLiteralsInInterpolation:
|
9
|
+
Enabled: true
|
10
|
+
EnforcedStyle: double_quotes
|
11
|
+
|
12
|
+
Style/TrailingCommaInArrayLiteral:
|
13
|
+
Enabled: true
|
14
|
+
EnforcedStyleForMultiline: consistent_comma
|
15
|
+
|
16
|
+
Style/TrailingCommaInHashLiteral:
|
17
|
+
Enabled: true
|
18
|
+
EnforcedStyleForMultiline: consistent_comma
|
19
|
+
|
20
|
+
Style/TrailingCommaInArguments:
|
21
|
+
Enabled: true
|
22
|
+
EnforcedStyleForMultiline: consistent_comma
|
23
|
+
|
24
|
+
Layout/LineLength:
|
25
|
+
Max: 120
|
26
|
+
|
27
|
+
Metrics/BlockLength:
|
28
|
+
Exclude:
|
29
|
+
- "Gemfile"
|
30
|
+
- "spec/**/*"
|
31
|
+
|
32
|
+
Metrics/AbcSize:
|
33
|
+
Max: 20
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in yabeda-anycable.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem "pry"
|
9
|
+
gem "pry-byebug"
|
10
|
+
gem "pry-doc"
|
11
|
+
|
12
|
+
gem "rake", "~> 13.0"
|
13
|
+
|
14
|
+
gem "rspec", "~> 3.0"
|
15
|
+
|
16
|
+
gem "rubocop", "~> 1.7"
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
yabeda-anycable (0.1.0)
|
5
|
+
anycable-core (~> 1.1)
|
6
|
+
yabeda (~> 0.10)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
anycable-core (1.1.1)
|
12
|
+
anyway_config (>= 2.1.0)
|
13
|
+
google-protobuf (>= 3.13)
|
14
|
+
anyway_config (2.1.0)
|
15
|
+
ruby-next-core (>= 0.11.0)
|
16
|
+
ast (2.4.2)
|
17
|
+
byebug (11.1.3)
|
18
|
+
coderay (1.1.3)
|
19
|
+
concurrent-ruby (1.1.9)
|
20
|
+
diff-lcs (1.4.4)
|
21
|
+
dry-initializer (3.0.4)
|
22
|
+
google-protobuf (3.17.3-x86_64-linux)
|
23
|
+
method_source (1.0.0)
|
24
|
+
parallel (1.20.1)
|
25
|
+
parser (3.0.2.0)
|
26
|
+
ast (~> 2.4.1)
|
27
|
+
pry (0.14.1)
|
28
|
+
coderay (~> 1.1)
|
29
|
+
method_source (~> 1.0)
|
30
|
+
pry-byebug (3.8.0)
|
31
|
+
byebug (~> 11.0)
|
32
|
+
pry (~> 0.10)
|
33
|
+
pry-doc (1.1.0)
|
34
|
+
pry (~> 0.11)
|
35
|
+
yard (~> 0.9.11)
|
36
|
+
rainbow (3.0.0)
|
37
|
+
rake (13.0.6)
|
38
|
+
regexp_parser (2.1.1)
|
39
|
+
rexml (3.2.5)
|
40
|
+
rspec (3.10.0)
|
41
|
+
rspec-core (~> 3.10.0)
|
42
|
+
rspec-expectations (~> 3.10.0)
|
43
|
+
rspec-mocks (~> 3.10.0)
|
44
|
+
rspec-core (3.10.1)
|
45
|
+
rspec-support (~> 3.10.0)
|
46
|
+
rspec-expectations (3.10.1)
|
47
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
48
|
+
rspec-support (~> 3.10.0)
|
49
|
+
rspec-mocks (3.10.2)
|
50
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
51
|
+
rspec-support (~> 3.10.0)
|
52
|
+
rspec-support (3.10.2)
|
53
|
+
rubocop (1.18.3)
|
54
|
+
parallel (~> 1.10)
|
55
|
+
parser (>= 3.0.0.0)
|
56
|
+
rainbow (>= 2.2.2, < 4.0)
|
57
|
+
regexp_parser (>= 1.8, < 3.0)
|
58
|
+
rexml
|
59
|
+
rubocop-ast (>= 1.7.0, < 2.0)
|
60
|
+
ruby-progressbar (~> 1.7)
|
61
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
62
|
+
rubocop-ast (1.8.0)
|
63
|
+
parser (>= 3.0.1.1)
|
64
|
+
ruby-next-core (0.12.0)
|
65
|
+
ruby-progressbar (1.11.0)
|
66
|
+
unicode-display_width (2.0.0)
|
67
|
+
yabeda (0.10.0)
|
68
|
+
anyway_config (>= 1.3, < 3)
|
69
|
+
concurrent-ruby
|
70
|
+
dry-initializer
|
71
|
+
yard (0.9.26)
|
72
|
+
|
73
|
+
PLATFORMS
|
74
|
+
x86_64-linux
|
75
|
+
|
76
|
+
DEPENDENCIES
|
77
|
+
pry
|
78
|
+
pry-byebug
|
79
|
+
pry-doc
|
80
|
+
rake (~> 13.0)
|
81
|
+
rspec (~> 3.0)
|
82
|
+
rubocop (~> 1.7)
|
83
|
+
yabeda-anycable!
|
84
|
+
|
85
|
+
BUNDLED WITH
|
86
|
+
2.2.24
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 Andrey Novikov
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
# 
|
2
|
+
|
3
|
+
Built-in metrics for monitoring [AnyCable] RPC server out of the box! Part of the [Yabeda] suite.
|
4
|
+
|
5
|
+
See [AnyCable architecture](https://docs.anycable.io/architecture) on details on what AnyCable RPC server is. For monitoring of [AnyCable] websocket server you will need to use [monitoring capabilities](https://docs.anycable.io/anycable-go/instrumentation) built in [anycable-go] itself.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'yabeda-anycable'
|
11
|
+
|
12
|
+
# Then add monitoring system adapter, e.g.:
|
13
|
+
# gem 'yabeda-prometheus'
|
14
|
+
|
15
|
+
# If you're using Rails, don't forget to add plugin for it:
|
16
|
+
# gem 'yabeda-rails'
|
17
|
+
# But if not then you should run `Yabeda.configure!` manually when your app is ready.
|
18
|
+
```
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
**And that is it!** AnyCable metrics are being collected!
|
25
|
+
|
26
|
+
Additionally, depending on your adapter, you may want to setup metrics export. E.g. for [yabeda-prometheus]:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
# config/initializers/anycable.rb or elsewhere
|
30
|
+
AnyCable.configure_server do
|
31
|
+
Yabeda::Prometheus::Exporter.start_metrics_server!
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+
## Metrics
|
36
|
+
|
37
|
+
- Counter of total number of RPC calls: `anycable_rpc_call_count` (segmented by `method`, `command`, and `status`)
|
38
|
+
- Histogram of RPC call duration: `anycable_rpc_call_runtime` (seconds per RPC call execution, segmented by `method`, `command`, and `status`)
|
39
|
+
|
40
|
+
`status` label may be one of `SUCCESS` (all is good), `FAILURE` (e.g. connection rejected), or `ERROR` (exception raised).
|
41
|
+
|
42
|
+
## Development
|
43
|
+
|
44
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
45
|
+
|
46
|
+
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).
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/yabeda-rb/yabeda-anycable.
|
51
|
+
|
52
|
+
### Releasing
|
53
|
+
|
54
|
+
1. Bump version number in `lib/yabeda/anycable/version.rb`
|
55
|
+
|
56
|
+
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::AnyCable::VERSION).to_s`
|
57
|
+
|
58
|
+
2. Fill `CHANGELOG.md` with missing changes, add header with version and date.
|
59
|
+
|
60
|
+
3. Make a commit:
|
61
|
+
|
62
|
+
```sh
|
63
|
+
git add lib/yabeda/anycable/version.rb CHANGELOG.md
|
64
|
+
version=$(ruby -r ./lib/yabeda/anycable/version.rb -e "puts Gem::Version.new(Yabeda::AnyCable::VERSION)")
|
65
|
+
git commit --message="${version}: " --edit
|
66
|
+
```
|
67
|
+
|
68
|
+
4. Create annotated tag:
|
69
|
+
|
70
|
+
```sh
|
71
|
+
git tag v${version} --annotate --message="${version}: " --edit --sign
|
72
|
+
```
|
73
|
+
|
74
|
+
5. Fill version name into subject line and (optionally) some description (list of changes will be taken from changelog and appended automatically)
|
75
|
+
|
76
|
+
6. Push it:
|
77
|
+
|
78
|
+
```sh
|
79
|
+
git push --follow-tags
|
80
|
+
```
|
81
|
+
|
82
|
+
7. GitHub Actions will create a new release, build and push gem into RubyGems! You're done!
|
83
|
+
|
84
|
+
## License
|
85
|
+
|
86
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
87
|
+
|
88
|
+
[AnyCable]: https://anycable.io/ "Polyglot replacement for ActionCable server"
|
89
|
+
[anycable-go]: https://github.com/anycable/anycable-go "AnyCable WebSocket server written in Go"
|
90
|
+
[Yabeda]: https://github.com/yabeda-rb/yabeda "Extendable framework for collecting and exporting metrics from your Ruby application"
|
91
|
+
[yabeda-prometheus]: https://github.com/yabeda-rb/yabeda-prometheus "Adapter to expose metrics collected by Yabeda plugins to Prometheus via its offical Ruby client"
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "yabeda/anycable"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
require "pry"
|
11
|
+
Pry.start
|
data/bin/setup
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "yabeda"
|
4
|
+
require "anycable"
|
5
|
+
|
6
|
+
require_relative "anycable/middleware"
|
7
|
+
require_relative "anycable/version"
|
8
|
+
|
9
|
+
module Yabeda
|
10
|
+
# Yabeda plugin for instrumenting AnyCable RPC server
|
11
|
+
module AnyCable
|
12
|
+
class Error < StandardError; end
|
13
|
+
|
14
|
+
RUNTIME_HISTOGRAM_BUCKETS = [
|
15
|
+
0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 30, 60,
|
16
|
+
].freeze
|
17
|
+
|
18
|
+
::AnyCable.configure_server do
|
19
|
+
::AnyCable.middleware.use(Middleware)
|
20
|
+
|
21
|
+
::Yabeda.configure do
|
22
|
+
group :anycable
|
23
|
+
|
24
|
+
counter :rpc_call_count, tags: %i[method command status], comment: "RPC calls count"
|
25
|
+
|
26
|
+
histogram :rpc_call_runtime,
|
27
|
+
comment: "RPC call execution time",
|
28
|
+
unit: :seconds, per: :call,
|
29
|
+
tags: %i[method command status],
|
30
|
+
buckets: RUNTIME_HISTOGRAM_BUCKETS
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "anycable/middleware"
|
4
|
+
|
5
|
+
module Yabeda
|
6
|
+
module AnyCable
|
7
|
+
# Instrumentation middleware that wraps every RPC command execution
|
8
|
+
class Middleware < ::AnyCable::Middleware
|
9
|
+
def call(rpc_method_name, request, _metadata = nil)
|
10
|
+
started = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
11
|
+
(response = yield)
|
12
|
+
ensure
|
13
|
+
elapsed = (Process.clock_gettime(Process::CLOCK_MONOTONIC) - started).round(4)
|
14
|
+
labels = { method: rpc_method_name.to_s, status: response.status.to_s }
|
15
|
+
labels[:command] = request.respond_to?(:command) ? request.command : ""
|
16
|
+
::Yabeda.anycable.rpc_call_count.increment(labels)
|
17
|
+
::Yabeda.anycable.rpc_call_runtime.measure(labels, elapsed)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
Binary file
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/yabeda/anycable/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "yabeda-anycable"
|
7
|
+
spec.version = Yabeda::AnyCable::VERSION
|
8
|
+
spec.authors = ["Andrey Novikov"]
|
9
|
+
spec.email = ["envek@envek.name"]
|
10
|
+
|
11
|
+
spec.summary = "Collect performance metrics for AnyCable RPC server"
|
12
|
+
spec.description = <<~DESC
|
13
|
+
Yabeda plugin for easy collection of most important AnyCable RPC metrics: \
|
14
|
+
number and duration of executed commands, etc…
|
15
|
+
DESC
|
16
|
+
spec.homepage = "https://github.com/yabeda-rb/yabeda-anycable"
|
17
|
+
spec.license = "MIT"
|
18
|
+
spec.required_ruby_version = ">= 2.6.0"
|
19
|
+
|
20
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
21
|
+
spec.metadata["source_code_uri"] = "https://github.com/yabeda-rb/yabeda-anycable"
|
22
|
+
spec.metadata["changelog_uri"] = "https://github.com/yabeda-rb/yabeda-anycable/blob/master/CHANGELOG.md"
|
23
|
+
|
24
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
25
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
26
|
+
end
|
27
|
+
spec.bindir = "exe"
|
28
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ["lib"]
|
30
|
+
|
31
|
+
spec.add_dependency "anycable-core", "~> 1.1"
|
32
|
+
spec.add_dependency "yabeda", "~> 0.10"
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yabeda-anycable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrey Novikov
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-07-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: anycable-core
|
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
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: yabeda
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.10'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.10'
|
41
|
+
description: 'Yabeda plugin for easy collection of most important AnyCable RPC metrics:
|
42
|
+
number and duration of executed commands, etc…
|
43
|
+
|
44
|
+
'
|
45
|
+
email:
|
46
|
+
- envek@envek.name
|
47
|
+
executables: []
|
48
|
+
extensions: []
|
49
|
+
extra_rdoc_files: []
|
50
|
+
files:
|
51
|
+
- ".github/workflows/release.yml"
|
52
|
+
- ".github/workflows/test.yml"
|
53
|
+
- ".gitignore"
|
54
|
+
- ".rspec"
|
55
|
+
- ".rubocop.yml"
|
56
|
+
- CHANGELOG.md
|
57
|
+
- Gemfile
|
58
|
+
- Gemfile.lock
|
59
|
+
- LICENSE.txt
|
60
|
+
- README.md
|
61
|
+
- Rakefile
|
62
|
+
- bin/console
|
63
|
+
- bin/setup
|
64
|
+
- lib/yabeda/anycable.rb
|
65
|
+
- lib/yabeda/anycable/middleware.rb
|
66
|
+
- lib/yabeda/anycable/version.rb
|
67
|
+
- yabeda-anycable-logo.png
|
68
|
+
- yabeda-anycable.gemspec
|
69
|
+
homepage: https://github.com/yabeda-rb/yabeda-anycable
|
70
|
+
licenses:
|
71
|
+
- MIT
|
72
|
+
metadata:
|
73
|
+
homepage_uri: https://github.com/yabeda-rb/yabeda-anycable
|
74
|
+
source_code_uri: https://github.com/yabeda-rb/yabeda-anycable
|
75
|
+
changelog_uri: https://github.com/yabeda-rb/yabeda-anycable/blob/master/CHANGELOG.md
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 2.6.0
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubygems_version: 3.2.22
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: Collect performance metrics for AnyCable RPC server
|
95
|
+
test_files: []
|