-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename to yabeda-puma-plugin, because yabeda-puma has already taken
- Loading branch information
1 parent
8da09c9
commit ca0eaf4
Showing
18 changed files
with
109 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require "yabeda/puma/plugin/version" | ||
require 'yabeda' | ||
|
||
module Yabeda | ||
module Puma | ||
module Plugin | ||
class << self | ||
attr_accessor :control_url, :control_auth_token | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module Yabeda | ||
module Puma | ||
module Plugin | ||
module Statistics | ||
METRICS = [:backlog, :running, :pool_capacity, :max_threads, :workers] | ||
CLUSTERED_METRICS = [:booted_workers, :old_workers] | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require 'yabeda/puma/plugin/statistics' | ||
require 'json' | ||
|
||
module Yabeda | ||
module Puma | ||
module Plugin | ||
module Statistics | ||
class Fetcher | ||
def self.call | ||
body = Socket.unix(Yabeda::Puma::Plugin.control_url.gsub("unix://", '')) do |socket| | ||
socket << "GET /stats?token=#{Yabeda::Puma::Plugin.control_auth_token} HTTP/1.0\r\n\r\n" | ||
socket.read | ||
end | ||
|
||
JSON.parse(body.split("\n").last) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
require 'yabeda/puma/plugin/statistics' | ||
|
||
module Yabeda | ||
module Puma | ||
module Plugin | ||
module Statistics | ||
class Parser | ||
attr_reader :clustered, :data | ||
|
||
def initialize(clustered:, data:) | ||
@clustered = clustered | ||
@data = data | ||
end | ||
|
||
def call | ||
Array.new.tap { |result| parse(data, result) } | ||
end | ||
|
||
private | ||
|
||
def parse(stats, labels = {}, result) | ||
stats.each do |key, value| | ||
value.each { |s| parse(s, labels.merge(index: s['index']), result) } if key == 'worker_status' | ||
parse(value, labels, result) if key == 'last_status' | ||
result << {name: key, value: value, labels: labels} if metric?(key) | ||
end | ||
end | ||
|
||
def metric?(name) | ||
Statistics::METRICS.include?(name.to_sym) || (Statistics::CLUSTERED_METRICS.include?(name.to_sym) && clustered) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Yabeda | ||
module Puma | ||
module Plugin | ||
VERSION = "0.1.0" | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
spec/yabeda/puma/statistics/parser_spec.rb → ...eda/puma/plugin/statistics/parser_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe Yabeda::Puma::Plugin do | ||
it "has a version number" do | ||
expect(Yabeda::Puma::Plugin::VERSION).not_to be nil | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
|
||
lib = File.expand_path("../lib", __FILE__) | ||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | ||
require "yabeda/puma/version" | ||
require "yabeda/puma/plugin/version" | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = "yabeda-puma" | ||
spec.version = Yabeda::Puma::VERSION | ||
spec.name = "yabeda-puma-plugin" | ||
spec.version = Yabeda::Puma::Plugin::VERSION | ||
spec.authors = ["Salahutdinov Dmitry"] | ||
spec.email = ["[email protected]"] | ||
|
||
spec.summary = %q{Collecting metrics of the puma web server.} | ||
spec.summary = %q{Puma web server plugin for collecting puma metrics with Yabeda framework.} | ||
spec.description = %q{Extends Yabeda metrics with puma web server values by using puma plugin} | ||
spec.homepage = "http://github.com/yabeda-rb/yabeda-puma" | ||
spec.homepage = "http://github.com/yabeda-rb/yabeda-puma-plugin" | ||
spec.license = "MIT" | ||
|
||
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do | ||
|
@@ -28,6 +28,5 @@ Gem::Specification.new do |spec| | |
spec.add_development_dependency "bundler" | ||
spec.add_development_dependency "rake", "~> 10.0" | ||
spec.add_development_dependency "rspec", "~> 3.0" | ||
spec.add_development_dependency "byebug" | ||
spec.add_development_dependency "rack" | ||
end |