telegraf 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 132cb999b16a37b5dbb280da213c44c1a227165c0f28a4dcb568a42c6d149033
4
- data.tar.gz: 511605f1d7ed94572d4cce1431cc7c48c82b502154d19a1de63ec098b026c177
3
+ metadata.gz: b2ee7281b9a2894ca1b68ad84e14cf0ddaf1668d6203df4173438d8c137048c4
4
+ data.tar.gz: 87b415ca608c3c6d70495f1c7cc013a5720361d68d1baaf86b5366180891d92a
5
5
  SHA512:
6
- metadata.gz: 570b4cafae14dab8ed1d43072366c4df5a4e2ea37862e3643ebd96cc7f556f7a644c9aa60afb2ce7e3b00d1ec8bee78cd8c525390bcd30d64c310ac79769410e
7
- data.tar.gz: f595be285d5edaf4c84ba6ed97be15f6097ba747ea493f6f4fef5f15fa604f9a44392b7794c979da06751df081599cd06b3aee5ec54d328c0067e80e4e1320a2
6
+ metadata.gz: b5fb0d9e6572edee60f78b3ff9ed6e4345be20fd3440dfdcc5b7b983caaa74ef087014d10395aac65034aac071e7d65e886d3f49ac58e5bb50e69352e1e9199d
7
+ data.tar.gz: c38898a38963a56f148a43a05e9a29ae42072e434ed48c3e741ef2c834940cb2524ede03734ec66078b3c036b52a37f2dfc4059994fc29416e333bc943f14d63
@@ -1,26 +1,36 @@
1
+ # vim: ft=yaml
2
+ name: test
1
3
  on: [push, pull_request]
2
4
  jobs:
3
- test:
5
+ rspec:
4
6
  name: Ruby ${{ matrix.ruby }} / ${{ matrix.gemfile }}
5
7
  runs-on: ubuntu-20.04
6
8
 
7
9
  strategy:
8
10
  matrix:
9
11
  ruby:
10
- - '3.0'
11
- - '2.7'
12
- - '2.6'
13
- - '2.5'
12
+ - "3.1"
13
+ - "3.0"
14
+ - "2.7"
15
+ - "2.6"
16
+ - "2.5"
14
17
  gemfile:
15
18
  - rails_5.2.gemfile
16
19
  - rails_6.0.gemfile
17
20
  - rails_6.1.gemfile
21
+ - rails_7.0.gemfile
18
22
  - rack_2.0.gemfile
19
23
  - rack_2.1.gemfile
20
24
  - rack_2.2.gemfile
21
25
  exclude:
22
- - ruby: '3.0'
26
+ - ruby: "3.1"
23
27
  gemfile: rails_5.2.gemfile
28
+ - ruby: "3.0"
29
+ gemfile: rails_5.2.gemfile
30
+ - ruby: "2.6"
31
+ gemfile: rails_7.0.gemfile
32
+ - ruby: "2.5"
33
+ gemfile: rails_7.0.gemfile
24
34
  fail-fast: false
25
35
 
26
36
  env:
@@ -38,3 +48,21 @@ jobs:
38
48
  bundler-cache: true
39
49
 
40
50
  - run: bundle exec rspec --color --format documentation
51
+
52
+ rubocop:
53
+ name: rubocop
54
+ runs-on: ubuntu-20.04
55
+
56
+ env:
57
+ BUNDLE_WITHOUT: development
58
+ BUNDLE_JOBS: 4
59
+ BUNDLE_RETRY: 3
60
+
61
+ steps:
62
+ - uses: actions/checkout@master
63
+ - uses: ruby/setup-ruby@v1
64
+ with:
65
+ ruby-version: 3.0
66
+ bundler-cache: true
67
+
68
+ - run: bundle exec rubocop --parallel --color
data/.rubocop.yml CHANGED
@@ -1,75 +1,11 @@
1
- AllCops:
2
- Include:
3
- - "**/*.rb"
4
- NewCops: enable
5
- SuggestExtensions: false
6
- TargetRubyVersion: 2.5
7
-
8
-
9
- Layout/ArgumentAlignment:
10
- EnforcedStyle: with_fixed_indentation
11
-
12
- Layout/CaseIndentation:
13
- EnforcedStyle: end
14
- IndentOneStep: true
15
- SupportedStyles:
16
- - case
17
- - end
18
-
19
- Layout/FirstHashElementIndentation:
20
- EnforcedStyle: consistent
21
-
22
- Layout/LineLength:
23
- Exclude:
24
- - spec/**/*_spec.rb
25
-
26
- Layout/SpaceInsideBlockBraces:
27
- EnforcedStyle: space
28
- EnforcedStyleForEmptyBraces: no_space
29
- SpaceBeforeBlockParameters: false
30
-
31
- Layout/SpaceInsideHashLiteralBraces:
32
- EnforcedStyle: no_space
33
-
34
-
35
- Metrics/AbcSize:
36
- Enabled: false
37
-
38
- Metrics/BlockLength:
39
- Exclude:
40
- - spec/**/*_spec.rb
1
+ # vim: ft=yaml
41
2
 
