phobos_prometheus 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 303cb6f568d8d956511bd7c60f7ac21ba20b6254
4
+ data.tar.gz: a8cbc11a5a7ba06537d325d2f47a755d676c4b7a
5
+ SHA512:
6
+ metadata.gz: 0f0c30dd031276feeba291ddbd897f4a968abfbdc955f83868e2217760fcf9e04909d0a55a1e54315d78c98c3f40f692d7cfef6c32786b7fba3a7dfd0fa0f35e
7
+ data.tar.gz: d2819b2d6e2f9b999feb7f5eeb067dbbd63a6a8b6602459dfb76056c578071c7ae2ae3f2afce4c10ee7aaad577bb6824134a283c997a7a53bc6b845c0053599e
data/.editorconfig ADDED
@@ -0,0 +1,9 @@
1
+ root = true
2
+
3
+ [*]
4
+ indent_style = space
5
+ indent_size = 2
6
+ end_of_line = lf
7
+ charset = utf-8
8
+ trim_trailing_whitespace = true
9
+ insert_final_newline = true
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,19 @@
1
+ ###########################
2
+ # Configuration for rubocop
3
+ # in .rubocop.yml
4
+
5
+ ##############
6
+ # Global rules
7
+ # see .rubocop_common.yml
8
+
9
+ ##############
10
+ # Inherit default rules first, and then override those rules with
11
+ # our violation whitelist.
12
+ inherit_from:
13
+ - .rubocop_common.yml
14
+
15
+ ##############
16
+ # Project specific overrides here, example:
17
+ # Metrics/BlockLength:
18
+ # Exclude:
19
+ # - 'tasks/the_huge_task.rake'
@@ -0,0 +1,23 @@
1
+ ##############
2
+ # Global rules
3
+ AllCops:
4
+ Exclude:
5
+ - db/**/*
6
+ TargetRubyVersion: 2.4
7
+
8
+ Rails:
9
+ Enabled: false
10
+
11
+ Style/SymbolArray:
12
+ EnforcedStyle: brackets
13
+
14
+ Metrics/LineLength:
15
+ Max: 100
16
+
17
+ Metrics/BlockLength:
18
+ Exclude:
19
+ - '*.gemspec'
20
+ - 'spec/**/*.rb'
21
+
22
+ Documentation:
23
+ Enabled: false
data/.rubosync.yml ADDED
@@ -0,0 +1,2 @@
1
+ git:
2
+ repo: git@github.com:phobos/shared.git
data/.travis.yml ADDED
@@ -0,0 +1,21 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.6
5
+ - 2.4.1
6
+
7
+ env:
8
+ global:
9
+ - CC_TEST_REPORTER_ID=7f9f912d1c88d636a74d9df3af43093c9e127185ef8e78e43dcd192fad284e17
10
+
11
+ before_install:
12
+ - env
13
+ - gem install bundler -v 1.16.0
14
+
15
+ before_script:
16
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
17
+ - chmod +x ./cc-test-reporter
18
+ - if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then ./cc-test-reporter before-build || echo "Skipping CC coverage before-build"; fi
19
+
20
+ after_script:
21
+ - if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT || echo "Skipping CC coverage after-build"; fi
data/CHANGELOG.md ADDED
@@ -0,0 +1,44 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to
6
+ [Semantic Versioning](http://semver.org/).
7
+
8
+ ## UNRELEASED
9
+
10
+ ## [0.3.2] - 2017-12-18
11
+
12
+ ### Changed
13
+
14
+ * Make sure we support Ruby 2.3
15
+
16
+ ## [0.3.1] - 2017-12-18
17
+
18
+ ### Changed
19
+
20
+ * Bugfix: Histogram did not get bin sizes as per config
21
+ * Bugfix: Gauge incorrectly reported warnings for config following specification
22
+
23
+ ## [0.3.0] - 2017-12-14
24
+
25
+ ### Added
26
+
27
+ * Perform validation of configuration before booting
28
+ * Add support for gauges (to track e.g. total number of started listeners)
29
+
30
+ ### Changed
31
+
32
+ * Configuration is now driven by config file, instead of internal constants #4
33
+
34
+ ## [0.2.0] - 2017-12-04
35
+
36
+ ### Changed
37
+
38
+ * Small internal refactorization
39
+
40
+ ## [0.1.0] - 2017-12-04
41
+
42
+ ### Added
43
+
44
+ * Initial release
@@ -0,0 +1,46 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ ## Our Standards
8
+
9
+ Examples of behavior that contributes to creating a positive environment include:
10
+
11
+ * Using welcoming and inclusive language
12
+ * Being respectful of differing viewpoints and experiences
13
+ * Gracefully accepting constructive criticism
14
+ * Focusing on what is best for the community
15
+ * Showing empathy towards other community members
16
+
17
+ Examples of unacceptable behavior by participants include:
18
+
19
+ * The use of sexualized language or imagery and unwelcome sexual attention or advances
20
+ * Trolling, insulting/derogatory comments, and personal or political attacks
21
+ * Public or private harassment
22
+ * Publishing others' private information, such as a physical or electronic address, without explicit permission
23
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
24
+
25
+ ## Our Responsibilities
26
+
27
+ Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28
+
29
+ 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, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30
+
31
+ ## Scope
32
+
33
+ This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34
+
35
+ ## Enforcement
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at phobosrb@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38
+
39
+ Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40
+
41
+ ## Attribution
42
+
43
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44
+
45
+ [homepage]: http://contributor-covenant.org
46
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in phobos_prometheus.gemspec
8
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,29 @@
1
+ # Description
2
+
3
+ Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
4
+
5
+ Fixes # (issue)
6
+
7
+ ## Type of change
8
+
9
+ Please delete options that are not relevant.
10
+
11
+ - [ ] Bug fix (non-breaking change which fixes an issue)
12
+ - [ ] New feature (non-breaking change which adds functionality)
13
+ - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
14
+ - [ ] This change requires a documentation update
15
+
16
+ # How Has This Been Tested?
17
+
18
+ Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
19
+
20
+ - [ ] Test A
21
+ - [ ] Test B
22
+
23
+ # Checklist:
24
+
25
+ - [ ] My code follows the style guidelines of this project
26
+ - [ ] I have performed a self-review of my own code
27
+ - [ ] I have made corresponding changes to the documentation
28
+ - [ ] I have added tests that prove my fix is effective or that my feature works
29
+ - [ ] Changelog is updated
data/README.md ADDED
@@ -0,0 +1,126 @@
1
+ [![Build Status](https://travis-ci.org/phobos/phobos_prometheus.svg?branch=master)](https://travis-ci.org/phobos/phobos_prometheus)
2
+ [![Maintainability](https://api.codeclimate.com/v1/badges/c6dfe9affb0e7cc5a682/maintainability)](https://codeclimate.com/github/phobos/phobos_prometheus/maintainability)
3
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/c6dfe9affb0e7cc5a682/test_coverage)](https://codeclimate.com/github/phobos/phobos_prometheus/test_coverage)
4
+ [![Chat with us on Discord](https://discordapp.com/api/guilds/379938130326847488/widget.png)](https://discord.gg/rfMUBVD)
5
+
6
+ # Phobos Prometheus
7
+
8
+ A bundled Prometheus collector and exporter of Phobos metrics.
9
+
10
+ Exporter is a simple Sinatra app which can be mounted in eg a Rack App.
11
+
12
+ Collector initializes Prometheus metrics and sets up a subscribtion to certain Phobos events to keep monitor of your metrics
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ ```ruby
19
+ gem 'phobos_prometheus'
20
+ ```
21
+
22
+ And then execute:
23
+
24
+ $ bundle
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install phobos_prometheus
29
+
30
+ ## Usage
31
+
32
+ **Step 1:** In phobos_boot.rb, configure the library by calling `PhobosPrometheus.configure` with
33
+ the path of your configuration file. Note that PhobosPrometheus expects Phobos.configure to have
34
+ been run since it is using Phobos.logger
35
+
36
+ ```ruby
37
+ PhobosPrometheus.configure('config/phobos_prometheus.yml')
38
+ ```
39
+
40
+ **Step 2:** In phobos_boot.rb, add `PhobosPrometheus.subscribe` to setup tracking of Phobos metrics.
41
+
42
+ **Step 3:** In config.ru, mount the metrics endpoint:
43
+
44
+ ```ruby
45
+ run Rack::URLMap.new(
46
+ '/metrics' => PhobosPrometheus::Exporter,
47
+ # ...
48
+ )
49
+ ```
50
+
51
+ ## Configuration
52
+
53
+ There are three major keys to consider: `counters`, `histograms` and `buckets`. You probably also
54
+ want to update `metrics_prefix` to differentiate between different consumer apps.
55
+
56
+ For a list of possible instrumentation events, see Phobos and PhobosDBCheckpoint.
57
+
58
+ ### Counters
59
+
60
+ The `counters` section provides a list of instrumentation labels that you want to create counters
61
+ for. For example, in order to count the number of processed events:
62
+
63
+ ```yml
64
+ counters:
65
+ - instrumentation: listener.process_message
66
+ ```
67
+
68
+ ### Histograms
69
+
70
+ The `histograms` section provides a list of instrumentation labels that you want to create
71
+ histograms for. Histograms are a bit more complex as they require bin sizes, these can be named and referenced via `bucket_name`
72
+
73
+ For example, in order to count the duration of processed events:
74
+
75
+ ```yml
76
+ histograms:
77
+ - instrumentation: listener.process_message
78
+ bucket_name: message
79
+ ```
80
+
81
+ The example above assumes you have defined a bucket with name `message`, see below.
82
+
83
+ ### Buckets
84
+
85
+ The `buckets` section provides a definition of bucket sizes having named labels that you need to
86
+ reference for configuring histograms.
87
+
88
+ To connect with the bucket example above, we need to create a bucket named `message` e.g:
89
+
90
+ ```yml
91
+ buckets:
92
+ - name: message
93
+ bins:
94
+ - 5
95
+ - 10
96
+ - 25
97
+ # - ...
98
+ ```
99
+
100
+ ### Gauges
101
+
102
+ The `gauges` section provides a list of bi-directional gauges. The provided `label` will be used as the prometheus label, and a counter with this label will be incremented on any event matching the instrumentation label given in `increment` and decremented by events matching `decrement`.
103
+
104
+ In order to count the number of active handlers, one could do this:
105
+
106
+ ```yml
107
+ gauges:
108
+ - label: number_of_handlers
109
+ increment: listener.start_handler
110
+ decrement: listener.stop_handler
111
+ ```
112
+
113
+ ## Development
114
+
115
+ After checking out the repo, run `bundle install` to install dependencies. Then, run `rake spec` to
116
+ run the tests. You can also run `bin/console` for an interactive prompt that will allow you to
117
+ experiment.
118
+
119
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new
120
+ version, update the version number in `version.rb`, and then run `bundle exec rake release`, which
121
+ will create a git tag for the version, push git commits and tags, and push the `.gem` file to
122
+ [rubygems.org](https://rubygems.org).
123
+
124
+ ## Contributing
125
+
126
+ Bug reports and pull requests are welcome on GitHub at https://github.com/phobos/phobos_prometheus.