prometheus_exporter 0.7.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +82 -25
  3. data/Appraisals +7 -3
  4. data/CHANGELOG +104 -24
  5. data/Dockerfile +9 -0
  6. data/README.md +258 -51
  7. data/bin/prometheus_exporter +19 -6
  8. data/examples/custom_collector.rb +1 -1
  9. data/gemfiles/ar_70.gemfile +5 -0
  10. data/lib/prometheus_exporter/client.rb +48 -23
  11. data/lib/prometheus_exporter/instrumentation/active_record.rb +11 -29
  12. data/lib/prometheus_exporter/instrumentation/delayed_job.rb +5 -2
  13. data/lib/prometheus_exporter/instrumentation/good_job.rb +30 -0
  14. data/lib/prometheus_exporter/instrumentation/method_profiler.rb +63 -23
  15. data/lib/prometheus_exporter/instrumentation/periodic_stats.rb +62 -0
  16. data/lib/prometheus_exporter/instrumentation/process.rb +5 -21
  17. data/lib/prometheus_exporter/instrumentation/puma.rb +34 -27
  18. data/lib/prometheus_exporter/instrumentation/resque.rb +35 -0
  19. data/lib/prometheus_exporter/instrumentation/sidekiq.rb +53 -23
  20. data/lib/prometheus_exporter/instrumentation/sidekiq_process.rb +52 -0
  21. data/lib/prometheus_exporter/instrumentation/sidekiq_queue.rb +32 -24
  22. data/lib/prometheus_exporter/instrumentation/sidekiq_stats.rb +37 -0
  23. data/lib/prometheus_exporter/instrumentation/unicorn.rb +10 -15
  24. data/lib/prometheus_exporter/instrumentation.rb +5 -0
  25. data/lib/prometheus_exporter/metric/base.rb +12 -10
  26. data/lib/prometheus_exporter/metric/gauge.rb +4 -0
  27. data/lib/prometheus_exporter/metric/histogram.rb +15 -3
  28. data/lib/prometheus_exporter/middleware.rb +45 -19
  29. data/lib/prometheus_exporter/server/active_record_collector.rb +9 -12
  30. data/lib/prometheus_exporter/server/collector.rb +4 -0
  31. data/lib/prometheus_exporter/server/delayed_job_collector.rb +24 -18
  32. data/lib/prometheus_exporter/server/good_job_collector.rb +52 -0
  33. data/lib/prometheus_exporter/server/metrics_container.rb +66 -0
  34. data/lib/prometheus_exporter/server/process_collector.rb +8 -13
  35. data/lib/prometheus_exporter/server/puma_collector.rb +14 -12
  36. data/lib/prometheus_exporter/server/resque_collector.rb +50 -0
  37. data/lib/prometheus_exporter/server/runner.rb +14 -3
  38. data/lib/prometheus_exporter/server/sidekiq_collector.rb +1 -1
  39. data/lib/prometheus_exporter/server/sidekiq_process_collector.rb +43 -0
  40. data/lib/prometheus_exporter/server/sidekiq_queue_collector.rb +6 -7
  41. data/lib/prometheus_exporter/server/sidekiq_stats_collector.rb +48 -0
  42. data/lib/prometheus_exporter/server/type_collector.rb +2 -0
  43. data/lib/prometheus_exporter/server/unicorn_collector.rb +32 -33
  44. data/lib/prometheus_exporter/server/web_collector.rb +17 -17
  45. data/lib/prometheus_exporter/server/web_server.rb +72 -41
  46. data/lib/prometheus_exporter/server.rb +4 -0
  47. data/lib/prometheus_exporter/version.rb +1 -1
  48. data/lib/prometheus_exporter.rb +12 -13
  49. data/prometheus_exporter.gemspec +6 -6
  50. metadata +53 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f949348bbafc06b8f7a3dd3927693de8fef54090d85a7889afbfbf7dcb167b6
4
- data.tar.gz: adeca8000ebb59c7225c1453135900aeab5c1760902edd5b4fecf9fa4b879a57
3
+ metadata.gz: '042907307e8e1555111f34fb69d6cf66127e7742a76130952e3708a742ada24a'
4
+ data.tar.gz: 1e474618e9ddfa870a47e3ba7d7e55935677f3770d73968bb60457474b49502d
5
5
  SHA512:
