dry-monitor 0.3.1 → 0.3.2

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: 34309d32f94041d825568804c30507d69178437c5b433f6aa9628338dd09ad3a
4
- data.tar.gz: efbf86392a682aaf4685631c407f8dd92adea9cc151522fa88de139362d7372a
3
+ metadata.gz: 85738f938dcede38fc7ce87e0370b28d6007a4bc623add02b36266c92436ddc4
4
+ data.tar.gz: ff09a85ea8d421a6af32c711d2c84a62164f868462b2676cb5b644af6b5a4dcb
5
5
  SHA512:
6
- metadata.gz: cf0da9d876fb8fa59b324f0f9c268860e089f2b630af6e4d4ba4e59da732404fa298832f50a9f61a1052c32562748834ebd8526e97bf8eb68a7e6016caf27446
7
- data.tar.gz: 05a53f3834257a284e598027bc653a38cfc09bb421fce97c639a74210b19f2d966f170778e47e0990b3b6632743b927e9b1a768baa03a73a950d080ee62c4574
6
+ metadata.gz: 57421c674b4a278f86ec556e84f09778400e30767cce50f5190dc0ddc1403f9c9cbb570fb45b7a481f2aecce325c52cc67f6ba0bdec55a8d58c92354845a1f3e
7
+ data.tar.gz: 3cd559b457cab3d252875a9464b9cc24d96e486f56f4ae31c50e1003aa81d7d63306ee77daa33116bf780c70a138f3c6b092b3796de9ed5e02bde7c5bc822c58
@@ -1,68 +1,109 @@
1
- # v0.3.1 2019-06-18
1
+ ## 0.3.2 2020-04-09
2
+
3
+
4
+ ### Fixed
5
+
6
+ - Ensure `Dry::Monitor::Rack::Middleware` is compatible with `Rack::Builder#use` (@jodosha)
7
+
8
+ ### Changed
9
+
10
+ - Performance improvements (@davydovanton)
11
+ - Dependency on `dry-events` was bumped to `~> 0.5` (@davydovanton)
12
+
13
+ [Compare v0.3.1...v0.3.2](https://github.com/dry-rb/dry-monitor/compare/v0.3.1...v0.3.2)
14
+
15
+ ## 0.3.1 2019-06-18
16
+
2
17
 
3
18
  ### Fixed
4
19
 
5
- * Uninitialized constant `Dry::Monitor::Notifications::EMPTY_HASH` when no payload given (@mensfeld)
20
+ - Uninitialized constant `Dry::Monitor::Notifications::EMPTY_HASH` when no payload given (@mensfeld)
21
+
22
+
23
+ [Compare v0.3.0...v0.3.1](https://github.com/dry-rb/dry-monitor/compare/v0.3.0...v0.3.1)
24
+
25
+ ## 0.3.0 2019-01-29
6
26
 
7
- # v0.3.0 2019-01-29
8
27
 
9
28
  ### Fixed
10
29
 
11
- * cannot load such file -- rack/utils (mensfeld)
30
+ - cannot load such file -- rack/utils (mensfeld)
12
31
 
13
32
  ### Changed
14
33
 
15
- * Make `rack` logger into a plugin (mensfeld)
16
- * Make `sql` logger into a plugin (mensfeld)
34
+ - Make `rack` logger into a plugin (mensfeld)
35
+ - Make `sql` logger into a plugin (mensfeld)
36
+
37
+ [Compare v0.2.0...v0.3.0](https://github.com/dry-rb/dry-monitor/compare/v0.2.0...v0.3.0)
38
+
39
+ ## 0.2.0 2018-01-21
17
40
 
18
- # v0.2.0 2018-01-21
19
41
 
20
42
  ### Changed
21
43
 
22
- * Make `rouge` an optional dependency (davydovanton & mensfeld)
44
+ - Make `rouge` an optional dependency (davydovanton & mensfeld)
45
+
46
+ [Compare v0.1.2...v0.2.0](https://github.com/dry-rb/dry-monitor/compare/v0.1.2...v0.2.0)
47
+
48
+ ## 0.1.2 2018-01-04
23
49
 
24
- # v0.1.2 2018-01-04
25
50
 
26
51
  ### Fixed
27
52
 
28
- * Rack logger no longer prevents arbitrary payload in `:error` events (solnic)
53
+ - Rack logger no longer prevents arbitrary payload in `:error` events (solnic)
54
+
55
+
56
+ [Compare v0.1.1...v0.1.2](https://github.com/dry-rb/dry-monitor/compare/v0.1.1...v0.1.2)
57
+
58
+ ## 0.1.1 2018-01-03
29
59
 
30
- # v0.1.1 2018-01-03
31
60
 
32
61
  ### Fixed
33
62
 
34
- * Query params containing arrays of primitives (e.g. `?ids[]=1&ids[]=2`) no longer crash the logger (timriley)
63
+ - Query params containing arrays of primitives (e.g. `?ids[]=1&ids[]=2`) no longer crash the logger (timriley)
64
+
65
+
66
+ [Compare v0.1.0...v0.1.1](https://github.com/dry-rb/dry-monitor/compare/v0.1.0...v0.1.1)
67
+
68
+ ## 0.1.0 2018-01-02
35
69
 
36
- # v0.1.0 2018-01-02
37
70
 
38
71
  ### Fixed
39
72
 
40
- * Query params are logged correctly via rack middleware (solnic)
73
+ - Query params are logged correctly via rack middleware (solnic)
41
74
 
42
75
  ### Changed
43
76
 
44
- * Uses `dry-events` for notifications (solnic)
77
+ - Uses `dry-events` for notifications (solnic)
78
+
79
+ [Compare v0.0.3...v0.1.0](https://github.com/dry-rb/dry-monitor/compare/v0.0.3...v0.1.0)
80
+
81
+ ## 0.0.3 2017-08-28
45
82
 
46
- # v0.0.3 2017-08-28
47
83
 
48
84
  ### Changed
49
85
 
50
- * Update default theme setting for compatibility with latest version of rouge (alexandru-calinoiu)
51
- * Require latest version of rouge gem (timriley)
86
+ - Update default theme setting for compatibility with latest version of rouge (alexandru-calinoiu)
87
+ - Require latest version of rouge gem (timriley)
88
+
89
+ [Compare v0.0.2...v0.0.3](https://github.com/dry-rb/dry-monitor/compare/v0.0.2...v0.0.3)
90
+
91
+ ## 0.0.2 2017-02-02
52
92
 
53
- # v0.0.2 2017-02-02
54
93
 
55
94
  ### Added
56
95
 
57
- * `Dry::Monitor::Rack::Middleware#on` shortcut (solnic)
58
- * `Dry::Monitor::Rack::Middleware#instrument` shortcut (solnic)
59
- * `Dry::Monitor::SQL::Logger` can be configured with a custom message template (solnic)
96
+ - `Dry::Monitor::Rack::Middleware#on` shortcut (solnic)
97
+ - `Dry::Monitor::Rack::Middleware#instrument` shortcut (solnic)
98
+ - `Dry::Monitor::SQL::Logger` can be configured with a custom message template (solnic)
60
99
 
61
100
  ### Changed
62
101
 
63
- * `Dry::Monitor::Rack::Logger#{subscribe=>attach}` and now it accepts a rack middleware instance (solnic)
64
- * `Dry::Monitor::Rack::Logger` appends new lines when logging `:rack.request.stop` events (solnic)
102
+ - `Dry::Monitor::Rack::Logger#{subscribe=>attach}` and now it accepts a rack middleware instance (solnic)
103
+ - `Dry::Monitor::Rack::Logger` appends new lines when logging `:rack.request.stop` events (solnic)
104
+
105
+ [Compare v0.0.1...v0.0.2](https://github.com/dry-rb/dry-monitor/compare/v0.0.1...v0.0.2)
65
106
 
66
- # v0.0.1 2017-02-01
107
+ ## 0.0.1 2017-02-01
67
108
 
68
109
  First public release
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2014 Ruby Object Mapper
3
+ Copyright (c) 2015-2020 dry-rb team
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
data/README.md CHANGED
@@ -1,23 +1,28 @@
1
1
  [gem]: https://rubygems.org/gems/dry-monitor
2
- [travis]: https://travis-ci.org/dry-rb/dry-monitor
3
- [codeclimate]: https://codeclimate.com/github/dry-rb/dry-monitor
4
- [coveralls]: https://coveralls.io/r/dry-rb/dry-monitor
2
+ [actions]: https://github.com/dry-rb/dry-monitor/actions
3
+ [codacy]: https://www.codacy.com/gh/dry-rb/dry-monitor
4
+ [chat]: https://dry-rb.zulipchat.com
5
5
  [inchpages]: http://inch-ci.org/github/dry-rb/dry-monitor
6
6
 
7
- # dry-monitor [![Join the chat at https://gitter.im/dry-rb/chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/dry-rb/chat)
7
+ # dry-monitor [![Join the chat at https://dry-rb.zulipchat.com](https://img.shields.io/badge/dry--rb-join%20chat-%23346b7a.svg)][chat]
8
8
 
9
9
  [![Gem Version](https://badge.fury.io/rb/dry-monitor.svg)][gem]
10
- [![Build Status](https://travis-ci.org/dry-rb/dry-monitor.svg?branch=master)][travis]
11
- [![Code Climate](https://codeclimate.com/github/dry-rb/dry-monitor/badges/gpa.svg)][codeclimate]
12
- [![Test Coverage](https://codeclimate.com/github/dry-rb/dry-monitor/badges/coverage.svg)][codeclimate]
10
+ [![CI Status](https://github.com/dry-rb/dry-monitor/workflows/ci/badge.svg)][actions]
11
+ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/984c4274e56d423a818e7a1bf5e963d0)][codacy]
12
+ [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/984c4274e56d423a818e7a1bf5e963d0)][codacy]
13
13
  [![Inline docs](http://inch-ci.org/github/dry-rb/dry-monitor.svg?branch=master)][inchpages]
14
14
 
15
- Monitoring and instrumentation APIs.
15
+ ## Links
16
16
 
17
- ## Synopsis
17
+ * [User documentation](http://dry-rb.org/gems/dry-monitor)
18
+ * [API documentation](http://rubydoc.info/gems/dry-monitor)
18
19
 
19
- ``` ruby
20
- ```
20
+ ## Supported Ruby versions
21
+
22
+ This library officially supports the following Ruby versions:
23
+
24
+ * MRI >= `2.4`
25
+ * jruby >= `9.2`
21
26
 
22
27
  ## License
23
28
 
@@ -1,28 +1,40 @@
1
1
  # frozen_string_literal: true
2
+ # this file is managed by dry-rb/devtools project
2
3
 
3
- require File.expand_path('lib/dry/monitor/version', __dir__)
4
+ lib = File.expand_path('lib', __dir__)
5
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
+ require 'dry/monitor/version'
4
7
 
5
8
  Gem::Specification.new do |spec|
6
9
  spec.name = 'dry-monitor'
7
- spec.version = Dry::Monitor::VERSION
8
- spec.authors = ['Piotr Solnica']
9
- spec.email = ['piotr.solnica@gmail.com']
10
- spec.summary = 'Monitoring and instrumentation APIs'
11
- spec.homepage = 'https://github.com/dry-rb/dry-monitor'
10
+ spec.authors = ["Piotr Solnica"]
11
+ spec.email = ["piotr.solnica@gmail.com"]
12
12
  spec.license = 'MIT'
13
+ spec.version = Dry::Monitor::VERSION.dup
13
14
 
14
- spec.files = `git ls-files -z`.split("\x0")
15
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
+ spec.summary = "Monitoring and instrumentation APIs"
16
+ spec.description = spec.summary
17
+ spec.homepage = 'https://dry-rb.org/gems/dry-monitor'
18
+ spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "dry-monitor.gemspec", "lib/**/*"]
19
+ spec.bindir = 'bin'
20
+ spec.executables = []
17
21
  spec.require_paths = ['lib']
18
22
 
19
- spec.add_runtime_dependency 'dry-configurable', '~> 0.5'
20
- spec.add_runtime_dependency 'dry-core', '~> 0.4'
21
- spec.add_runtime_dependency 'dry-equalizer', '~> 0.2'
22
- spec.add_runtime_dependency 'dry-events', '~> 0.1'
23
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
24
+ spec.metadata['changelog_uri'] = 'https://github.com/dry-rb/dry-monitor/blob/master/CHANGELOG.md'
25
+ spec.metadata['source_code_uri'] = 'https://github.com/dry-rb/dry-monitor'
26
+ spec.metadata['bug_tracker_uri'] = 'https://github.com/dry-rb/dry-monitor/issues'
23
27
 
24
- spec.add_development_dependency 'bundler'
25
- spec.add_development_dependency 'rake'
26
- spec.add_development_dependency 'rouge', '~> 2.0', '>= 2.2.1'
27
- spec.add_development_dependency 'rspec'
28
+ spec.required_ruby_version = ">= 2.4.0"
29
+
30
+ # to update dependencies edit project.yml
31
+ spec.add_runtime_dependency "dry-configurable", "~> 0.5"
32
+ spec.add_runtime_dependency "dry-core", "~> 0.4"
33
+ spec.add_runtime_dependency "dry-equalizer", "~> 0.2"
34
+ spec.add_runtime_dependency "dry-events", "~> 0.2"
35
+
36
+ spec.add_development_dependency "bundler"
37
+ spec.add_development_dependency "rake"
38
+ spec.add_development_dependency "rouge", "~> 2.0", ">= 2.2.1"
39
+ spec.add_development_dependency "rspec"
28
40
  end
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/monitor'
3
+ require "dry/monitor"
@@ -1,20 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/monitor/logger'
4
- require 'dry/monitor/notifications'
5
- require 'dry/core/extensions'
3
+ require "dry/monitor/logger"
4
+ require "dry/monitor/notifications"
5
+ require "dry/core/extensions"
6
6
 
7
7
  module Dry
8
8
  module Monitor
9
9
  extend Dry::Core::Extensions
10
10
 
11
11
  register_extension(:rack) do
12
- require 'rack/utils'
13
- require 'dry/monitor/rack/logger'
12
+ require "rack/utils"
13
+ require "dry/monitor/rack/logger"
14
14
  end
15
15
 
16
16
  register_extension(:sql) do
17
- require 'dry/monitor/sql/logger'
17
+ require "dry/monitor/sql/logger"
18
18
  end
19
19
  end
20
20
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/core/constants'
3
+ require "dry/core/constants"
4
4
 
5
5
  module Dry
6
6
  module Monitor
@@ -1,15 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'logger'
3
+ require "logger"
4
4
 
5
5
  module Dry
6
6
  module Monitor
7
7
  class Logger < ::Logger
8
+ DEFAULT_FORMATTER = proc do |_severity, _datetime, _progname, msg|
9
+ "#{msg}\n"
10
+ end
11
+
8
12
  def initialize(*args)
9
13
  super
10
- self.formatter = proc do |_severity, _datetime, _progname, msg|
11
- "#{msg}\n"
12
- end
14
+ self.formatter = DEFAULT_FORMATTER
13
15
  end
14
16
  end
15
17
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/events/publisher'
4
- require 'dry/monitor/constants'
3
+ require "dry/events/publisher"
4
+ require "dry/monitor/constants"
5
5
 
6
6
  module Dry
7
7
  module Monitor
@@ -20,7 +20,7 @@ module Dry
20
20
  CLOCK = Clock.new
21
21
 
22
22
  class Notifications
23
- include Events::Publisher['Dry::Monitor::Notifications']
23
+ include Events::Publisher["Dry::Monitor::Notifications"]
24
24
 
25
25
  attr_reader :id
26
26
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/configurable'
4
- require 'dry/monitor/rack/middleware'
3
+ require "dry/configurable"
4
+ require "dry/monitor/rack/middleware"
5
5
 
6
6
  module Dry
7
7
  module Monitor
@@ -11,15 +11,15 @@ module Dry
11
11
 
12
12
  setting :filtered_params, %w[_csrf password]
13
13
 
14
- REQUEST_METHOD = 'REQUEST_METHOD'
15
- PATH_INFO = 'PATH_INFO'
16
- REMOTE_ADDR = 'REMOTE_ADDR'
17
- QUERY_STRING = 'QUERY_STRING'
14
+ REQUEST_METHOD = "REQUEST_METHOD"
15
+ PATH_INFO = "PATH_INFO"
16
+ REMOTE_ADDR = "REMOTE_ADDR"
17
+ QUERY_STRING = "QUERY_STRING"
18
18
 
19
19
  START_MSG = %(Started %s "%s" for %s at %s)
20
20
  STOP_MSG = %(Finished %s "%s" for %s in %sms [Status: %s]\n)
21
- QUERY_MSG = %( Query parameters %s)
22
- FILTERED = '[FILTERED]'
21
+ QUERY_MSG = %( Query parameters )
22
+ FILTERED = "[FILTERED]"
23
23
 
24
24
  attr_reader :logger
25
25
 
@@ -50,7 +50,7 @@ module Dry
50
50
  end
51
51
 
52
52
  def log_start_request(request)
53
- info START_MSG % [
53
+ logger.info START_MSG % [
54
54
  request[REQUEST_METHOD],
55
55
  request[PATH_INFO],
56
56
  request[REMOTE_ADDR],
@@ -60,7 +60,7 @@ module Dry
60
60
  end
61
61
 
62
62
  def log_stop_request(request, status, time)
63
- info STOP_MSG % [
63
+ logger.info STOP_MSG % [
64
64
  request[REQUEST_METHOD],
65
65
  request[PATH_INFO],
66
66
  request[REMOTE_ADDR],
@@ -71,7 +71,7 @@ module Dry
71
71
 
72
72
  def log_request_params(request)
73
73
  with_http_params(request[QUERY_STRING]) do |params|
74
- info QUERY_MSG % [params.inspect]
74
+ logger.info QUERY_MSG + params.inspect
75
75
  end
76
76
  end
77
77
 
@@ -87,21 +87,21 @@ module Dry
87
87
 
88
88
  def filter_backtrace(backtrace)
89
89
  # TODO: what do we want to do with this?
90
- backtrace.reject { |l| l.include?('gems') }
90
+ backtrace.reject { |l| l.include?("gems") }
91
91
  end
92
92
 
93
93
  def filter_params(params)
94
- params.each_with_object({}) do |(k, v), h|
94
+ params.each do |k, v|
95
95
  if config.filtered_params.include?(k)
96
- h.update(k => FILTERED)
96
+ params[k] = FILTERED
97
97
  elsif v.is_a?(Hash)
98
- h.update(k => filter_params(v))
98
+ filter_params(v)
99
99
  elsif v.is_a?(Array)
100
- h.update(k => v.map { |m| m.is_a?(Hash) ? filter_params(m) : m })
101
- else
102
- h[k] = v
100
+ v.map! { |m| m.is_a?(Hash) ? filter_params(m) : m }
103
101
  end
104
102
  end
103
+
104
+ params
105
105
  end
106
106
  end
107
107
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/monitor/notifications'
3
+ require "dry/monitor/notifications"
4
4
 
5
5
  module Dry
6
6
  module Monitor
@@ -22,7 +22,7 @@ module Dry
22
22
  @notifications, @app = *args
23
23
  end
24
24
 
25
- def new(app)
25
+ def new(app, *_args, &_block)
26
26
  self.class.new(notifications, app)
27
27
  end
28
28
 
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rouge/util'
4
- require 'rouge/token'
5
- require 'rouge/theme'
6
- require 'rouge/themes/gruvbox'
7
- require 'rouge/formatter'
8
- require 'rouge/formatters/terminal256'
9
- require 'rouge/lexer'
10
- require 'rouge/regex_lexer'
11
- require 'rouge/lexers/sql'
3
+ require "rouge/util"
4
+ require "rouge/token"
5
+ require "rouge/theme"
6
+ require "rouge/themes/gruvbox"
7
+ require "rouge/formatter"
8
+ require "rouge/formatters/terminal256"
9
+ require "rouge/lexer"
10
+ require "rouge/regex_lexer"
11
+ require "rouge/lexers/sql"
12
12
 
13
13
  module Dry
14
14
  module Monitor
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry-configurable'
4
- require 'dry/core/extensions'
5
- require 'dry/monitor/notifications'
3
+ require "dry-configurable"
4
+ require "dry/core/extensions"
5
+ require "dry/monitor/notifications"
6
6
 
7
7
  module Dry
8
8
  module Monitor
@@ -14,19 +14,27 @@ module Dry
14
14
  extend Dry::Configurable
15
15
 
16
16
  register_extension(:default_colorizer) do
17
- require_relative './colorizers/default'
17
+ require_relative "./colorizers/default"
18
18
 
19
- def colorizer
20
- @colorizer ||= Colorizers::Default.new(config.theme)
19
+ module DefaultColorizer
20
+ def colorizer
21
+ @colorizer ||= Colorizers::Default.new(config.theme)
22
+ end
21
23
  end
24
+
25
+ Logger.include(DefaultColorizer)
22
26
  end
23
27
 
24
28
  register_extension(:rouge_colorizer) do
25
- require_relative './colorizers/rouge'
29
+ require_relative "./colorizers/rouge"
26
30
 
27
- def colorizer
28
- @colorizer ||= Colorizers::Rouge.new(config.theme)
31
+ module RougeColorizer
32
+ def colorizer
33
+ @colorizer ||= Colorizers::Rouge.new(config.theme)
34
+ end
29
35
  end
36
+
37
+ Logger.include(RougeColorizer)
30
38
  end
31
39
 
32
40
  setting :theme, nil
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Dry
4
4
  module Monitor
5
- VERSION = '0.3.1'
5
+ VERSION = "0.3.2"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-monitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Solnica
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-18 00:00:00.000000000 Z
11
+ date: 2020-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-configurable
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.1'
61
+ version: '0.2'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0.1'
68
+ version: '0.2'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -128,24 +128,16 @@ dependencies:
128
128
  - - ">="
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0'
131
- description:
131
+ description: Monitoring and instrumentation APIs
132
132
  email:
133
133
  - piotr.solnica@gmail.com
134
134
  executables: []
135
135
  extensions: []
136
136
  extra_rdoc_files: []
137
137
  files:
138
- - ".codeclimate.yml"
139
- - ".gitignore"
140
- - ".rspec"
141
- - ".rubocop.yml"
142
- - ".travis.yml"
143
138
  - CHANGELOG.md
144
- - CONTRIBUTING.md
145
- - Gemfile
146
139
  - LICENSE
147
140
  - README.md
148
- - Rakefile
149
141
  - dry-monitor.gemspec
150
142
  - lib/dry-monitor.rb
151
143
  - lib/dry/monitor.rb
@@ -158,17 +150,14 @@ files:
158
150
  - lib/dry/monitor/sql/colorizers/rouge.rb
159
151
  - lib/dry/monitor/sql/logger.rb
160
152
  - lib/dry/monitor/version.rb
161
- - rakelib/rubocop.rake
162
- - spec/integration/instrumentation_spec.rb
163
- - spec/integration/logger_spec.rb
164
- - spec/integration/rack_middleware_spec.rb
165
- - spec/integration/sql_logger_spec.rb
166
- - spec/spec_helper.rb
167
- - spec/test_logs/.gitkeep
168
- homepage: https://github.com/dry-rb/dry-monitor
153
+ homepage: https://dry-rb.org/gems/dry-monitor
169
154
  licenses:
170
155
  - MIT
171
- metadata: {}
156
+ metadata:
157
+ allowed_push_host: https://rubygems.org
158
+ changelog_uri: https://github.com/dry-rb/dry-monitor/blob/master/CHANGELOG.md
159
+ source_code_uri: https://github.com/dry-rb/dry-monitor
160
+ bug_tracker_uri: https://github.com/dry-rb/dry-monitor/issues
172
161
  post_install_message:
173
162
  rdoc_options: []
174
163
  require_paths:
@@ -177,7 +166,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
177
166
  requirements:
178
167
  - - ">="
179
168
  - !ruby/object:Gem::Version
180
- version: '0'
169
+ version: 2.4.0
181
170
  required_rubygems_version: !ruby/object:Gem::Requirement
182
171
  requirements:
183
172
  - - ">="
@@ -188,10 +177,4 @@ rubygems_version: 3.0.3
188
177
  signing_key:
189
178
  specification_version: 4
190
179
  summary: Monitoring and instrumentation APIs
191
- test_files:
192
- - spec/integration/instrumentation_spec.rb
193
- - spec/integration/logger_spec.rb
194
- - spec/integration/rack_middleware_spec.rb
195
- - spec/integration/sql_logger_spec.rb
196
- - spec/spec_helper.rb
197
- - spec/test_logs/.gitkeep
180
+ test_files: []
@@ -1,15 +0,0 @@
1
- version: "2"
2
-
3
- prepare:
4
- fetch:
5
- - url: "https://raw.githubusercontent.com/dry-rb/devtools/master/.rubocop.yml"
6
- path: ".rubocop.yml"
7
-
8
- exclude_patterns:
9
- - "benchmarks/"
10
- - "examples/"
11
- - "spec/"
12
-
13
- plugins:
14
- rubocop:
15
- enabled: true
data/.gitignore DELETED
@@ -1,10 +0,0 @@
1
- .DS_Store
2
- coverage
3
- /.bundle
4
- vendor/bundle
5
- bin/
6
- tmp/
7
- .idea/
8
- Gemfile.lock
9
- spec/test_logs/*.log
10
- .rubocop.yml
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --color
2
- --require spec_helper
3
- --order random
@@ -1,28 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
- bundler_args: --without benchmarks tools
4
- before_install: gem update --system
5
- before_script:
6
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
7
- - chmod +x ./cc-test-reporter
8
- - ./cc-test-reporter before-build
9
- after_script:
10
- - "[ -d coverage ] && ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
11
- script:
12
- - bundle exec rake ci
13
- rvm:
14
- - 2.6.3
15
- - 2.5.5
16
- - 2.4.6
17
- - jruby-9.2.7.0
18
- env:
19
- global:
20
- - COVERAGE=true
21
- notifications:
22
- email: false
23
- webhooks:
24
- urls:
25
- - https://webhooks.gitter.im/e/19098b4253a72c9796db
26
- on_success: change # options: [always|never|change] default: always
27
- on_failure: always # options: [always|never|change] default: always
28
- on_start: false # default: false
@@ -1,29 +0,0 @@
1
- # Issue Guidelines
2
-
3
- ## Reporting bugs
4
-
5
- If you found a bug, report an issue and describe what's the expected behavior versus what actually happens. If the bug causes a crash, attach a full backtrace. If possible, a reproduction script showing the problem is highly appreciated.
6
-
7
- ## Reporting feature requests
8
-
9
- Report a feature request **only after discussing it first on [discuss.dry-rb.org](https://discuss.dry-rb.org)** where it was accepted. Please provide a concise description of the feature, don't link to a discussion thread, and instead summarize what was discussed.
10
-
11
- ## Reporting questions, support requests, ideas, concerns etc.
12
-
13
- **PLEASE DON'T** - use [discuss.dry-rb.org](http://discuss.dry-rb.org) instead.
14
-
15
- # Pull Request Guidelines
16
-
17
- A Pull Request will only be accepted if it addresses a specific issue that was reported previously, or fixes typos, mistakes in documentation etc.
18
-
19
- Other requirements:
20
-
21
- 1) Do not open a pull request if you can't provide tests along with it. If you have problems writing tests, ask for help in the related issue.
22
- 2) Follow the style conventions of the surrounding code. In most cases, this is standard ruby style.
23
- 3) Add API documentation if it's a new feature
24
- 4) Update API documentation if it changes an existing feature
25
- 5) Bonus points for sending a PR to [github.com/dry-rb/dry-rb.org](github.com/dry-rb/dry-rb.org) which updates user documentation and guides
26
-
27
- # Asking for help
28
-
29
- If these guidelines aren't helpful, and you're stuck, please post a message on [discuss.dry-rb.org](https://discuss.dry-rb.org).
data/Gemfile DELETED
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- gemspec
6
-
7
- gem 'dry-events', git: 'https://github.com/dry-rb/dry-events.git', branch: 'master'
8
-
9
- group :test do
10
- gem 'rack'
11
- gem 'simplecov', platform: :mri, require: false
12
- end
13
-
14
- group :tools do
15
- gem 'byebug', platform: :mri
16
- end
data/Rakefile DELETED
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env rake
2
- # frozen_string_literal: true
3
-
4
- require 'bundler/gem_tasks'
5
-
6
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
7
-
8
- require 'rspec/core'
9
- require 'rspec/core/rake_task'
10
-
11
- task default: :spec
12
-
13
- desc 'Run all specs in spec directory'
14
- RSpec::Core::RakeTask.new(:spec)
15
-
16
- desc "Run CI tasks"
17
- task ci: [:spec]
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- begin
4
- require 'rubocop/rake_task'
5
-
6
- Rake::Task[:default].enhance [:rubocop]
7
-
8
- RuboCop::RakeTask.new do |task|
9
- task.options << '--display-cop-names'
10
- end
11
-
12
- namespace :rubocop do
13
- desc 'Generate a configuration file acting as a TODO list.'
14
- task :auto_gen_config do
15
- exec 'bundle exec rubocop --auto-gen-config'
16
- end
17
- end
18
-
19
- rescue LoadError
20
- end
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe 'Subscribing to instrumentation events' do
4
- subject(:notifications) { Dry::Monitor::Notifications.new(:app) }
5
-
6
- before do
7
- Dry::Monitor::Notifications.register_event(:sql, name: 'rom[sql]')
8
- end
9
-
10
- describe '#instrument' do
11
- it 'allows subscribing via block' do
12
- captured = []
13
- payload = { query: 'SELECT 1 FROM users' }
14
-
15
- notifications.subscribe(:sql) do |event|
16
- captured << [event.id, event[:query]]
17
- end
18
-
19
- notifications.instrument(:sql, payload)
20
-
21
- expect(captured).to eql([[:sql, 'SELECT 1 FROM users']])
22
- end
23
-
24
- it 'allows instrumenting via block' do
25
- captured = []
26
- payload = { query: 'SELECT 1 FROM users' }
27
-
28
- notifications.subscribe(:sql) do |event|
29
- captured << [event.id, event[:query]]
30
- end
31
-
32
- notifications.instrument(:sql, payload) do
33
- payload
34
- end
35
-
36
- expect(captured).to eql([[:sql, 'SELECT 1 FROM users']])
37
- end
38
-
39
- it 'allows instrumenting via block when no payload given' do
40
- captured = []
41
-
42
- notifications.subscribe(:sql) do |event|
43
- captured << [event.id]
44
- end
45
-
46
- notifications.instrument(:sql) {}
47
-
48
- expect(captured).to eql([[:sql]])
49
- end
50
- end
51
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Dry::Monitor::Logger do
4
- subject(:logger) do
5
- Dry::Monitor::Logger.new($stdout)
6
- end
7
-
8
- describe '#info' do
9
- it 'outputs with configured formatter' do
10
- expect { logger.info('test') }.to output("test\n").to_stdout
11
- end
12
- end
13
- end
@@ -1,100 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Dry::Monitor::Rack::Middleware do
4
- subject(:middleware) { Dry::Monitor::Rack::Middleware.new(notifications).new(rack_app) }
5
-
6
- let(:notifications) do
7
- Dry::Monitor::Notifications.new(:test)
8
- end
9
-
10
- let(:rack_app) do
11
- double(:rack_app)
12
- end
13
-
14
- let(:log_file_path) do
15
- SPEC_ROOT.join('test_logs/middleware.log')
16
- end
17
-
18
- let(:rack_logger) do
19
- Dry::Monitor::Rack::Logger.new(Dry::Monitor::Logger.new(log_file_path))
20
- end
21
-
22
- let(:env) do
23
- { 'REQUEST_METHOD' => 'GET',
24
- 'PATH_INFO' => '/hello-world',
25
- 'REMOTE_ADDR' => '0.0.0.0',
26
- 'QUERY_STRING' => query_params }
27
- end
28
-
29
- let(:query_params) do
30
- %w[
31
- _csrf=123456
32
- password=secret
33
- user[password]=secret
34
- others[][password]=secret1
35
- others[][password]=secret2
36
- foo=bar
37
- one=1
38
- ids[]=1
39
- ids[]=2
40
- ].join('&')
41
- end
42
-
43
- describe '#call' do
44
- before do
45
- File.open(log_file_path, 'w').close
46
- rack_logger.attach(middleware)
47
- end
48
-
49
- it 'triggers start/stop events for with a rack request' do
50
- expect(rack_app).to receive(:call).with(env).and_return([200, :total_success])
51
-
52
- status, response = middleware.call(env)
53
-
54
- expect(status).to be(200)
55
- expect(response).to be(:total_success)
56
-
57
- log_file_content = File.read(log_file_path)
58
-
59
- expect(log_file_content).to include('Started GET "/hello-world"')
60
- expect(log_file_content).to include('Finished GET "/hello-world"')
61
- expect(log_file_content).to include('Query parameters {"_csrf"=>"[FILTERED]", "password"=>"[FILTERED]", "user"=>{"password"=>"[FILTERED]"}, "others"=>[{"password"=>"[FILTERED]"}, {"password"=>"[FILTERED]"}], "foo"=>"bar", "one"=>"1", "ids"=>["1", "2"]}')
62
- end
63
- end
64
-
65
- describe '#on' do
66
- it 'subscribe a listener to a specific request event' do
67
- captured = []
68
-
69
- middleware.on(:error) do |event|
70
- captured << event[:exception]
71
- captured << event[:env]
72
- end
73
-
74
- exception = 'oops'
75
- env = { 'REQUEST_METHOD' => 'GET' }
76
-
77
- middleware.instrument(:error, exception: exception, env: env)
78
-
79
- expect(captured).to eql([exception, env])
80
- end
81
- end
82
-
83
- describe 'rack logger' do
84
- before do
85
- File.open(log_file_path, 'w').close
86
- rack_logger.attach(middleware)
87
- end
88
-
89
- it 'logs exceptions' do
90
- exception = double(:exception, message: 'oops', backtrace: ['/some/path.rb'])
91
-
92
- middleware.instrument(:error, exception: exception, env: env)
93
-
94
- log_file_content = File.read(log_file_path)
95
-
96
- expect(log_file_content).to include('oops')
97
- expect(log_file_content).to include('/some/path.rb')
98
- end
99
- end
100
- end
@@ -1,60 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Dry::Monitor::SQL::Logger do
4
- subject(:logger) { sql_logger.new(Dry::Monitor::Logger.new(log_file_path)) }
5
-
6
- let(:notifications) do
7
- Dry::Monitor::Notifications.new(:test)
8
- end
9
-
10
- let(:log_file_path) do
11
- SPEC_ROOT.join('test_logs/sql.log')
12
- end
13
-
14
- let(:log_file_content) { File.read(log_file_path) }
15
-
16
- shared_context '#subscribe' do
17
- let(:query) do
18
- 'SELECT id, name FROM users'
19
- end
20
-
21
- before do
22
- File.open(log_file_path, 'w').close
23
-
24
- logger.subscribe(notifications)
25
-
26
- notifications.instrument(:sql, name: 'users', query: query) do
27
- sleep 0.0025
28
- end
29
- end
30
-
31
- it 'writes sql query info' do
32
- expect(log_file_content).to include('Loaded "users" in')
33
- end
34
- end
35
-
36
- context 'without colors' do
37
- let(:sql_logger) do
38
- Dry::Monitor::SQL::Logger.load_extensions(:rouge_colorizer)
39
- Dry::Monitor::SQL::Logger
40
- end
41
-
42
- include_context '#subscribe' do
43
- let(:colored_query) do
44
- "\e[38;5;203mSELECT\e[39m\e[38;5;230m"
45
- end
46
-
47
- it 'writes sql query in logs' do
48
- expect(log_file_content).to include(colored_query)
49
- end
50
- end
51
- end
52
-
53
- context 'without colors' do
54
- let(:sql_logger) do
55
- Dry::Monitor::SQL::Logger
56
- end
57
-
58
- include_context '#subscribe'
59
- end
60
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- if RUBY_ENGINE == 'ruby' && ENV['COVERAGE'] == 'true'
4
- require 'yaml'
5
- rubies = YAML.safe_load(File.read(File.join(__dir__, '..', '.travis.yml')))['rvm']
6
- latest_mri = rubies.select { |v| v =~ /\A\d+\.\d+.\d+\z/ }.max
7
-
8
- if RUBY_VERSION == latest_mri
9
- require 'simplecov'
10
- SimpleCov.start do
11
- add_filter '/spec/'
12
- end
13
- end
14
- end
15
-
16
- begin
17
- require 'byebug'
18
- rescue LoadError; end
19
- require 'dry-monitor'
20
- Dry::Monitor.load_extensions(:sql, :rack)
21
-
22
- SPEC_ROOT = Pathname(__dir__)
23
-
24
- Dir[SPEC_ROOT.join('shared/**/*.rb')].each(&method(:require))
25
- Dir[SPEC_ROOT.join('support/**/*.rb')].each(&method(:require))
26
-
27
- RSpec.configure(&:disable_monkey_patching!)
File without changes