influxdb-process 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/.gitignore +9 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/Makefile +2 -0
- data/README.md +77 -0
- data/Rakefile +2 -0
- data/influxdb-process.gemspec +26 -0
- data/lib/influxdb/process/version.rb +5 -0
- data/lib/influxdb/process.rb +19 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1392cd9aa1f34ccf439ff3be4ff7e353b0a8a177
|
4
|
+
data.tar.gz: 455bb5e9016eb0676137b946b7c1460a4a2a3a9a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d00fe0f8b62f6f674f47d6ab2d4eea9dce08233a826480df24e796be9e1ffb889f2023ad8270db185d99febd26fd8ba745aa76d472ec199a4172be6fee0330a1
|
7
|
+
data.tar.gz: 0d355f43aaf1344a266ed51c8f2da64eecb205d389588d8a0b9a1d96f40c1079f80f572301681ca152f0fca30b82211eaddf390198ca8f26d52afcef0349b243
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Ilya Vassilevsky
|
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/Makefile
ADDED
data/README.md
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# InfluxDB::Process
|
2
|
+
|
3
|
+
Gathers metrics from the Ruby process it is executed in and sends them to an InfluxDB database.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'influxdb-process'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or do all this at once:
|
18
|
+
|
19
|
+
$ bundle add influxdb-process
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
This library assumes that you already have a working InfluxDB client instance.
|
24
|
+
It does not attempt to create one for you.
|
25
|
+
If not, see [InfluxDB Ruby](https://github.com/influxdata/influxdb-ruby) for client initialization instructions.
|
26
|
+
Let's say you have the client in the `influxdb` variable, as it says.
|
27
|
+
|
28
|
+
Add this to any place in your Ruby program:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
InfluxDB::Process::Instrumentation.new(influxdb)
|
32
|
+
```
|
33
|
+
|
34
|
+
When you deploy this, the process where this code is executed will create a new thread.
|
35
|
+
It will periodically collect process metrics and send them to InfluxDB via the provided client.
|
36
|
+
|
37
|
+
By default, metrics will be written to the `process_metrics` series every *10* seconds.
|
38
|
+
You can set your own series name and interval via additional keyword arguments:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
InfluxDB::Process::Instrumentation.new(influxdb, series: 'ruby_stats', interval: 42)
|
42
|
+
```
|
43
|
+
|
44
|
+
Metrics will be tagged with process name.
|
45
|
+
By default, `$0`/`$PROGRAM_NAME` will be used.
|
46
|
+
You can set your own process name via an additional keyword argument:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
InfluxDB::Process::Instrumentation.new(influxdb, process: 'report_generator')
|
50
|
+
```
|
51
|
+
|
52
|
+
You can also set the `INFLUXDB_PROCESS_NAME` environment variable:
|
53
|
+
|
54
|
+
INFLUXDB_PROCESS_NAME=cache_cleaner bundle exec ruby ...
|
55
|
+
|
56
|
+
It will take precedence over the keyword argument.
|
57
|
+
|
58
|
+
## Development
|
59
|
+
|
60
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
61
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
62
|
+
|
63
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
64
|
+
To release a new version:
|
65
|
+
* Update the version number in `version.rb`
|
66
|
+
* Run `bundle exec rake release`, which will do the following:
|
67
|
+
* create a git tag for the version
|
68
|
+
* push git commits and tags
|
69
|
+
* push the `.gem` file to [rubygems.org](https://rubygems.org)
|
70
|
+
|
71
|
+
## Contributing
|
72
|
+
|
73
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/vassilevsky/influxdb-process
|
74
|
+
|
75
|
+
## License
|
76
|
+
|
77
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "influxdb/process/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "influxdb-process"
|
7
|
+
spec.version = InfluxDB::Process::VERSION
|
8
|
+
spec.authors = ["Ilya Vassilevsky"]
|
9
|
+
spec.email = ["vassilevsky@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Ruby process instrumentation to an InfluxDB database"
|
12
|
+
spec.homepage = "https://github.com/vassilevsky/influxdb-process"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
|
+
f.match(%r{^(test|spec|features)/})
|
17
|
+
end
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "influxdb"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "influxdb"
|
2
|
+
require "influxdb/process/version"
|
3
|
+
|
4
|
+
module InfluxDB
|
5
|
+
module Process
|
6
|
+
class Instrumentation
|
7
|
+
def initialize(influxdb, series: 'process_metrics', interval: 10, process: nil)
|
8
|
+
@process = ENV['INFLUXDB_PROCESS_NAME'] || process || $PROGRAM_NAME
|
9
|
+
|
10
|
+
Thread.new do
|
11
|
+
loop do
|
12
|
+
influxdb.write_point(series, tags: {process: @process}, values: GC.stat)
|
13
|
+
sleep(interval)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: influxdb-process
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ilya Vassilevsky
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-12-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: influxdb
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.16'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.16'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- vassilevsky@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- Makefile
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- influxdb-process.gemspec
|
69
|
+
- lib/influxdb/process.rb
|
70
|
+
- lib/influxdb/process/version.rb
|
71
|
+
homepage: https://github.com/vassilevsky/influxdb-process
|
72
|
+
licenses:
|
73
|
+
- MIT
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 2.6.13
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: Ruby process instrumentation to an InfluxDB database
|
95
|
+
test_files: []
|