42
- Metrics/MethodLength:
43
- Enabled: false
3
+ inherit_gem:
4
+ my-rubocop: default.yml
44
5
 
6
+ AllCops:
7
+ TargetRubyVersion: 2.5
8
+ SuggestExtensions: False
45
9
 
46
- Naming/FileName:
47
- Exclude:
48
- - Rakefile
49
- - Gemfile
50
-
51
-
52
- Style/ClassAndModuleChildren:
53
- Enabled: false
54
-
55
- Style/Documentation:
56
- Enabled: false
57
-
58
- Style/HashEachMethods:
59
- Enabled: false
60
-
61
- Style/HashTransformKeys:
62
- Enabled: false
63
-
64
- Style/HashTransformValues:
65
- Enabled: false
66
-
67
- Style/IfUnlessModifier:
68
- Enabled: false
69
-
70
- Style/RescueModifier:
71
- Exclude:
72
- - spec/**/*_spec.rb
73
-
74
- Style/TrivialAccessors:
75
- AllowPredicates: true
10
+ RSpec/FilePath:
11
+ Enabled: False
data/Appraisals CHANGED
@@ -18,6 +18,12 @@ appraise 'rails-6.1' do
18
18
  end
19
19
  end
20
20
 
21
+ appraise 'rails-7.0' do
22
+ group :test do
23
+ gem 'rails', '~> 7.0.0'
24
+ end
25
+ end
26
+
21
27
  appraise 'rack-2.0' do
22
28
  group :test do
23
29
  gem 'rack', '~> 2.0.0'
data/CHANGELOG.md CHANGED
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [2.1.0] - 2022-01-24
10
+ ### Added
11
+ - Support for Rails 7.0 and Ruby 3.1
12
+ - Grape API instrumentation (#17)
13
+
9
14
  ## [2.0.0] - 2021-09-30
10
15
  ### Changed
11
16
  - The sidekiq middleware does not use keyword arguments as sidekiq does not handle them correctly on Ruby 3.0 (#14)
@@ -34,7 +39,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
34
39
  ### Changed
35
40
  - Remove `influxdb` not unnecessarily restrict users needing a specific influxdb client.
36
41
 
37
- [Unreleased]: https://github.com/jgraichen/telegraf-ruby/compare/v2.0.0...HEAD
42
+ [Unreleased]: https://github.com/jgraichen/telegraf-ruby/compare/v2.1.0...HEAD
43
+ [2.1.0]: https://github.com/jgraichen/telegraf-ruby/compare/v2.0.0...v2.1.0
38
44
  [2.0.0]: https://github.com/jgraichen/telegraf-ruby/compare/v1.0.0...v2.0.0
39
45
  [1.0.0]: https://github.com/jgraichen/telegraf-ruby/compare/v0.8.0...v1.0.0
40
46
  [0.8.0]: https://github.com/jgraichen/telegraf-ruby/compare/v0.7.0...v0.8.0
data/Gemfile CHANGED
@@ -5,10 +5,9 @@ source 'https://rubygems.org'
5
5
  # Specify your gem's dependencies in telegraf.gemspec
6
6
  gemspec
7
7
 
8
+ gem 'my-rubocop', github: 'jgraichen/my-rubocop', ref: 'v6'
8
9
  gem 'rake'
9
10
  gem 'rspec', '~> 3.8'
10
- gem 'rubocop', '~> 1.7'
11
- gem 'rubocop-rspec', '~> 1.41'
12
11
 
13
12
  group :test do
14
13
  gem 'rack'
@@ -0,0 +1,21 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake"
6
+ gem "rspec", "~> 3.8"
7
+ gem "rubocop", "~> 1.7"
8
+ gem "rubocop-rspec", "~> 1.41"
9
+
10
+ group :test do
11
+ gem "rack"
12
+ gem "rails", "~> 7.0.0"
13
+ gem "sidekiq", "~> 6.0"
14
+ end
15
+
16
+ group :development do
17
+ gem "appraisal"
18
+ gem "rake-release", "~> 1.2"
19
+ end
20
+
21
+ gemspec path: "../"
@@ -39,11 +39,11 @@ module Telegraf
39
39
  **@tags,
40
40
  job: job.class.name,
41
41
  queue: job.queue_name,
42
- errors: payload.key?(:exception_object)
42
+ errors: payload.key?(:exception_object),
43
43
  },
44
44
  values: {
45
- app_ms: ((finish - start) * 1000.0) # milliseconds
46
- }
45
+ app_ms: ((finish - start) * 1000.0), # milliseconds
46
+ },
47
47
  )
