sinatra-instrumentation 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4a6183a762b5a91f46d31d970a9ddf81277ba47e
4
+ data.tar.gz: 71966212c8ddef8a4a5422713633f8d7044aa347
5
+ SHA512:
6
+ metadata.gz: 5a581486793ee3b2298b1432858fd0e5a24201c10c1581d8e79a28e0e5fe316eafce04a8e9a803806eac2049338b6c72a718054a97083b24640f54790db3d6a6
7
+ data.tar.gz: d7df4aa626712a6523d042ad3e8765cd74b16585a9e3793d2f80cf7c7e9770a22f9a3fc2321db04a8dc4d4eb2b993f28a326dcf8cd55887f3420d833d2a18d00
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Appraisals ADDED
@@ -0,0 +1,24 @@
1
+ appraise 'sinatra-latest' do
2
+ gem 'sinatra'
3
+ end
4
+
5
+ appraise 'sinatra-2.0.0' do
6
+ gem 'sinatra', '2.0.0'
7
+ end
8
+
9
+ appraise 'sinatra-1.4.8' do
10
+ gem 'sinatra', '1.4.8'
11
+ end
12
+
13
+ appraise 'sinatra-1.3.6' do
14
+ gem 'sinatra', '1.3.6'
15
+ end
16
+
17
+ appraise 'sinatra-1.2.9' do
18
+ gem 'sinatra', '1.2.9'
19
+ end
20
+
21
+ appraise 'sinatra-1.1.4' do
22
+ gem 'sinatra', '1.1.4'
23
+ end
24
+
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in sinatra-tracer.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Ashwin Chandrasekar
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,61 @@
1
+ # Sinatra::Instrumentation
2
+
3
+ Auto-instrumenter for Sinatra applications. It traces routes using
4
+ `Rack::Tracer` and patches Sinatra to trace template rendering.
5
+
6
+ ## Supported Versions
7
+
8
+ - MRI Ruby 2.0 and newer
9
+ - Sinatra 1.1.4 and newer
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'sinatra-instrumentation'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install sinatra-instrumentation
26
+
27
+ ## Usage
28
+
29
+ In a classic Sinatra application, this can be used by requiring the library:
30
+
31
+ ```ruby
32
+ require 'sinatra/instrumentation'
33
+ ```
34
+
35
+ A modular application will need to register it manually:
36
+
37
+ ```ruby
38
+ class SinatraApp < Sinatra::Base
39
+ register Sinatra::Instrumentation
40
+ ...
41
+ end
42
+ ```
43
+
44
+ ## Tags
45
+
46
+ In addition to the standard OpenTracing tags, the instrumentation also adds:
47
+ - `sinatra.template`: the name of the view template, or if rendering a string with view code, the contents of the string.
48
+
49
+ ## Development
50
+
51
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
52
+
53
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
54
+
55
+ ## Contributing
56
+
57
+ Bug reports and pull requests are welcome on GitHub at https://github.com/signalfx/ruby-sinatra-instrumentation.
58
+
59
+ ## License
60
+
61
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "sinatra/instrumentation"
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(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "sinatra", "1.0"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "sinatra", "1.1.4"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "sinatra", "1.2.9"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "sinatra", "1.3.6"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "sinatra", "1.4.8"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "sinatra", "2.0.0"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "sinatra"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,40 @@
1
+ require 'rack/tracer'
2
+ require 'sinatra/base'
3
+ require 'sinatra/instrumentation/version'
4
+ require 'opentracing'
5
+
6
+ module Sinatra
7
+ module Instrumentation
8
+
9
+ class << self
10
+
11
+ def registered(app)
12
+ # enable the Rack Tracer middleware
13
+ app.use Rack::Tracer
14
+
15
+ patch_render if !@patched
16
+ @patched = true
17
+ end
18
+
19
+ def patch_render
20
+ ::Sinatra::Base.module_eval do
21
+ alias_method :render_original, :render
22
+
23
+ def render(engine, data, options = {}, locals = {}, &block)
24
+ result = ""
25
+
26
+ OpenTracing.global_tracer.start_active_span("sinatra.render", tags: {}) do |scope|
27
+ result = render_original(engine, data, options, locals, &block)
28
+ scope.span.set_tag("sinatra.template", data)
29
+ end
30
+
31
+ result
32
+ end
33
+ end
34
+ end
35
+
36
+ end
37
+ end
38
+
39
+ register Instrumentation
40
+ end
@@ -0,0 +1,5 @@
1
+ module Sinatra
2
+ module Instrumentation
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
@@ -0,0 +1,39 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "sinatra/instrumentation/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "sinatra-instrumentation"
8
+ spec.version = Sinatra::Instrumentation::VERSION
9
+ spec.authors = ["Ashwin Chandrasekar"]
10
+ spec.email = ["achandrasekar@signalfx.com"]
11
+
12
+ spec.summary = %q{Instrumentation for Sinatra applications}
13
+ spec.description = %q{OpenTracing compatible auto-instrumentation for Sinatra web applications.}
14
+ spec.homepage = "http://github.com/signalfx/ruby-sinatra-instrumentation"
15
+ spec.license = "MIT"
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.16"
27
+ spec.add_development_dependency "opentracing_test_tracer", "~> 0.1"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+ spec.add_development_dependency "rspec", "~> 3.0"
30
+ spec.add_development_dependency "rubocop", "~> 0.60"
31
+ spec.add_development_dependency "rubocop-rspec", "~> 1.30.0"
32
+ spec.add_development_dependency "appraisal", "~> 2.2"
33
+ spec.add_development_dependency "sinatra", "~> 1.4"
34
+ spec.add_development_dependency "rack-test", "~> 1.1"
35
+
36
+ spec.add_dependency "opentracing", "~> 0.3"
37
+ spec.add_dependency "rack-tracer", "~>0.8.0"
38
+
39
+ end
data/test_app/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'opentracing'
4
+ gem 'sinatra', '~> 1.4'
5
+ gem 'jaeger-client', '~> 0.6.1'
6
+ gem 'sinatra-instrumentation', '~> 0.1.0'
data/test_app/hello.rb ADDED
@@ -0,0 +1,35 @@
1
+ require 'sinatra'
2
+ require 'opentracing'
3
+ require 'jaeger/client'
4
+ require 'jaeger/client/http_sender'
5
+ require 'logger'
6
+
7
+ require 'sinatra/instrumentation'
8
+
9
+ accessToken = ""
10
+ headers = { }
11
+ service_name = "sinatra-tracer-test"
12
+ encoder = Jaeger::Client::Encoders::ThriftEncoder.new(service_name: service_name)
13
+ httpsender = Jaeger::Client::HttpSender.new(url: "http://localhost:14268/api/traces", headers: headers, encoder: encoder, logger: Logger.new(STDOUT))
14
+ OpenTracing.global_tracer = Jaeger::Client.build(service_name: service_name, sender: httpsender, propagate_b3: true)
15
+
16
+ get '/' do
17
+ "#{hello}"
18
+ end
19
+
20
+ get '/render' do
21
+ code = "<%= Time.now %>"
22
+ erb code
23
+ end
24
+
25
+ get '/rendererb' do
26
+ erb :index
27
+ end
28
+
29
+ def hello
30
+ hello_str = "hello"
31
+ OpenTracing.start_active_span("hello") do
32
+ puts hello_str
33
+ end
34
+ hello_str
35
+ end
metadata ADDED
@@ -0,0 +1,218 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sinatra-instrumentation
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Ashwin Chandrasekar
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-12-11 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.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: opentracing_test_tracer
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.1'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.60'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.60'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop-rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 1.30.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 1.30.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: appraisal
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.2'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.2'
111
+ - !ruby/object:Gem::Dependency
112
+ name: sinatra
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.4'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.4'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rack-test
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.1'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1.1'
139
+ - !ruby/object:Gem::Dependency
140
+ name: opentracing
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '0.3'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '0.3'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rack-tracer
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 0.8.0
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 0.8.0
167
+ description: OpenTracing compatible auto-instrumentation for Sinatra web applications.
168
+ email:
169
+ - achandrasekar@signalfx.com
170
+ executables: []
171
+ extensions: []
172
+ extra_rdoc_files: []
173
+ files:
174
+ - ".gitignore"
175
+ - Appraisals
176
+ - Gemfile
177
+ - LICENSE.txt
178
+ - README.md
179
+ - Rakefile
180
+ - bin/console
181
+ - bin/setup
182
+ - gemfiles/sinatra_1.0.gemfile
183
+ - gemfiles/sinatra_1.1.4.gemfile
184
+ - gemfiles/sinatra_1.2.9.gemfile
185
+ - gemfiles/sinatra_1.3.6.gemfile
186
+ - gemfiles/sinatra_1.4.8.gemfile
187
+ - gemfiles/sinatra_2.0.0.gemfile
188
+ - gemfiles/sinatra_latest.gemfile
189
+ - lib/sinatra/instrumentation.rb
190
+ - lib/sinatra/instrumentation/version.rb
191
+ - sinatra-tracer.gemspec
192
+ - test_app/Gemfile
193
+ - test_app/hello.rb
194
+ homepage: http://github.com/signalfx/ruby-sinatra-instrumentation
195
+ licenses:
196
+ - MIT
197
+ metadata: {}
198
+ post_install_message:
199
+ rdoc_options: []
200
+ require_paths:
201
+ - lib
202
+ required_ruby_version: !ruby/object:Gem::Requirement
203
+ requirements:
204
+ - - ">="
205
+ - !ruby/object:Gem::Version
206
+ version: '0'
207
+ required_rubygems_version: !ruby/object:Gem::Requirement
208
+ requirements:
209
+ - - ">="
210
+ - !ruby/object:Gem::Version
211
+ version: '0'
212
+ requirements: []
213
+ rubyforge_project:
214
+ rubygems_version: 2.6.13
215
+ signing_key:
216
+ specification_version: 4
217
+ summary: Instrumentation for Sinatra applications
218
+ test_files: []