6
- metadata.gz: 7d3829ad57f03a19f6081c3444f9b13906aedd4fa1c5b99237d454096e0d993c27c2df0993482c421b6034a58a55c9603620bcdf7698248e4ac23a5063d63718
7
- data.tar.gz: fb915716acbbb4f24a152c8ebf9eb35bdc97185a7144eb986e50aafad07a36d5cc83cbbbf7c16e8b399207e9c66d90973d2e6f9ddcdc8a17cab797840d13ed8b
6
+ metadata.gz: '0137930945e0b254dbf0d7245d696d782044bfee9dd255ff022ffadaddafb47cdefc1aa6f83927bc84866d87fee761027590c2f08fbe730496e7099e68a883b7'
7
+ data.tar.gz: 562691a91a7f4a0e380b92236f3295177481763393db7b0db9d8763f6ac631d317e6bd21bd3368471029742b8e649a1c2a3884fa2aafe93d280aa353909d9ecd
@@ -1,42 +1,99 @@
1
- name: Test Exporter
1
+ name: CI
2
2
 
3
3
  on:
4
4
  push:
5
+ branches:
6
+ - main
5
7
  pull_request:
6
8
  schedule:
7
- - cron: '0 0 * * 0' # weekly
9
+ - cron: "0 0 * * 0" # weekly
10
+
11
+ permissions:
12
+ contents: write
13
+ packages: write
14
+
15
+ env:
16
+ DOCKER_REPO: ghcr.io/discourse/prometheus_exporter
8
17
 
9
18
  jobs:
10
19
  build:
11
20
  runs-on: ubuntu-latest
12
- name: Ruby ${{ matrix.ruby }}
21
+ name: Ruby ${{ matrix.ruby }} AR ${{ matrix.activerecord }}
22
+ timeout-minutes: 10
23
+
24
+ env:
25
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/ar_${{ matrix.activerecord }}.gemfile
26
+
13
27
  strategy:
28
+ fail-fast: false
14
29
  matrix:
15
- ruby: ["2.7", "2.6", "2.5"]
30
+ ruby: ['3.0', '3.1', '3.2', '3.3']
31
+ activerecord: [60, 61, 70]
32
+
16
33
  steps:
17
- - uses: actions/checkout@master
18
- with:
19
- fetch-depth: 1
20
- - uses: actions/setup-ruby@v1
34
+ - uses: actions/checkout@v2
35
+
36
+ - uses: ruby/setup-ruby@v1
21
37
  with:
22
38
  ruby-version: ${{ matrix.ruby }}
23
- - uses: actions/cache@v2
24
- with:
25
- path: vendor/bundle
26
- key: ${{ runner.os }}-${{ matrix.ruby }}-gems-v2-${{ hashFiles('**/Gemfile.lock') }}
27
- restore-keys: |
28
- ${{ runner.os }}-${{ matrix.ruby }}-gems-v2-
29
- - name: Setup gems
30
- run: |
31
- gem install bundler
32
- # for Ruby <= 2.6 , details https://github.com/rubygems/rubygems/issues/3284
33
- gem update --system 3.0.8 && gem update --system
34
- bundle config path vendor/bundle
35
- bundle install --jobs 4
36
- bundle exec appraisal install
39
+ bundler-cache: true
40
+
37
41
  - name: Rubocop
38
42
  run: bundle exec rubocop
39
- - name: install gems
40
- run: bundle exec appraisal bundle
43
+
41
44
  - name: Run tests
