rt-watchman 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +48 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/watchman/store.rb +11 -0
- data/lib/watchman/version.rb +3 -0
- data/lib/watchman.rb +53 -0
- data/watchman.gemspec +23 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 88bb77b06c44e1102fb710df63250ae6f22f4e3e
|
4
|
+
data.tar.gz: e0fc15204138fc0d09048dbacd815fd6df2d8c71
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c45606318147f76702d2f3d2c6426063066215248d77902c92e39dbc2b9645bfaa1eb8133a9b1e6eceeec9430ee0e227fcd5e535bedb4ed8c2dffd9a28b95a2a
|
7
|
+
data.tar.gz: 0a6ce7072878da5125589c598fa4dd2d3a9339159341e88ac2dc67fd0edd6dbf12fd857841faa58bb425ef0bb19adebbe544e9902fd8c35ee44008e9e95c75ea
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Igor Šarčević
|
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,48 @@
|
|
1
|
+
# Watchman
|
2
|
+
|
3
|
+
Watchman is your friend who monitors your processes so you don't have to.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
``` ruby
|
8
|
+
gem 'watchman'
|
9
|
+
```
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
First, set up the host and the port of the metrics server:
|
14
|
+
|
15
|
+
``` ruby
|
16
|
+
Watchman.host = "localhost"
|
17
|
+
Watchman.port = 22345
|
18
|
+
```
|
19
|
+
|
20
|
+
To submit a simple value from your service:
|
21
|
+
|
22
|
+
``` ruby
|
23
|
+
Watchman.submit("number.of.kittens", 30)
|
24
|
+
```
|
25
|
+
|
26
|
+
To benchmark a part of your service:
|
27
|
+
|
28
|
+
``` ruby
|
29
|
+
Watchman.benchmark("time.to.wake.up") do
|
30
|
+
puts "Sleeping"
|
31
|
+
sleep 10
|
32
|
+
puts "Wake up"
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
## Global metric prefix
|
37
|
+
|
38
|
+
If you want to prepend all the metric names with a prefix, do the following:
|
39
|
+
|
40
|
+
``` ruby
|
41
|
+
Watchman.prefix = "production.server1"
|
42
|
+
```
|
43
|
+
|
44
|
+
Then, all your metrics will be saved with that prefix. For example:
|
45
|
+
|
46
|
+
``` ruby
|
47
|
+
Watchman.submit("high.score", 100) # => production.server1.high.score = 100
|
48
|
+
```
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "watchman"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/watchman.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require "watchman/version"
|
2
|
+
require "benchmark"
|
3
|
+
require "socket"
|
4
|
+
|
5
|
+
module Watchman
|
6
|
+
module_function
|
7
|
+
|
8
|
+
require_relative "watchman/store"
|
9
|
+
|
10
|
+
def prefix=(value)
|
11
|
+
@prefix = value
|
12
|
+
end
|
13
|
+
|
14
|
+
def host=(host)
|
15
|
+
@host = host
|
16
|
+
end
|
17
|
+
|
18
|
+
def host
|
19
|
+
@host
|
20
|
+
end
|
21
|
+
|
22
|
+
def port=(port)
|
23
|
+
@port = port
|
24
|
+
end
|
25
|
+
|
26
|
+
def port
|
27
|
+
@port
|
28
|
+
end
|
29
|
+
|
30
|
+
def submit(name, value)
|
31
|
+
Watchman::Store.save(metric_name_with_prefix(name), value)
|
32
|
+
end
|
33
|
+
|
34
|
+
def benchmark(name)
|
35
|
+
result = nil
|
36
|
+
|
37
|
+
time = Benchmark.measure do
|
38
|
+
result = yield
|
39
|
+
end
|
40
|
+
|
41
|
+
submit(name, (time.real * 1000).floor)
|
42
|
+
|
43
|
+
result
|
44
|
+
end
|
45
|
+
|
46
|
+
def metric_name_with_prefix(name)
|
47
|
+
if @prefix
|
48
|
+
"#{@prefix}.#{name}"
|
49
|
+
else
|
50
|
+
name
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/watchman.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'watchman/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rt-watchman"
|
8
|
+
spec.version = Watchman::VERSION
|
9
|
+
spec.authors = ["Rendered Text"]
|
10
|
+
spec.email = ["devops@renderedtext.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Watches your cloud}
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.bindir = "exe"
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
spec.add_development_dependency "rspec"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rt-watchman
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rendered Text
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- devops@renderedtext.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- CODE_OF_CONDUCT.md
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/console
|
70
|
+
- bin/setup
|
71
|
+
- lib/watchman.rb
|
72
|
+
- lib/watchman/store.rb
|
73
|
+
- lib/watchman/version.rb
|
74
|
+
- watchman.gemspec
|
75
|
+
homepage:
|
76
|
+
licenses:
|
77
|
+
- MIT
|
78
|
+
metadata: {}
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 2.4.8
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: Watches your cloud
|
99
|
+
test_files: []
|