scout_signalfx 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +12 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +84 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/scout_signalfx.rb +14 -0
- data/lib/scout_signalfx/periodic_callback.rb +86 -0
- data/lib/scout_signalfx/version.rb +3 -0
- data/scout_signalfx.gemspec +30 -0
- metadata +154 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: abeaadc06120e178633cafabfac1c3bb59f9e400
|
4
|
+
data.tar.gz: 9d869beaecf1eec2fcfa107fd6e7037c9d78a693
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 56342be9ee7df5a2ec0b688c3062183b614a840d680d35b86fc6b889a394ed064e1479aadc16cd3436e68e81d0f5e718e870b06a0fc1183cf7f93de14ea554b1
|
7
|
+
data.tar.gz: cb1e3d858f6038943549f845417e0b548a62f783902b4a8aaa9a5c64e2ed755de3573436fcb808d94221aa2867ee6829ad5e86e973fdf3e24bee3463af89f1c8
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Derek Haynes
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# ScoutSignalfx
|
2
|
+
|
3
|
+
[](https://travis-ci.org/scoutapp/scout_signalfx_ruby)
|
4
|
+
|
5
|
+
Bring key health metrics for your Ruby on Rails app(s) into [SignalFx](https://signalfx.com/) with the `scout_signalfx` gem. The gem extends the [Scout](https://scoutapp.com) Ruby gem, which gathers detailed performance on every web request, and sends those metrics direct to SignalFx.
|
6
|
+
|
7
|
+
A [Scout](https://scoutapp.com) account isn't required, but it certainly makes performance investigations more fun.
|
8
|
+
|
9
|
+

|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'scout_signalfx'
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
$ gem install scout_signalfx
|
26
|
+
|
27
|
+
## Configuration
|
28
|
+
|
29
|
+
__Add a `config/initializers/scout_signalfx.rb` file to your Rails app:__
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
SIGNAL_FX_CLIENT = SignalFx.new("[SIGNAL_FX_TOKEN]")
|
33
|
+
ScoutSignalfx.configure(SIGNAL_FX_CLIENT)
|
34
|
+
```
|
35
|
+
|
36
|
+
Your SignalFx API access token can be obtained from the SignalFx organization you want to report data into.
|
37
|
+
|
38
|
+
__Add a `config/scout_apm.yml` file to your Rails app:__
|
39
|
+
|
40
|
+
```yaml
|
41
|
+
common: &defaults
|
42
|
+
monitor: true
|
43
|
+
|
44
|
+
development:
|
45
|
+
<<: *defaults
|
46
|
+
monitor: false # set to true to test in your development environment
|
47
|
+
|
48
|
+
production:
|
49
|
+
<<: *defaults
|
50
|
+
```
|
51
|
+
|
52
|
+
_This step isn't required if you're an existing Scout customer._
|
53
|
+
|
54
|
+
[See the Scout docs](http://help.apm.scoutapp.com/#ruby-agent) for advanced configuration instructions.
|
55
|
+
|
56
|
+
The Scout gem auto-magically instruments your controller-actions. There's no more steps!
|
57
|
+
|
58
|
+
## Metric Schema
|
59
|
+
|
60
|
+
The following metrics are reported once per-minute:
|
61
|
+
|
62
|
+
* web.duration_ms
|
63
|
+
* web.count
|
64
|
+
* web.errors_count
|
65
|
+
|
66
|
+
Each metric has the following dimensions:
|
67
|
+
|
68
|
+
* app - The name of the app
|
69
|
+
* host - The hostname of the running app
|
70
|
+
* transaction - The name of the transaction. For example, `UsersController#index` becomes `users.index` in SignalFx.
|
71
|
+
|
72
|
+
## Tests
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
rake
|
76
|
+
```
|
77
|
+
|
78
|
+
## Contributing
|
79
|
+
|
80
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/scoutapp/scout_signalfx_ruby.
|
81
|
+
|
82
|
+
## License
|
83
|
+
|
84
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "scout_signalfx"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
module ScoutSignalfx
|
2
|
+
# Takes a +SignalFxClient+ and configures the ScoutApm SignalFx Payload Plugin.
|
3
|
+
def self.configure(signalfx_client)
|
4
|
+
@@signalfx_client ||= signalfx_client
|
5
|
+
ScoutApm::Extensions::Config.add_periodic_callback(ScoutSignalfx::PeriodicCallback.new)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.signalfx_client
|
9
|
+
@@signalfx_client
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
require "scout_signalfx/version"
|
14
|
+
require "scout_signalfx/periodic_callback"
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module ScoutSignalfx
|
2
|
+
# This is ran after each reporting period (once per-minute).
|
3
|
+
class PeriodicCallback
|
4
|
+
def call(reporting_period, metadata)
|
5
|
+
@reporting_period = reporting_period
|
6
|
+
@metadata = metadata
|
7
|
+
|
8
|
+
return if controller_metrics.empty?
|
9
|
+
ScoutSignalfx.signalfx_client.send(
|
10
|
+
gauges: guages,
|
11
|
+
counters: counters,
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def metrics
|
18
|
+
@reporting_period.metrics_payload
|
19
|
+
end
|
20
|
+
|
21
|
+
# The time associated w/the metrics
|
22
|
+
def timestamp
|
23
|
+
Time.at(@metadata[:agent_time].to_i)
|
24
|
+
end
|
25
|
+
|
26
|
+
def timestamp_ms
|
27
|
+
timestamp.to_i*1000
|
28
|
+
end
|
29
|
+
|
30
|
+
def transaction_name
|
31
|
+
metrics.keys.first.metric_name
|
32
|
+
end
|
33
|
+
|
34
|
+
# Renames Scout metric names to a more SignalFx-ish format.
|
35
|
+
# Ex: Controllers/users/index => users.index
|
36
|
+
def signalfx_transaction_name(transaction_name)
|
37
|
+
@signalfx_transaction_name ||= transaction_name.sub!("Controller/",'').gsub("/",".")
|
38
|
+
end
|
39
|
+
|
40
|
+
def controller_metrics
|
41
|
+
@controller_metrics ||= metrics.select { |meta,metric| meta.type == 'Controller' }
|
42
|
+
end
|
43
|
+
|
44
|
+
def controller_error_metrics
|
45
|
+
@controller_error_metrics ||= metrics.select { |meta,metric| meta.type == 'Errors' && meta.name =~ /\AController/ }
|
46
|
+
end
|
47
|
+
|
48
|
+
def guages
|
49
|
+
controller_metrics.map do |meta,metric|
|
50
|
+
{
|
51
|
+
metric: 'web.duration_ms',
|
52
|
+
value: (metric.total_call_time / metric.call_count.to_f)*1000,
|
53
|
+
timestamp: timestamp_ms,
|
54
|
+
dimensions: dimensions_for_metric_name(meta.metric_name)
|
55
|
+
}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def counters
|
60
|
+
controller_metrics.map do |meta,metric|
|
61
|
+
{
|
62
|
+
metric: 'web.count',
|
63
|
+
value: metric.call_count,
|
64
|
+
timestamp: timestamp_ms,
|
65
|
+
dimensions: dimensions_for_metric_name(meta.metric_name)
|
66
|
+
}
|
67
|
+
end + controller_error_metrics.map do |meta,metric|
|
68
|
+
{
|
69
|
+
metric: 'web.errors.count',
|
70
|
+
value: metric.call_count,
|
71
|
+
timestamp: timestamp_ms,
|
72
|
+
dimensions: dimensions_for_metric_name(meta.name)
|
73
|
+
}
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def dimensions_for_metric_name(metric_name)
|
78
|
+
[
|
79
|
+
{key: 'host', value: ScoutApm::Agent.instance.context.environment.hostname},
|
80
|
+
{key: 'transaction', value: signalfx_transaction_name(metric_name)},
|
81
|
+
{key: 'app', value: ScoutApm::Agent.instance.context.config.value('name')}
|
82
|
+
]
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'scout_signalfx/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "scout_signalfx"
|
8
|
+
spec.version = ScoutSignalfx::VERSION
|
9
|
+
spec.authors = ["Derek Haynes"]
|
10
|
+
spec.email = ["derek.haynes@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "Reports app performance metrics gathered via Scout to SignalFx"
|
13
|
+
spec.homepage = "https://github.com/scoutapp/scout_signalfx_ruby"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "minitest"
|
24
|
+
spec.add_development_dependency "mocha"
|
25
|
+
spec.add_development_dependency "fakeweb", ["~> 1.3"]
|
26
|
+
|
27
|
+
spec.add_runtime_dependency "scout_apm", "~> 2.4.11"
|
28
|
+
spec.add_runtime_dependency "signalfx"
|
29
|
+
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: scout_signalfx
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Derek Haynes
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-06-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: mocha
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: fakeweb
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: scout_apm
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.4.11
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.4.11
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: signalfx
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description:
|
112
|
+
email:
|
113
|
+
- derek.haynes@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".travis.yml"
|
120
|
+
- Gemfile
|
121
|
+
- LICENSE.txt
|
122
|
+
- README.md
|
123
|
+
- Rakefile
|
124
|
+
- bin/console
|
125
|
+
- bin/setup
|
126
|
+
- lib/scout_signalfx.rb
|
127
|
+
- lib/scout_signalfx/periodic_callback.rb
|
128
|
+
- lib/scout_signalfx/version.rb
|
129
|
+
- scout_signalfx.gemspec
|
130
|
+
homepage: https://github.com/scoutapp/scout_signalfx_ruby
|
131
|
+
licenses:
|
132
|
+
- MIT
|
133
|
+
metadata: {}
|
134
|
+
post_install_message:
|
135
|
+
rdoc_options: []
|
136
|
+
require_paths:
|
137
|
+
- lib
|
138
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
requirements: []
|
149
|
+
rubyforge_project:
|
150
|
+
rubygems_version: 2.4.6
|
151
|
+
signing_key:
|
152
|
+
specification_version: 4
|
153
|
+
summary: Reports app performance metrics gathered via Scout to SignalFx
|
154
|
+
test_files: []
|