42
- run: bundle exec appraisal rake
45
+ run: bundle exec rake
46
+
47
+ publish:
48
+ if: github.event_name == 'push' && github.ref == 'refs/heads/main'
49
+ needs: build
50
+ runs-on: ubuntu-latest
51
+
52
+ outputs:
53
+ new_version_published: ${{ steps.release.outputs.new_version_published }}
54
+
55
+ steps:
56
+ - uses: actions/checkout@v2
57
+
58
+ - name: Release gem
59
+ id: release
60
+ uses: discourse/publish-rubygems-action@v2
61
+ env:
62
+ RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
63
+ GIT_EMAIL: team@discourse.org
64
+ GIT_NAME: discoursebot
65
+
66
+ publish_docker:
67
+ needs: publish
68
+ if: needs.publish.outputs.new_version_published == 'true'
69
+ runs-on: ubuntu-latest
70
+ timeout-minutes: 20
71
+
72
+ steps:
73
+ - uses: actions/checkout@v3
74
+ - uses: docker/setup-qemu-action@v2
75
+ - uses: docker/setup-buildx-action@v2
76
+
77
+ - name: Set vars
78
+ id: vars
79
+ run: |
80
+ ruby -r ./lib/prometheus_exporter/version.rb -e 'print "version=#{PrometheusExporter::VERSION}"' >> $GITHUB_OUTPUT
81
+
82
+ - name: Login to Github Container Registry
83
+ uses: docker/login-action@v2
84
+ with:
85
+ registry: ghcr.io
86
+ username: ${{ github.actor }}
87
+ password: ${{ secrets.GITHUB_TOKEN }}
88
+
89
+ - name: Build and push images
90
+ uses: docker/build-push-action@v3
91
+ with:
92
+ context: .
93
+ push: true
94
+ platforms: linux/amd64,linux/arm64
95
+ build-args: |
96
+ GEM_VERSION=${{ steps.vars.outputs.version }}
97
+ tags: |
98
+ ${{ env.DOCKER_REPO }}:${{ steps.vars.outputs.version }}
99
+ ${{ env.DOCKER_REPO }}:latest
data/Appraisals CHANGED
@@ -1,10 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  appraise "ar-60" do
4
- # we are using this version as default in gemspec
5
- # gem "activerecord", "~> 6.0.0"
4
+ gem "activerecord", "~> 6.0.0"
6
5
  end
7
6
 
8
7
  appraise "ar-61" do
9
- gem "activerecord", "~> 6.1.0.rc2"
8
+ gem "activerecord", "~> 6.1.1"
9
+ end
10
+
11
+ appraise "ar-70" do
12
+ # latest version
13
+ gem "activerecord", "~> 7.1.2"
10
14
  end
