activerecord-opentracing-dox-fork 0.2.2.doximity1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 936f1d92a5a8b23913d49f20f0b52fc044b6a2a8212bb724ded12b49758b49f9
4
+ data.tar.gz: 0ebdb92aa66da6aac52952592095bf9de681549e686e982ec4b0f82d91fe2e73
5
+ SHA512:
6
+ metadata.gz: 94b8afaaf9ec0a406e7f8c17ebfd9b5aebbc7220643437b5f50d913288a4d184ef2b5ec08744d29908cc0a7000c2f7e85c87cfd072ae60865e2c48d3dbe6ef15
7
+ data.tar.gz: 802bc6d92338bc20727e5ff0cd794bf77ae5aac675b63694ac8d74af20cd56adbbceb62f1c852a2da49794daf46097d3bd1cba08735d2371a6ff91c9afb97182
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /tracer-test
10
+ /Gemfile.lock
11
+
12
+ # rspec failure tracking
13
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,46 @@
1
+ require: rubocop-rspec
2
+
3
+ Style/Documentation:
4
+ Enabled: no
5
+
6
+ Style/IfUnlessModifier:
7
+ Enabled: no
8
+
9
+ RSpec/NestedGroups:
10
+ Max: 4
11
+
12
+ RSpec/ExampleLength:
13
+ Enabled: no
14
+
15
+ RSpec/FilePath:
16
+ Enabled: no
17
+
18
+ RSpec/MultipleExpectations:
19
+ Enabled: no
20
+
21
+ Metrics/BlockLength:
22
+ Enabled: no
23
+
24
+ Metrics/MethodLength:
25
+ Enabled: no
26
+
27
+ Metrics/AbcSize:
28
+ Enabled: no
29
+
30
+ Metrics/ClassLength:
31
+ Enabled: no
32
+
33
+ Metrics/ParameterLists:
34
+ Enabled: no
35
+
36
+ Lint/UnusedMethodArgument:
37
+ Enabled: no
38
+
39
+ Style/FrozenStringLiteralComment:
40
+ Enabled: yes
41
+ EnforcedStyle: always
42
+ Include:
43
+ - 'lib/**/*'
44
+
45
+ Metrics/LineLength:
46
+ Max: 120
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.16.2
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 activerecord-tracer.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Indrek Juhkam
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,35 @@
1
+ # ActiveRecord::OpenTracing
2
+
3
+ Adds OpenTracing instrumentation to ActiveRecord
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'activerecord-opentracing'
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```ruby
16
+ require 'opentracing'
17
+ OpenTracing.global_tracer = TracerImplementation.new
18
+
19
+ require 'active_record/opentracing'
20
+ ActiveRecord::OpenTracing.instrument
21
+ ```
22
+
23
+ ## Development
24
+
25
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
+
27
+ 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).
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/activerecord-tracer.
32
+
33
+ ## License
34
+
35
+ 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,9 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ RuboCop::RakeTask.new(:rubocop)
8
+
9
+ task default: %i[rubocop spec]
@@ -0,0 +1,33 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'active_record/opentracing/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'activerecord-opentracing-dox-fork'
7
+ spec.version = ActiveRecord::OpenTracing::VERSION
8
+ spec.authors = ['SaleMove TechMovers', "Doximity"]
9
+ spec.email = ["ops@doximity.com"]
10
+
11
+ spec.summary = 'ActiveRecord OpenTracing intrumenter'
12
+ spec.description = ''
13
+ spec.homepage = 'https://github.com/doximity/ruby-activerecord-opentracing'
14
+ spec.license = 'MIT'
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.16'
24
+ spec.add_development_dependency 'opentracing_test_tracer', '~> 0.1'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'rspec', '~> 3.0'
27
+ spec.add_development_dependency 'rubocop', '~> 0.54.0'
28
+ spec.add_development_dependency 'rubocop-rspec', '~> 1.24.0'
29
+ spec.add_development_dependency 'sqlite3', '~> 1.3.13'
30
+
31
+ spec.add_dependency 'activerecord', '~> 5.0'
32
+ spec.add_dependency 'opentracing', '~> 0.3'
33
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'active_record/opentracing'
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,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_record'
4
+ require 'opentracing'
5
+
6
+ require 'active_record/opentracing/version'
7
+ require 'active_record/opentracing/processor'
8
+
9
+ module ActiveRecord
10
+ module OpenTracing
11
+ def self.instrument(tracer: ::OpenTracing.global_tracer)
12
+ processor = Processor.new(tracer)
13
+
14
+ ActiveSupport::Notifications.subscribe('sql.active_record') do |*args|
15
+ processor.call(*args)
16
+ end
17
+
18
+ self
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRecord
4
+ module OpenTracing
5
+ class Processor
6
+ DEFAULT_OPERATION_NAME = 'sql.query'.freeze
7
+ COMPONENT_NAME = 'ActiveRecord'.freeze
8
+ SPAN_KIND = 'client'.freeze
9
+ DB_TYPE = 'sql'.freeze
10
+
11
+ def initialize(tracer)
12
+ @tracer = tracer
13
+ end
14
+
15
+ def call(_event_name, start, finish, _id, payload)
16
+ span = @tracer.start_span(
17
+ payload[:name] || DEFAULT_OPERATION_NAME,
18
+ start_time: start,
19
+ tags: {
20
+ 'component' => COMPONENT_NAME,
21
+ 'span.kind' => SPAN_KIND,
22
+ 'db.instance' => db_instance,
23
+ 'db.cached' => payload.fetch(:cached, false),
24
+ # 'db.statement' => payload.fetch(:sql).squish,
25
+ 'db.type' => DB_TYPE,
26
+ 'peer.address' => db_address
27
+ }
28
+ )
29
+
30
+ if (exception = payload[:exception_object])
31
+ span.set_tag('error', true)
32
+ span.log_kv(
33
+ event: 'error',
34
+ :'error.kind' => exception.class.to_s,
35
+ :'error.object' => exception,
36
+ message: exception.message,
37
+ stack: exception.backtrace.join("\n")
38
+ )
39
+ end
40
+
41
+ span.finish(end_time: finish)
42
+ end
43
+
44
+ private
45
+
46
+ def db_instance
47
+ @db_instance ||= db_config.fetch(:database)
48
+ end
49
+
50
+ def db_address
51
+ @db_address ||= begin
52
+ connection_config = ActiveRecord::Base.connection_config
53
+ username = connection_config[:username]
54
+ host = connection_config[:host]
55
+ database = connection_config.fetch(:database)
56
+ vendor = connection_config.fetch(:adapter)
57
+
58
+ str = String.new('')
59
+ str << "#{vendor}://"
60
+ str << username if username
61
+ str << "@#{host}" if host
62
+ str << "/#{database}"
63
+ str
64
+ end
65
+ end
66
+
67
+ def db_config
68
+ @db_config ||= ActiveRecord::Base.connection_config
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRecord
4
+ module OpenTracing
5
+ VERSION = '0.2.2.doximity1'.freeze
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,184 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activerecord-opentracing-dox-fork
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.2.doximity1
5
+ platform: ruby
6
+ authors:
7
+ - SaleMove TechMovers
8
+ - Doximity
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2019-08-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.16'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.16'
28
+ - !ruby/object:Gem::Dependency
29
+ name: opentracing_test_tracer
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '0.1'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '0.1'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '10.0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '10.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rspec
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '3.0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '3.0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rubocop
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: 0.54.0
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: 0.54.0
84
+ - !ruby/object:Gem::Dependency
85
+ name: rubocop-rspec
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: 1.24.0
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: 1.24.0
98
+ - !ruby/object:Gem::Dependency
99
+ name: sqlite3
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: 1.3.13
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: 1.3.13
112
+ - !ruby/object:Gem::Dependency
113
+ name: activerecord
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: '5.0'
119
+ type: :runtime
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: '5.0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: opentracing
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: '0.3'
133
+ type: :runtime
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '0.3'
140
+ description: ''
141
+ email:
142
+ - ops@doximity.com
143
+ executables: []
144
+ extensions: []
145
+ extra_rdoc_files: []
146
+ files:
147
+ - ".gitignore"
148
+ - ".rspec"
149
+ - ".rubocop.yml"
150
+ - ".travis.yml"
151
+ - Gemfile
152
+ - LICENSE.txt
153
+ - README.md
154
+ - Rakefile
155
+ - activerecord-opentracing.gemspec
156
+ - bin/console
157
+ - bin/setup
158
+ - lib/active_record/opentracing.rb
159
+ - lib/active_record/opentracing/processor.rb
160
+ - lib/active_record/opentracing/version.rb
161
+ homepage: https://github.com/doximity/ruby-activerecord-opentracing
162
+ licenses:
163
+ - MIT
164
+ metadata: {}
165
+ post_install_message:
166
+ rdoc_options: []
167
+ require_paths:
168
+ - lib
169
+ required_ruby_version: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ required_rubygems_version: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - ">"
177
+ - !ruby/object:Gem::Version
178
+ version: 1.3.1
179
+ requirements: []
180
+ rubygems_version: 3.0.3
181
+ signing_key:
182
+ specification_version: 4
183
+ summary: ActiveRecord OpenTracing intrumenter
184
+ test_files: []