48
48
  end
49
49
  end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegraf
4
+ # Telegraf::Grape
5
+ #
6
+ # This class extends requests metrics with details for Grape API endpoints.
7
+ #
8
+ #
9
+ # Tags:
10
+ #
11
+ # * `controller`:
12
+ # The Grape endpoint class.
13
+ #
14
+ # * `instance`:
15
+ # The Grape endpoint class.
16
+ #
17
+ # * `format`:
18
+ # Grape's internal identifier for the response format.
19
+ #
20
+ class Grape
21
+ def call(_name, _start, _finish, _id, payload)
22
+ point = payload[:env][::Telegraf::Rack::FIELD_NAME]
23
+ return unless point
24
+
25
+ endpoint = payload[:endpoint]
26
+ return unless endpoint
27
+
28
+ point.tags[:controller] = endpoint.options[:for].to_s
29
+ point.tags[:instance] = point.tags[:controller]
30
+ point.tags[:format] = payload[:env]['api.format']
31
+ end
32
+ end
33
+ end
@@ -3,6 +3,7 @@
3
3
  require 'rails'
4
4
  require 'telegraf'
5
5
  require 'telegraf/active_job'
6
+ require 'telegraf/grape'
6
7
  require 'telegraf/rack'
7
8
  require 'telegraf/sidekiq'
8
9
 
@@ -57,6 +58,10 @@ module Telegraf
57
58
  # Install request instrumentation
58
59
  config.telegraf.instrumentation = true
59
60
 
61
+ # Install Grape instrumentation
62
+ config.telegraf.grape = ::ActiveSupport::OrderedOptions.new
63
+ config.telegraf.grape.enabled = defined?(::Grape)
64
+
60
65
  # Install ActiveJob instrumentation
61
66
  config.telegraf.active_job = ::ActiveSupport::OrderedOptions.new
62
67
  config.telegraf.active_job.enabled = defined?(::ActiveJob)
@@ -91,7 +96,7 @@ module Telegraf
91
96
  next unless app.config.telegraf.instrumentation
92
97
 
93
98
  ActiveSupport::Notifications.subscribe(
94
- 'process_action.action_controller'
99
+ 'process_action.action_controller',
95
100
  ) do |_name, start, finish, _id, payload|
96
101
  point = payload[:headers].env[::Telegraf::Rack::FIELD_NAME]
97
102
  next unless point
@@ -107,6 +112,15 @@ module Telegraf
107
112
  end
108
113
  end
109
114
 
115
+ initializer 'telegraf.grape' do |app|
116
+ next unless app.config.telegraf.grape.enabled
117
+
118
+ ActiveSupport::Notifications.subscribe(
119
+ 'endpoint_run.grape',
120
+ Telegraf::Grape.new,
121
+ )
122
+ end
123
+
110
124
  initializer 'telegraf.active_job' do |app|
111
125
  next unless app.config.telegraf.active_job.enabled
112
126
 
@@ -115,8 +129,8 @@ module Telegraf
115
129
  Telegraf::ActiveJob.new(
116
130
  agent: app.config.telegraf.agent,
117
131
  series: app.config.telegraf.active_job.series,
118
- tags: app.config.telegraf.active_job.tags
119
- )
132
+ tags: app.config.telegraf.active_job.tags,
133
+ ),
120
134
  )
121
135
  end
122
136
 
@@ -129,7 +143,7 @@ module Telegraf
129
143
  app.config.telegraf.agent,
130
144
  {
131
145
  series: app.config.telegraf.sidekiq.series,
132
- tags: app.config.telegraf.sidekiq.tags
146
+ tags: app.config.telegraf.sidekiq.tags,
133
147
  }
134
148
  end
135
149
  end
@@ -52,11 +52,11 @@ module Telegraf
52
52
  errors: true,
53
53
  retry: job.key?('retried_at'),
54
54
  queue: queue,
55
- worker: worker.class.name
55
+ worker: worker.class.name,
56
56
  }
57
57
 
58
58
  values = {
59
- retry_count: job['retry_count']
59
+ retry_count: job['retry_count'],
60
60
  }.compact
61
61
 