data/CHANGELOG CHANGED
@@ -1,4 +1,84 @@
1
- 0.7.0 - 29-12-2020
1
+ 2.1.0 - 2024-08-01
2
+
3
+ - FEATURE: good_job instrumentation
4
+ - PERF: improve performance of histogram
5
+ - DEV: use new metric collector pattern so we reuse code between collectors
6
+
7
+ 2.0.8 - 2023-01-20
8
+
9
+ - FEATURE: attempting to make our first docker release
10
+
11
+ 2.0.7 - 2023-01-13
12
+
13
+ - FEATURE: allow binding server to both ipv4 and v6
14
+ - FIX: expire stale sidekiq metrics
15
+
16
+
17
+ 2.0.6 - 2022-11-22
18
+
19
+ - FIX: use user specified labels over default in merge conflict
20
+ - FIX: sidekiq stats collector memory leak
21
+
22
+ 2.0.5 - 2022-11-15
23
+
24
+ - FIX: regression :prepend style instrumentation not working correctly
25
+
26
+ 2.0.4 - 2022-11-10
27
+
28
+ - FIX/FEATURE: support for Redis 5 gem instrumentation
29
+
30
+ 2.0.3 - 2022-05-23
31
+
32
+ - FEATURE: new ping endpoint for keepalive checks
33
+ - FIX: order histogram correctly for GCP support
34
+ - FIX: improve sidekiq instrumentation
35
+
36
+ 2.0.2 - 2022-02-25
37
+
38
+ - FIX: runner was not requiring unicorn integration correctly leading to a crash
39
+
40
+ 2.0.1 - 2022-02-24
41
+
42
+ - FIX: ensure threads do not leak when calling #start repeatedly on instrumentation classes, this is an urgent patch for Puma integration
43
+
44
+ 2.0.0 - 2022-02-18
45
+
46
+ - FEATURE: Add per worker custom labels
47
+ - FEATURE: support custom histogram buckets
48
+ - FIX: all metrics are exposing status label, and not only `http_requests_total`
49
+ - BREAKING: rename all `http_duration` metrics to `http_request_duration` to match prometheus official naming conventions (See https://prometheus.io/docs/practices/naming/#metric-names).
50
+
51
+ 1.0.1 - 2021-12-22
52
+
53
+ - FEATURE: add labels to preflight requests
54
+ - FEATURE: SidekiqStats metrics
55
+ - FIX: mintor refactors to Sidekiq metrics
56
+
57
+ 1.0.0 - 2021-11-23
58
+
59
+ - BREAKING: rename metrics to match prometheus official naming conventions (See https://prometheus.io/docs/practices/naming/#metric-names)
60
+ - FEATURE: Sidekiq process metrics
61
+ - FEATURE: Allow collecting web metrics as histograms
62
+ - FIX: logger improved for web server
63
+ - FIX: Remove job labels from DelayedJob queues
64
+
65
+ 0.8.1 - 2021-08-04
66
+
67
+ - FEATURE: swap from hardcoded STDERR to logger pattern (see README for details)
68
+
69
+ 0.8.0 - 2021-07-05
70
+
71
+ - FIX: handle ThreadError more gracefully in cases where process shuts down
72
+ - FEATURE: add job_name and queue_name labels to delayed job metrics
73
+ - FEATURE: always scope puma metrics on hostname in collector
74
+ - FEATURE: add customizable labels option to puma collector
75
+ - FEATURE: support for Resque
76
+ - DEV: Remove support for EOL ruby 2.5
77
+ - FIX: Add source location to MethodProfiler patches
78
+ - FEATURE: Improve Active Record instrumentation
79
+ - FEATURE: Support HTTP_X_AMZN_TRACE_ID when supplied
80
+
81
+ 0.7.0 - 2020-12-29
2
82
 
3
83
  - Dev: Removed support from EOL rubies, only 2.5, 2.6, 2.7 and 3.0 are supported now.
4
84
  - Dev: Better support for Ruby 3.0, explicitly depending on webrick
@@ -6,111 +86,111 @@
6
86
  - FEATURE: clean pattern for overriding middleware labels was introduced (in README)
7
87
  - Fix: Better support for forking
8
88
 
9
- 0.6.0 - 17-11-2020
89
+ 0.6.0 - 2020-11-17
10
90
 
11
91
  - FEATURE: add support for basic-auth in the prometheus_exporter web server
12
92
 
13
- 0.5.3 - 29-07-2020
93
+ 0.5.3 - 2020-07-29
14
94
 
15
95
  - FEATURE: added #remove to all metric types so users can remove specific labels if needed
16
96
 
17
- 0.5.2 - 01-07-2020
97
+ 0.5.2 - 2020-07-01
18
98
 
19
99
  - FEATURE: expanded instrumentation for sidekiq
20
100
  - FEATURE: configurable default labels
21
101
 
22
- 0.5.1 - 25-02-2020
102
+ 0.5.1 - 2020-02-25
23
103
 
24
104
  - FEATURE: Allow configuring the default client's host and port via environment variables
25
105
 
26
- 0.5.0 - 14-02-2020
106
+ 0.5.0 - 2020-02-14
27
107
 
28
108
  - Breaking change: listen only to localhost by default to prevent unintended insecure configuration
29
109
  - FIX: Avoid calling `hostname` aggressively, instead cache it on the exporter instance
30
110
 
31
- 0.4.17 - 13-01-2020
111
+ 0.4.17 - 2020-01-13
32
112
 
33
113
  - FEATURE: add support for `to_h` on all metrics which can be used to query existing key/values
34
114
 
35
- 0.4.16 - 04-11-2019
115
+ 0.4.16 - 2019-11-04
36
116
 
37
117
  - FEATURE: Support #reset! on all metric types to reset a metric to default
38
118
 
39
- 0.4.15 - 04-11-2019
119
+ 0.4.15 - 2019-11-04
40
120
 
41
121
  - FEATURE: Improve delayed job collector, add pending counts
42
122
  - FEATURE: New ActiveRecord collector (documented in readme)
43
123
  - FEATURE: Allow passing in histogram and summary options
44
124
  - FEATURE: Allow custom labels for unicorn collector
45
125
 
46
- 0.4.14 - 10-09-2019
126
+ 0.4.14 - 2019-09-10
47
127
 
48
128
  - FEATURE: allow finding metrics by name RemoteMetric #find_registered_metric
49
129
  - FIX: guard socket closing
50
130
 
51
- 0.4.13 - 09-07-2019
131
+ 0.4.13 - 2019-07-09
52
132
 
53
133
  - Fix: Memory leak in unicorn and puma collectors
54
134
 
55
- 0.4.12 - 30-05-2019
135
+ 0.4.12 - 2019-05-30
56
136
 
57
137
  - Fix: unicorn collector reporting incorrect number of unicorn workers
58
138
 
59
- 0.4.11 - 15-05-2019
139
+ 0.4.11 - 2019-05-15
60
140
 
61
141
  - Fix: Handle stopping nil worker_threads in Client
62
142
  - Dev: add frozen string literals
63
143
 
64
- 0.4.10 - 29-04-2019
144
+ 0.4.10 - 2019-04-29
65
145
 
66
146
  - Fix: Custom label support for puma collector
67
147
  - Fix: Raindrops socket collector not working correctly
68
148
 
69
- 0.4.9 - 11-04-2019
149
+ 0.4.9 - 2019-04-11
70
150
 
71
151
  - Fix: Gem was not working correctly in Ruby 2.4 and below due to a syntax error
72
152
 
73
- 0.4.8 - 10-04-2019
153
+ 0.4.8 - 2019-04-10
74
154
 
75
155
  - Feature: added helpers for instrumenting unicorn using raindrops
76
156
 
77
- 0.4.7 - 08-04-2019
157
+ 0.4.7 - 2019-04-08
78
158
 
79
159
  - Fix: collector was not escaping " \ and \n correctly. This could lead
80
160
  to a corrupt payload in some cases.
81
161
 
82
- 0.4.6 - 02-04-2019
162
+ 0.4.6 - 2019-04-02
83
163
 
84
164
  - Feature: Allow resetting a counter
85
165
  - Feature: Add sidekiq metrics: restarted, dead jobs counters
86
166
  - Fix: Client shutting down before sending metrics to collector
87
167
 
88
- 0.4.5 - 14-02-2019
168
+ 0.4.5 - 2019-02-14
89
169
 
90
170
  - Feature: Allow process collector to ship custom labels for all process metrics
91
171
  - Fix: Always scope process metrics on hostname in collector
92
172
 
93
- 0.4.4 - 13-02-2019
173
+ 0.4.4 - 2019-02-13
94
174
 
95
175
  - Feature: add support for local metric collection without using HTTP
96
176
 
97
- 0.4.3 - 11-02-2019
177
+ 0.4.3 - 2019-02-11
98
178
 
99
179
  - Feature: Add alias for Gauge #observe called #set, this makes it a bit easier to migrate from prom
100
180
  - Feature: Add increment and decrement to Counter
101
181
 
102
- 0.4.2 - 30-11-2018
182
+ 0.4.2 - 2018-11-30
103
183
 
104
184
  - Fix/Feature: setting a Gauge to nil will remove Gauge (setting to non numeric will raise)
105
185
 
106
- 0.4.0 - 23-10-2018
186
+ 0.4.0 - 2018-10-23
107
187
 
108
188
  - Feature: histogram support
109
189
  - Feature: custom quantile support for summary
110
190
  - Feature: Puma metrics
111
191
  - Fix: delayed job metrics
112
192
 
113
- 0.3.4 - 02-10-2018
193
+ 0.3.4 - 2018-10-02
114
194
 
115
195
  - Fix: custom collector via CLI was not working correctly
116
196
 
data/Dockerfile ADDED
@@ -0,0 +1,9 @@
1
+ ARG RUBY_VERSION=3.1
2
+ ARG GEM_VERSION=
3
+
4
+ FROM ruby:${RUBY_VERSION}-slim
5
+
6
+ RUN gem install --no-doc --version=${GEM_VERSION} prometheus_exporter
7
+
8
+ EXPOSE 9394
9
+ ENTRYPOINT ["prometheus_exporter", "-b", "ANY"]