inst_statsd 2.1.6 → 2.3.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: cc4aff5a3dabe6fd65126f1b1f80d61cf0e11067608071d0f2429a013abf556e
4
- data.tar.gz: 7fc0ed85b4184df2e116fb86b8554d6a74cc476accd4abf2ae1dd06251daca53
3
+ metadata.gz: 568ce7b0b1164ceb930ba4c27604d3600f3afc9faf9486fa55ed315c3e1b6e90
4
+ data.tar.gz: e8970517048f627c0449ba8fa241adaae49b9aa37b3a4faa5047aa64e67f07d6
5
5
  SHA512:
6
- metadata.gz: 2df91d41c5a50fefcb46243e2de9eb7a8dd8caf568786c8ed721e6f46bde1c420e9b85d6b49118217603cc7a202a15a4c07315a4e1bfd6bae4557ccceb581ce0
7
- data.tar.gz: a6c7ab6cae3d3e5b19f7fde3da1d52d3d15104f26fb501262e8731804418aabf72cfa3613a3f6a930a56b4507f433507bb5333d74c7f05dc51cb8ac8872ddad7
6
+ metadata.gz: 92c65a63134c03d227481e0fca2cf23e438268dd8fa59a124ac95795c7e3ec304ac6d7052d7e9e0270cdfdb89ff7bba24543b4021fdfed3dc098fedb6951364a
7
+ data.tar.gz: 53087ac5aa2d2efe2af74d037ed18a0723774b38e17e3ddb34a8de2b5f67ec74620ef33c02737f3393a1faaf48c81ff5cd0cbfb217f408eb57b249f97ed312d4
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module InstStatsd
2
4
  class BlockStat
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'benchmark'
2
4
 
3
5
  module InstStatsd
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module InstStatsd
2
4
  class Counter
3
5
  class << self
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "active_support"
2
4
 
3
5
  module InstStatsd
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'logger'
2
4
 
3
5
  module InstStatsd
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module InstStatsd
2
4
  class RequestLogger
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module InstStatsd
2
4
  class RequestStat < BlockStat
3
5
  def initialize(name, start, finish, id, payload, statsd=InstStatsd::Statsd)
@@ -18,6 +20,7 @@ module InstStatsd
18
20
  self.short_stat = "request"
19
21
  self.tags[:controller] = controller if controller
20
22
  self.tags[:action] = action if action
23
+ self.tags[:status] = status if status
21
24
  else
22
25
  self.common_key = "request.#{controller}.#{action}" if controller && action
23
26
  end
@@ -46,6 +49,17 @@ module InstStatsd
46
49
  @payload.fetch(:params, {})['action']
47
50
  end
48
51
 
52
+ def status
53
+ status = @payload.fetch(:status, 0)
54
+ # Only return status group to reduce the number of indexed custom metrics (and cost) of datadog
55
+ return '1XX' if status >= 100 and status < 200
56
+ return '2XX' if status >= 200 and status < 300
57
+ return '3XX' if status >= 300 and status < 400
58
+ return '4XX' if status >= 400 and status < 500
59
+ return '5XX' if status >= 500 and status < 600
60
+ nil
61
+ end
62
+
49
63
  def total
50
64
  if (!@finish || !@start)
51
65
  return 0
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module InstStatsd
2
4
  class RequestTracking
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module InstStatsd
2
4
  class SqlTracker
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Proxy class to communicate messages to statsd
2
4
  # Available statsd messages are described in:
3
5
  # https://github.com/etsy/statsd/blob/master/README.md
data/lib/inst_statsd.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'statsd'
2
4
 
3
5
  module InstStatsd
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe InstStatsd::BlockStat do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe InstStatsd::BlockTracking do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe InstStatsd::Counter do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe InstStatsd do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe InstStatsd::NullLogger do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'logger'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
 
@@ -68,6 +70,22 @@ describe InstStatsd::RequestStat do
68
70
  end
69
71
  end
70
72
 
73
+ describe '#status' do
74
+ it 'should return nil if status is not defined' do
75
+ rs = create_subject
76
+ expect(rs.status).to eq nil
77
+ end
78
+
79
+ it 'should return HTTP status group if present' do
80
+ expect(create_subject({status: 200}).status).to eq '2XX'
81
+ expect(create_subject({status: 201}).status).to eq '2XX'
82
+ expect(create_subject({status: 302}).status).to eq '3XX'
83
+ expect(create_subject({status: 400}).status).to eq '4XX'
84
+ expect(create_subject({status: 404}).status).to eq '4XX'
85
+ expect(create_subject({status: 503}).status).to eq '5XX'
86
+ end
87
+ end
88
+
71
89
  describe '#total' do
72
90
  it 'correctly calculates milliseconds from start, finish' do
73
91
  rs = create_subject({params: {}})
@@ -111,10 +129,11 @@ describe InstStatsd::RequestStat do
111
129
  params: {
112
130
  'controller' => 'foo',
113
131
  'action' => 'index'
114
- }
132
+ },
133
+ status: 200
115
134
  }
116
135
  rs = create_subject(payload, statsd)
117
- expect(statsd).to receive(:timing).with('request.total', 1000, {short_stat: 'request.total', tags: {action: "index", controller: "foo"}} )
136
+ expect(statsd).to receive(:timing).with('request.total', 1000, {short_stat: 'request.total', tags: {action: "index", controller: "foo", status: '2XX'}} )
118
137
  rs.report
119
138
  end
120
139
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe InstStatsd::RequestTracking do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module InstStatsd
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe InstStatsd::Statsd do
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'inst_statsd'
2
4
 
3
5
  RSpec.configure do |config|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inst_statsd
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.6
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Cloward
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-05-24 00:00:00.000000000 Z
12
+ date: 2022-07-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dogstatsd-ruby
@@ -43,14 +43,14 @@ dependencies:
43
43
  name: aroi
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - "~>"
46
+ - - ">="
47
47
  - !ruby/object:Gem::Version
48
48
  version: 0.0.7
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - "~>"
53
+ - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: 0.0.7
56
56
  - !ruby/object:Gem::Dependency
@@ -174,8 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
174
  - !ruby/object:Gem::Version
175
175
  version: '0'
176
176
  requirements: []
177
- rubyforge_project:
178
- rubygems_version: 2.7.6
177
+ rubygems_version: 3.0.3
179
178
  signing_key:
180
179
  specification_version: 4
181
180
  summary: Statsd for Instructure