62
62
  # The "enqueued_at" key is not present for scheduled jobs.
@@ -80,7 +80,7 @@ module Telegraf
80
80
  values[:app_ms] = (job_stop - job_start) * 1000 # milliseconds
81
81
 
82
82
  @agent.write(
83
- @series, tags: tags, values: values
83
+ @series, tags: tags, values: values,
84
84
  )
85
85
  end
86
86
  end
@@ -3,10 +3,10 @@
3
3
  module Telegraf
4
4
  module VERSION
5
5
  MAJOR = 2
6
- MINOR = 0
6
+ MINOR = 1
7
7
  PATCH = 0
8
8
  STAGE = nil
9
- STRING = [MAJOR, MINOR, PATCH, STAGE].reject(&:nil?).join('.').freeze
9
+ STRING = [MAJOR, MINOR, PATCH, STAGE].compact.join('.').freeze
10
10
 
11
11
  def self.to_s
12
12
  STRING
data/telegraf.gemspec CHANGED
@@ -1,7 +1,6 @@
1
- # coding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
- lib = File.expand_path('../lib', __FILE__)
3
+ lib = File.expand_path('lib', __dir__)
5
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
5
  require 'telegraf/version'
7
6
 
@@ -16,6 +15,10 @@ Gem::Specification.new do |spec|
16
15
  spec.homepage = 'https://github.com/jgraichen/telegraf-ruby'
17
16
  spec.license = 'LGPLv3'
18
17
 
18
+ spec.metadata = {
19
+ 'rubygems_mfa_required' => 'true',
20
+ }
21
+
19
22
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
20
23
  f.match(%r{^(test|spec|features)/})
21
24
  end
@@ -24,7 +27,7 @@ Gem::Specification.new do |spec|
24
27
  spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f) }
25
28
  spec.require_paths = ['lib']
26
29
 
30
+ spec.required_ruby_version = '>= 2.5'
27
31
  spec.add_dependency 'influxdb'
28
-
29
32
  spec.add_development_dependency 'bundler'
30
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telegraf
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-30 00:00:00.000000000 Z
11
+ date: 2022-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: influxdb
@@ -46,7 +46,6 @@ extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
48
  - ".editorconfig"
49
- - ".github/workflows/lint.yml"
50
49
  - ".github/workflows/test.yml"
51
50
  - ".gitignore"
52
51
  - ".rspec"
@@ -65,9 +64,11 @@ files:
65
64
  - gemfiles/rails_5.2.gemfile
66
65
  - gemfiles/rails_6.0.gemfile
67
66
  - gemfiles/rails_6.1.gemfile
67
+ - gemfiles/rails_7.0.gemfile
68
68
  - lib/telegraf.rb
69
69
  - lib/telegraf/active_job.rb
70
70
  - lib/telegraf/agent.rb
71
+ - lib/telegraf/grape.rb
71
72
  - lib/telegraf/rack.rb
72
73
  - lib/telegraf/rails.rb
73
74
  - lib/telegraf/railtie.rb
@@ -77,7 +78,8 @@ files:
77
78
  homepage: https://github.com/jgraichen/telegraf-ruby
78
79
  licenses:
79
80
  - LGPLv3
80
- metadata: {}
81
+ metadata:
82
+ rubygems_mfa_required: 'true'
81
83
  post_install_message:
82
84
  rdoc_options: []
83
85
  require_paths:
@@ -86,14 +88,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
86
88
  requirements:
87
89
  - - ">="
88
90
  - !ruby/object:Gem::Version
89
- version: '0'
91
+ version: '2.5'
90
92
  required_rubygems_version: !ruby/object:Gem::Requirement
91
93
  requirements:
92
94
  - - ">="
93
95
  - !ruby/object:Gem::Version
94
96
  version: '0'
95
97
  requirements: []
96
- rubygems_version: 3.2.22
98
+ rubygems_version: 3.1.6
97
99
  signing_key:
98
100
  specification_version: 4
99
101
  summary: Metric Reporter to local telegraf agent
@@ -1,19 +0,0 @@
1
- on: [push, pull_request]
2
- jobs:
3
- rubocop:
4
- name: rubocop
5
- runs-on: ubuntu-20.04
6
-
7
- env:
8
- BUNDLE_WITHOUT: development
9
- BUNDLE_JOBS: 4
10
- BUNDLE_RETRY: 3
11
-
12
- steps:
13
- - uses: actions/checkout@master
14
- - uses: ruby/setup-ruby@v1
15
- with:
16
- ruby-version: 3.0
17
- bundler-cache: true
18
-
19
- - run: bundle exec rubocop --parallel --color