bc-lightstep-ruby 2.0.0 → 2.1.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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +20 -1
- data/bc-lightstep-ruby.gemspec +3 -1
- data/lib/bigcommerce/lightstep.rb +7 -1
- data/lib/bigcommerce/lightstep/active_record/adapter.rb +117 -0
- data/lib/bigcommerce/lightstep/active_record/tracer.rb +83 -0
- data/lib/bigcommerce/lightstep/configuration.rb +21 -29
- data/lib/bigcommerce/lightstep/transport_factory.rb +4 -0
- data/lib/bigcommerce/lightstep/version.rb +1 -1
- metadata +36 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a8c27ea5cc9408b41c8786c4dbc2c7f637fb7de271ff54f9b51bc95b2efef5a
|
4
|
+
data.tar.gz: 34439ce990947965dfeb07a573e9865bf5e6dc31eb2318d04ae651be85ab8bc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dc933fa3929ab32e05eaf12f97c30c7fd48043c8e9e8ea1bf1391138860f93e33d3574b476992e7994e61cee6eb3d0d0bb0b26cf840bee6a6ecf35c12060164
|
7
|
+
data.tar.gz: 1956ad38a1f0cfa14195271eca7977cb7628a09ba832eae94a8a854a5a531e540a2775bce737005668b197c07190a3d32715974d284654623811fd86a92e4f83
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -45,10 +45,18 @@ bc-lightstep-ruby can be automatically configured from these ENV vars, if you'd
|
|
45
45
|
| LIGHTSTEP_ACCESS_TOKEN | The access token to use to connect to the collector. Optional. | '' |
|
46
46
|
| LIGHTSTEP_HOST | Host of the collector. | `lightstep-collector.linkerd` |
|
47
47
|
| LIGHTSTEP_PORT | Port of the collector. | `4140` |
|
48
|
+
| LIGHTSTEP_HTTP1_ERROR_CODE | The HTTP error code to report in spans for internal errors | 500 |
|
49
|
+
| LIGHTSTEP_HTTP1_ERROR_CODE_MINIMUM | The minimum HTTP error code value to be considered an error for span tag purposes. | 500 |
|
50
|
+
| LIGHTSTEP_CONTROLLER_PREFIX | The prefix for Rails controllers to use | `controllers.` |
|
48
51
|
| LIGHTSTEP_SSL_VERIFY_PEER | If using 443 as the port, toggle SSL verification. | true |
|
49
52
|
| LIGHTSTEP_MAX_BUFFERED_SPANS | The maximum number of spans to buffer before dropping. | `1_000` |
|
50
53
|
| LIGHTSTEP_MAX_LOG_RECORDS | Maximum number of log records on a span to accept. | `1_000` |
|
51
54
|
| LIGHTSTEP_MAX_REPORTING_INTERVAL_SECONDS | The maximum number of seconds to wait before flushing the report to the collector. | 3.0 |
|
55
|
+
| LIGHTSTEP_ACTIVE_RECORD_ENABLED | Whether or not to add ActiveRecord mysql spans. Only works with mysql2 gem. | 1 |
|
56
|
+
| LIGHTSTEP_ACTIVE_RECORD_ALLOW_AS_ROOT_SPAN | Allow ActiveRecord mysql spans to be the root span? | 0 |
|
57
|
+
| LIGHTSTEP_ACTIVE_RECORD_SPAN_PREFIX | What to prefix the ActiveRecord mysql span with | '' |
|
58
|
+
| LIGHTSTEP_REDIS_ALLOW_AS_ROOT_SPAN | Allow redis to be the root span? | 0 |
|
59
|
+
| LIGHTSTEP_REDIS_EXCLUDED_COMMANDS | Redis commands to exclude from spans. Comma-separated list. | ping |
|
52
60
|
| LIGHTSTEP_VERBOSITY | The verbosity level of lightstep logs. | 1 |
|
53
61
|
|
54
62
|
Most systems will only need to customize the component name.
|
@@ -77,7 +85,7 @@ or systems outside of your instrumenting control.
|
|
77
85
|
|
78
86
|
### Redis
|
79
87
|
|
80
|
-
This gem will automatically detect and
|
88
|
+
This gem will automatically detect and instrument Redis calls when they are made using the `Redis::Client` class.
|
81
89
|
It will set as tags on the span the host, port, db instance, and the command (but no arguments).
|
82
90
|
|
83
91
|
Note that this will not record redis timings if they are a root span. This is to prevent trace spamming. You can
|
@@ -86,6 +94,17 @@ re-enable this by setting the `redis_allow_root_spans` configuration option to `
|
|
86
94
|
It also excludes `ping` commands, and you can provide a custom list by setting the `redis_excluded_commands`
|
87
95
|
configuration option to an array of commands to exclude.
|
88
96
|
|
97
|
+
### ActiveRecord and MySQL
|
98
|
+
|
99
|
+
This gem will automatically instrument MySQL queries with spans when made with the `mysql2` gem and ActiveRecord.
|
100
|
+
It will set as tags on the span the host, database type, database name, and a sanitized version of the SQL query made.
|
101
|
+
The query will have no values - replaced with `?` - to ensure secure logging and no leaking of PII data.
|
102
|
+
|
103
|
+
Note that this will not record mysql timings if they are a root span. This is to prevent trace spamming. You can
|
104
|
+
configure this gem to allow it via ENV, but it is not recommended.
|
105
|
+
|
106
|
+
By default, it will also exclude `COMMIT`, `SCHEMA`, and `SHOW FULL FIELDS` queries.
|
107
|
+
|
89
108
|
## RSpec
|
90
109
|
|
91
110
|
This library comes with a built-in matcher for testing span blocks. In your rspec config:
|
data/bc-lightstep-ruby.gemspec
CHANGED
@@ -33,9 +33,10 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.require_paths = ['lib']
|
34
34
|
spec.required_ruby_version = '>= 2.6'
|
35
35
|
|
36
|
+
spec.add_development_dependency 'activerecord', '> 4'
|
36
37
|
spec.add_development_dependency 'bundler', '~> 1.11'
|
37
38
|
spec.add_development_dependency 'bundler-audit', '~> 0.6'
|
38
|
-
spec.add_development_dependency 'rake', '
|
39
|
+
spec.add_development_dependency 'rake', '>= 12.0'
|
39
40
|
spec.add_development_dependency 'rspec', '~> 3.8'
|
40
41
|
spec.add_development_dependency 'rspec_junit_formatter', '~> 0.4'
|
41
42
|
spec.add_development_dependency 'rubocop', '~> 0.79'
|
@@ -45,6 +46,7 @@ Gem::Specification.new do |spec|
|
|
45
46
|
spec.add_development_dependency 'null-logger', '~> 0.1'
|
46
47
|
spec.add_development_dependency 'redis', '~> 4'
|
47
48
|
|
49
|
+
spec.add_runtime_dependency 'activesupport', '>= 4'
|
48
50
|
spec.add_runtime_dependency 'lightstep', '~> 0.13.0'
|
49
51
|
spec.add_runtime_dependency 'faraday', ['>= 0.8', '<= 0.15.4']
|
50
52
|
end
|
@@ -17,6 +17,7 @@
|
|
17
17
|
#
|
18
18
|
require 'lightstep'
|
19
19
|
require 'faraday'
|
20
|
+
require 'active_support/concern'
|
20
21
|
require_relative 'lightstep/version'
|
21
22
|
require_relative 'lightstep/errors'
|
22
23
|
require_relative 'lightstep/interceptors/registry'
|
@@ -27,6 +28,8 @@ require_relative 'lightstep/transport_factory'
|
|
27
28
|
require_relative 'lightstep/transport'
|
28
29
|
require_relative 'lightstep/rails_controller_instrumentation'
|
29
30
|
require_relative 'lightstep/middleware/faraday'
|
31
|
+
require_relative 'lightstep/active_record/tracer'
|
32
|
+
require_relative 'lightstep/active_record/adapter'
|
30
33
|
require_relative 'lightstep/redis/tracer'
|
31
34
|
|
32
35
|
##
|
@@ -54,7 +57,10 @@ module Bigcommerce
|
|
54
57
|
::LightStep.instance.max_log_records = ::Bigcommerce::Lightstep.max_log_records
|
55
58
|
::LightStep.instance.report_period_seconds = ::Bigcommerce::Lightstep.max_reporting_interval_seconds
|
56
59
|
|
57
|
-
|
60
|
+
return unless ::Bigcommerce::Lightstep.enabled
|
61
|
+
|
62
|
+
::Bigcommerce::Lightstep::Redis::Wrapper.patch
|
63
|
+
::Bigcommerce::Lightstep::ActiveRecord::Adapter.patch
|
58
64
|
end
|
59
65
|
end
|
60
66
|
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) 2020-present, BigCommerce Pty. Ltd. All rights reserved
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
6
|
+
# documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
7
|
+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
8
|
+
# persons to whom the Software is furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
11
|
+
# Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
14
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
15
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
16
|
+
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
17
|
+
#
|
18
|
+
module Bigcommerce
|
19
|
+
module Lightstep
|
20
|
+
module ActiveRecord
|
21
|
+
##
|
22
|
+
# Patches mysql and ActiveRecord to allow for mysql span tracing
|
23
|
+
#
|
24
|
+
module Adapter
|
25
|
+
extend ::ActiveSupport::Concern
|
26
|
+
|
27
|
+
##
|
28
|
+
# Patch ActiveRecord to enable mysql span traces
|
29
|
+
#
|
30
|
+
def self.patch
|
31
|
+
return unless enabled?
|
32
|
+
|
33
|
+
# rubocop:disable Lint/SendWithMixinArgument
|
34
|
+
::ActiveRecord::ConnectionAdapters::Mysql2Adapter.send(:include, ::Bigcommerce::Lightstep::ActiveRecord::Adapter)
|
35
|
+
# rubocop:enable Lint/SendWithMixinArgument
|
36
|
+
end
|
37
|
+
|
38
|
+
##
|
39
|
+
# Note: we only support patching mysql2 gem at this point
|
40
|
+
#
|
41
|
+
# @return [Boolean]
|
42
|
+
#
|
43
|
+
def self.enabled?
|
44
|
+
defined?(::ActiveRecord) && ::Bigcommerce::Lightstep.active_record && ::ActiveRecord::Base.connection_config[:adapter].to_s.downcase == 'mysql2'
|
45
|
+
rescue StandardError => e
|
46
|
+
::Bigcommerce::Lightstep.logger&.warn "Failed to determine ActiveRecord database adapter in bc-lightstep-ruby initializer: #{e.message}"
|
47
|
+
false
|
48
|
+
end
|
49
|
+
|
50
|
+
##
|
51
|
+
# @param [String] sql The raw sql query
|
52
|
+
# @param [String] name The type of sql query
|
53
|
+
#
|
54
|
+
def execute_with_inst(sql, name = 'SQL')
|
55
|
+
# bail out early if not enabled. This should not get here, but is provided as a failsafe.
|
56
|
+
return execute_without_inst(sql, name) unless ::Bigcommerce::Lightstep.active_record
|
57
|
+
|
58
|
+
sanitized_sql = lightstep_sanitize_sql(sql)
|
59
|
+
name = name.to_s.strip.empty? ? 'QUERY' : name
|
60
|
+
|
61
|
+
# we dont need to track all sql
|
62
|
+
return execute_without_inst(sql, name) if lightstep_skip_tracing?(name, sanitized_sql)
|
63
|
+
|
64
|
+
lightstep_tracer.db_trace(
|
65
|
+
statement: sanitized_sql,
|
66
|
+
host: @config[:host],
|
67
|
+
adapter: @config[:adapter],
|
68
|
+
database: @config[:database]
|
69
|
+
) do
|
70
|
+
execute_without_inst(sql, name)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
##
|
75
|
+
# Sanitize the sql for safe logging
|
76
|
+
#
|
77
|
+
# @param [String]
|
78
|
+
# @return [String]
|
79
|
+
#
|
80
|
+
def lightstep_sanitize_sql(sql)
|
81
|
+
sql.to_s.gsub(lightstep_sanitization_regexp, '?').tr("\n", ' ').to_s
|
82
|
+
end
|
83
|
+
|
84
|
+
##
|
85
|
+
# @return [Regexp]
|
86
|
+
#
|
87
|
+
def lightstep_sanitization_regexp
|
88
|
+
@lightstep_sanitization_regexp ||= ::Regexp.new('(\'[\s\S][^\']*\'|\d*\.\d+|\d+|NULL)', ::Regexp::IGNORECASE)
|
89
|
+
end
|
90
|
+
|
91
|
+
##
|
92
|
+
# Filter out sql queries from tracing we don't care about
|
93
|
+
#
|
94
|
+
# @param [String] name
|
95
|
+
# @param [String] sql
|
96
|
+
# @return [Boolean]
|
97
|
+
def lightstep_skip_tracing?(name, sql)
|
98
|
+
name.empty? || sql.empty? || sql.include?('COMMIT') || sql.include?('SCHEMA') || sql.include?('SHOW FULL FIELDS')
|
99
|
+
end
|
100
|
+
|
101
|
+
##
|
102
|
+
# @return [::Bigcommerce::Lightstep::ActiveRecord::Tracer]
|
103
|
+
#
|
104
|
+
def lightstep_tracer
|
105
|
+
@lightstep_tracer ||= ::Bigcommerce::Lightstep::ActiveRecord::Tracer.new
|
106
|
+
end
|
107
|
+
|
108
|
+
included do
|
109
|
+
if defined?(::ActiveRecord) && ::ActiveRecord::VERSION::MAJOR > 3
|
110
|
+
alias_method :execute_without_inst, :execute
|
111
|
+
alias_method :execute, :execute_with_inst
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) 2020-present, BigCommerce Pty. Ltd. All rights reserved
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
6
|
+
# documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
7
|
+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
8
|
+
# persons to whom the Software is furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
11
|
+
# Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
14
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
15
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
16
|
+
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
17
|
+
#
|
18
|
+
module Bigcommerce
|
19
|
+
module Lightstep
|
20
|
+
module ActiveRecord
|
21
|
+
##
|
22
|
+
# Tracer adapter for ActiveRecord
|
23
|
+
#
|
24
|
+
class Tracer
|
25
|
+
##
|
26
|
+
# @param [Bigcommerce::Lightstep::Tracer] tracer
|
27
|
+
# @param [String] span_prefix
|
28
|
+
# @param [Boolean] allow_root_spans
|
29
|
+
# @param [String] span_name
|
30
|
+
#
|
31
|
+
def initialize(tracer: nil, span_prefix: nil, span_name: nil, allow_root_spans: nil)
|
32
|
+
@tracer = tracer || ::Bigcommerce::Lightstep::Tracer.instance
|
33
|
+
@span_prefix = span_prefix || ::Bigcommerce::Lightstep.active_record_span_prefix
|
34
|
+
@span_name = span_name || 'mysql'
|
35
|
+
@allow_root_spans = !allow_root_spans.nil? ? allow_root_spans : ::Bigcommerce::Lightstep.active_record_allow_root_spans
|
36
|
+
end
|
37
|
+
|
38
|
+
##
|
39
|
+
# Trace a DB call
|
40
|
+
#
|
41
|
+
# @param [String] statement
|
42
|
+
# @param [String] host
|
43
|
+
# @param [String] adapter
|
44
|
+
# @param [String] database
|
45
|
+
#
|
46
|
+
def db_trace(statement:, host:, adapter:, database:)
|
47
|
+
return yield unless @tracer
|
48
|
+
|
49
|
+
# skip if not allowing root spans and there is no active span
|
50
|
+
return yield if !@allow_root_spans && !active_span?
|
51
|
+
|
52
|
+
@tracer.start_span(key) do |span|
|
53
|
+
span.set_tag('db.host', host.to_s)
|
54
|
+
span.set_tag('db.type', adapter.to_s)
|
55
|
+
span.set_tag('db.name', database.to_s)
|
56
|
+
span.set_tag('db.statement', statement.to_s)
|
57
|
+
span.set_tag('span.kind', 'client')
|
58
|
+
begin
|
59
|
+
yield
|
60
|
+
rescue StandardError => _e
|
61
|
+
span.set_tag('error', true)
|
62
|
+
raise # re-raise the error
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
##
|
68
|
+
# @return [String]
|
69
|
+
#
|
70
|
+
def key
|
71
|
+
!@span_prefix.to_s.empty? ? "#{@span_prefix}.mysql" : 'mysql'
|
72
|
+
end
|
73
|
+
|
74
|
+
##
|
75
|
+
# @return [Boolean]
|
76
|
+
#
|
77
|
+
def active_span?
|
78
|
+
@tracer.respond_to?(:active_span) && @tracer.active_span
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -23,27 +23,30 @@ module Bigcommerce
|
|
23
23
|
#
|
24
24
|
module Configuration
|
25
25
|
VALID_CONFIG_KEYS = {
|
26
|
-
component_name: '',
|
27
|
-
controller_trace_prefix: 'controllers.',
|
28
|
-
access_token: '',
|
29
|
-
host: 'lightstep-collector.linkerd',
|
26
|
+
component_name: ENV.fetch('LIGHTSTEP_COMPONENT_NAME', ''),
|
27
|
+
controller_trace_prefix: ENV.fetch('LIGHTSTEP_CONTROLLER_PREFIX', 'controllers.'),
|
28
|
+
access_token: ENV.fetch('LIGHTSTEP_ACCESS_TOKEN', ''),
|
29
|
+
host: ENV.fetch('LIGHTSTEP_HOST', 'lightstep-collector.linkerd'),
|
30
30
|
interceptors: nil,
|
31
|
-
port:
|
32
|
-
ssl_verify_peer:
|
33
|
-
open_timeout:
|
34
|
-
read_timeout:
|
31
|
+
port: ENV.fetch('LIGHTSTEP_PORT', 4_140).to_i,
|
32
|
+
ssl_verify_peer: ENV.fetch('LIGHTSTEP_SSL_VERIFY_PEER', 1).to_i.positive?,
|
33
|
+
open_timeout: ENV.fetch('LIGHTSTEP_OPEN_TIMEOUT', 2).to_i,
|
34
|
+
read_timeout: ENV.fetch('LIGHTSTEP_READ_TIMEOUT', 2).to_i,
|
35
35
|
continue_timeout: nil,
|
36
|
-
keep_alive_timeout: 2,
|
36
|
+
keep_alive_timeout: ENV.fetch('LIGHTSTEP_KEEP_ALIVE_TIMEOUT', 2).to_i,
|
37
37
|
logger: nil,
|
38
|
-
verbosity: 1,
|
39
|
-
http1_error_code: 500,
|
40
|
-
http1_error_code_minimum: 500,
|
41
|
-
max_buffered_spans: 1_000,
|
42
|
-
max_log_records: 1_000,
|
43
|
-
max_reporting_interval_seconds: 3.0,
|
44
|
-
redis_excluded_commands:
|
45
|
-
redis_allow_root_spans:
|
46
|
-
|
38
|
+
verbosity: ENV.fetch('LIGHTSTEP_VERBOSITY', 1).to_i,
|
39
|
+
http1_error_code: ENV.fetch('LIGHTSTEP_HTTP1_ERROR_CODE', 500).to_i,
|
40
|
+
http1_error_code_minimum: ENV.fetch('LIGHTSTEP_HTTP1_ERROR_CODE_MINIMUM', 500).to_i,
|
41
|
+
max_buffered_spans: ENV.fetch('LIGHTSTEP_MAX_BUFFERED_SPANS', 1_000).to_i,
|
42
|
+
max_log_records: ENV.fetch('LIGHTSTEP_MAX_LOG_RECORDS', 1_000).to_i,
|
43
|
+
max_reporting_interval_seconds: ENV.fetch('LIGHTSTEP_MAX_REPORTING_INTERVAL_SECONDS', 3.0).to_f,
|
44
|
+
redis_excluded_commands: ENV.fetch('LIGHTSTEP_REDIS_EXCLUDED_COMMANDS', 'ping').to_s.split(','),
|
45
|
+
redis_allow_root_spans: ENV.fetch('LIGHTSTEP_REDIS_ALLOW_AS_ROOT_SPAN', 0).to_i.positive?,
|
46
|
+
active_record: ENV.fetch('LIGHTSTEP_ACTIVE_RECORD_ENABLED', 1).to_i.positive?,
|
47
|
+
active_record_allow_root_spans: ENV.fetch('LIGHTSTEP_ACTIVE_RECORD_ALLOW_AS_ROOT_SPAN', 0).to_i.positive?,
|
48
|
+
active_record_span_prefix: ENV.fetch('LIGHTSTEP_ACTIVE_RECORD_SPAN_PREFIX', ''),
|
49
|
+
enabled: ENV.fetch('LIGHTSTEP_ENABLED', 1).to_i.positive?
|
47
50
|
}.freeze
|
48
51
|
|
49
52
|
attr_accessor *VALID_CONFIG_KEYS.keys
|
@@ -94,22 +97,11 @@ module Bigcommerce
|
|
94
97
|
VALID_CONFIG_KEYS.each do |k, v|
|
95
98
|
send("#{k}=".to_sym, v)
|
96
99
|
end
|
97
|
-
self.component_name = ENV.fetch('LIGHTSTEP_COMPONENT_NAME', '')
|
98
|
-
self.access_token = ENV.fetch('LIGHTSTEP_ACCESS_TOKEN', '')
|
99
|
-
self.host = ENV.fetch('LIGHTSTEP_HOST', 'lightstep-collector.linkerd')
|
100
|
-
self.port = ENV.fetch('LIGHTSTEP_PORT', 4140).to_i
|
101
|
-
self.ssl_verify_peer = ENV.fetch('LIGHTSTEP_SSL_VERIFY_PEER', true)
|
102
|
-
|
103
|
-
self.max_buffered_spans = ENV.fetch('LIGHTSTEP_MAX_BUFFERED_SPANS', 1_000).to_i
|
104
|
-
self.max_log_records = ENV.fetch('LIGHTSTEP_MAX_LOG_RECORDS', 1_000).to_i
|
105
|
-
self.max_reporting_interval_seconds = ENV.fetch('LIGHTSTEP_MAX_REPORTING_INTERVAL_SECONDS', 3.0).to_f
|
106
100
|
|
107
101
|
default_logger = ::Logger.new(STDOUT)
|
108
102
|
default_logger.level = ::Logger::INFO
|
109
103
|
self.logger = defined?(Rails) ? Rails.logger : default_logger
|
110
|
-
self.verbosity = ENV.fetch('LIGHTSTEP_VERBOSITY', 1).to_i
|
111
104
|
|
112
|
-
self.enabled = ENV.fetch('LIGHTSTEP_ENABLED', 1).to_i.positive?
|
113
105
|
self.interceptors = ::Bigcommerce::Lightstep::Interceptors::Registry.new
|
114
106
|
end
|
115
107
|
|
@@ -32,6 +32,10 @@ module Bigcommerce
|
|
32
32
|
encryption: ::Bigcommerce::Lightstep.port.to_i == 443 ? ::Bigcommerce::Lightstep::Transport::ENCRYPTION_TLS : ::Bigcommerce::Lightstep::Transport::ENCRYPTION_NONE,
|
33
33
|
ssl_verify_peer: ::Bigcommerce::Lightstep.ssl_verify_peer,
|
34
34
|
access_token: ::Bigcommerce::Lightstep.access_token,
|
35
|
+
open_timeout: ::Bigcommerce::Lightstep.open_timeout,
|
36
|
+
read_timeout: ::Bigcommerce::Lightstep.read_timeout,
|
37
|
+
continue_timeout: ::Bigcommerce::Lightstep.continue_timeout,
|
38
|
+
keep_alive_timeout: ::Bigcommerce::Lightstep.keep_alive_timeout,
|
35
39
|
logger: ::Bigcommerce::Lightstep.logger
|
36
40
|
)
|
37
41
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bc-lightstep-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shaun McCormick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activerecord
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,16 +56,16 @@ dependencies:
|
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- - "
|
59
|
+
- - ">="
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
61
|
+
version: '12.0'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- - "
|
66
|
+
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
68
|
+
version: '12.0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rspec
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,6 +164,20 @@ dependencies:
|
|
150
164
|
- - "~>"
|
151
165
|
- !ruby/object:Gem::Version
|
152
166
|
version: '4'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: activesupport
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '4'
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '4'
|
153
181
|
- !ruby/object:Gem::Dependency
|
154
182
|
name: lightstep
|
155
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -196,6 +224,8 @@ files:
|
|
196
224
|
- README.md
|
197
225
|
- bc-lightstep-ruby.gemspec
|
198
226
|
- lib/bigcommerce/lightstep.rb
|
227
|
+
- lib/bigcommerce/lightstep/active_record/adapter.rb
|
228
|
+
- lib/bigcommerce/lightstep/active_record/tracer.rb
|
199
229
|
- lib/bigcommerce/lightstep/configuration.rb
|
200
230
|
- lib/bigcommerce/lightstep/errors.rb
|
201
231
|
- lib/bigcommerce/lightstep/interceptors/base.rb
|