bc-lightstep-ruby 1.3.0 → 1.3.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39888ce33cb784b4e9bf294ef12948c14117a68eb0f19ed556c3d1bda47ca35b
|
4
|
+
data.tar.gz: a321672c7e044a5db91d6e58d051058acfaf347fabcb2d736fcac2d1024bad86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '009121dcef8ced54b459af1a4f3349cd50d49e08d5274afe99c14092507c16f48f661fdba98366faf895556053ea13365aaa7eadbe3b6c7aae75e17097c38a41'
|
7
|
+
data.tar.gz: 714da396916d0486762a9e7246bab4e94054ffab51a9db4cd5d14eb07136e03dd74e79abb05023a374d4481fa2fff72fe3b6655d949850799b0cc6e92cf98ea2
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,11 @@ Changelog for the bc-lightstep-ruby gem.
|
|
2
2
|
|
3
3
|
h3. Pending Release
|
4
4
|
|
5
|
+
h3. 1.3.1
|
6
|
+
|
7
|
+
- Add various options to suppress redis trace spam
|
8
|
+
- Fix issue with pipeline commands in redis instrumentation
|
9
|
+
|
5
10
|
h3. 1.3.0
|
6
11
|
|
7
12
|
- Adds automatic Redis instrumentation support
|
data/README.md
CHANGED
@@ -80,6 +80,12 @@ or systems outside of your instrumenting control.
|
|
80
80
|
This gem will automatically detect and instrumnent Redis calls when they are made using the `Redis::Client` class.
|
81
81
|
It will set as tags on the span the host, port, db instance, and the command (but no arguments).
|
82
82
|
|
83
|
+
Note that this will not record redis timings if they are a root span. This is to prevent trace spamming. You can
|
84
|
+
re-enable this by setting the `redis_allow_root_spans` configuration option to `true`.
|
85
|
+
|
86
|
+
It also excludes `ping` commands, and you can provide a custom list by setting the `redis_excluded_commands`
|
87
|
+
configuration option to an array of commands to exclude.
|
88
|
+
|
83
89
|
## License
|
84
90
|
|
85
91
|
Copyright (c) 2018-present, BigCommerce Pty. Ltd. All rights reserved
|
@@ -22,6 +22,23 @@ module Bigcommerce
|
|
22
22
|
# Middleware tracer for Redis clients
|
23
23
|
#
|
24
24
|
class Tracer
|
25
|
+
attr_accessor :tracer
|
26
|
+
|
27
|
+
##
|
28
|
+
# @param [Bigcommerce::Lightstep::Tracer] tracer
|
29
|
+
# @param [Array<String>] excluded_commands
|
30
|
+
# @param [Boolean] allow_root_spans
|
31
|
+
#
|
32
|
+
def initialize(
|
33
|
+
tracer: nil,
|
34
|
+
excluded_commands: nil,
|
35
|
+
allow_root_spans: nil
|
36
|
+
)
|
37
|
+
@tracer = tracer || ::Bigcommerce::Lightstep::Tracer.instance
|
38
|
+
@excluded_commands = excluded_commands || ::Bigcommerce::Lightstep.redis_excluded_commands
|
39
|
+
@allow_root_spans = allow_root_spans.nil? ? ::Bigcommerce::Lightstep.redis_allow_root_spans : allow_root_spans
|
40
|
+
end
|
41
|
+
|
25
42
|
##
|
26
43
|
# @param [String] key
|
27
44
|
# @param [String] statement
|
@@ -30,17 +47,26 @@ module Bigcommerce
|
|
30
47
|
# @param [Integer] port
|
31
48
|
#
|
32
49
|
def trace(key:, statement:, instance:, host:, port:)
|
33
|
-
return yield unless tracer
|
50
|
+
return yield unless @tracer
|
51
|
+
|
52
|
+
# only take the command, not any arguments
|
53
|
+
command = statement.to_s.split(' ').first
|
54
|
+
|
55
|
+
# skip excluded commands
|
56
|
+
return yield if excluded?(command.to_s)
|
57
|
+
|
58
|
+
# skip if not allowing root spans and there is no active span
|
59
|
+
return yield if !@allow_root_spans && !active_span?
|
34
60
|
|
35
61
|
tags = {
|
36
62
|
'db.type' => 'redis',
|
37
|
-
'db.statement' =>
|
63
|
+
'db.statement' => command,
|
38
64
|
'db.instance' => instance,
|
39
65
|
'db.host' => "redis://#{host}:#{port}",
|
40
66
|
'span.kind' => 'client'
|
41
67
|
}
|
42
68
|
|
43
|
-
tracer.start_span(key) do |span|
|
69
|
+
@tracer.start_span(key) do |span|
|
44
70
|
tags.each do |k, v|
|
45
71
|
span.set_tag(k, v)
|
46
72
|
end
|
@@ -55,10 +81,18 @@ module Bigcommerce
|
|
55
81
|
end
|
56
82
|
|
57
83
|
##
|
58
|
-
# @
|
84
|
+
# @param [String] command
|
85
|
+
# @return [Boolean]
|
86
|
+
#
|
87
|
+
def excluded?(command)
|
88
|
+
@excluded_commands.include?(command.to_s)
|
89
|
+
end
|
90
|
+
|
91
|
+
##
|
92
|
+
# @return [Boolean]
|
59
93
|
#
|
60
|
-
def
|
61
|
-
|
94
|
+
def active_span?
|
95
|
+
tracer.respond_to?(:active_span) && tracer.active_span
|
62
96
|
end
|
63
97
|
end
|
64
98
|
end
|
@@ -58,6 +58,7 @@ module Bigcommerce
|
|
58
58
|
def call_pipeline(pipeline)
|
59
59
|
return call_pipeline_original(pipeline) unless bc_lightstep_tracer
|
60
60
|
|
61
|
+
commands = pipeline.try(:commands) || []
|
61
62
|
bc_lightstep_tracer.trace(
|
62
63
|
key: 'redis.pipelined',
|
63
64
|
statement: commands.empty? ? '' : commands.map { |arr| arr.join(' ') }.join(', '),
|