redis-instrumentation 0.1.1 → 0.2.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 +5 -5
- data/README.md +3 -2
- data/lib/redis/instrumentation.rb +12 -5
- data/lib/redis/instrumentation/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b8eab7cfc0b5e410c65e7140d1a3ccc5f959ac30fe3b63f651cede6dc244b946
|
4
|
+
data.tar.gz: 33a4dfcf246154419ff92198a5c5586f1bcdbb00bf3a7cc3a1442054070a7239
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00a5db36b910cf3887c59aaff692130e9af5108e46c54114caf1d2917a80e3792b6227d1366be945cae50fb9fde29b7187f31709a03feb98201851c92bc25eff
|
7
|
+
data.tar.gz: b59526825e138da5a409fe62a351966ac2d83be7f130a380850dcf6e85819a6a4c195cfdc1b441b6cc39697658ff2daa33af996ba888563448ea9f8e059a677f
|
data/README.md
CHANGED
@@ -31,8 +31,9 @@ require 'redis/instrumentation'
|
|
31
31
|
Redis::Instrumentation.instrument
|
32
32
|
```
|
33
33
|
|
34
|
-
`instrument` takes
|
35
|
-
tracer. It will default to `OpenTracing.global_tracer`.
|
34
|
+
`instrument` takes two optional arguments:
|
35
|
+
* `tracer`, to set a custom OpenTracing tracer. It will default to `OpenTracing.global_tracer`.
|
36
|
+
* `db_statement_length`, to set a maximum value length for the `db.statement` tag. It will not truncate by default.
|
36
37
|
|
37
38
|
## Development
|
38
39
|
|
@@ -14,8 +14,10 @@ class Redis
|
|
14
14
|
class << self
|
15
15
|
|
16
16
|
attr_accessor :tracer
|
17
|
+
attr_accessor :db_statement_length
|
17
18
|
|
18
|
-
def instrument(tracer: OpenTracing.global_tracer
|
19
|
+
def instrument(tracer: OpenTracing.global_tracer,
|
20
|
+
db_statement_length: nil)
|
19
21
|
begin
|
20
22
|
require 'redis'
|
21
23
|
rescue LoadError => e
|
@@ -23,6 +25,7 @@ class Redis
|
|
23
25
|
end
|
24
26
|
|
25
27
|
@tracer = tracer
|
28
|
+
@db_statement_length = db_statement_length
|
26
29
|
|
27
30
|
patch_client if !@patched_client
|
28
31
|
@patched_client = true
|
@@ -35,7 +38,9 @@ class Redis
|
|
35
38
|
|
36
39
|
def call(command, trace: true, &block)
|
37
40
|
tags = ::Redis::Instrumentation::COMMON_TAGS.dup
|
38
|
-
|
41
|
+
statement = command.join(' ')
|
42
|
+
statement = statement.to_s[0, ::Redis::Instrumentation::db_statement_length] if ::Redis::Instrumentation::db_statement_length
|
43
|
+
tags['db.statement'] = statement
|
39
44
|
tags['db.instance'] = db
|
40
45
|
tags['peer.address'] = "redis://#{host}:#{port}"
|
41
46
|
|
@@ -46,7 +51,7 @@ class Redis
|
|
46
51
|
rescue => e
|
47
52
|
if scope
|
48
53
|
scope.span.set_tag("error", true)
|
49
|
-
scope.span.log_kv(
|
54
|
+
scope.span.log_kv("error.kind": e.class.name, message: e.message, "error.object": e)
|
50
55
|
end
|
51
56
|
raise e
|
52
57
|
ensure
|
@@ -56,7 +61,9 @@ class Redis
|
|
56
61
|
def call_pipeline(pipeline)
|
57
62
|
commands = pipeline.commands
|
58
63
|
tags = ::Redis::Instrumentation::COMMON_TAGS.dup
|
59
|
-
|
64
|
+
statement = commands.empty? ? "" : commands.map{ |arr| arr.join(' ') }.join(', ')
|
65
|
+
statement = statement.to_s[0, ::Redis::Instrumentation::db_statement_length] if ::Redis::Instrumentation::db_statement_length
|
66
|
+
tags['db.statement'] = statement
|
60
67
|
tags['db.instance'] = db
|
61
68
|
tags['peer.address'] = "redis://#{host}:#{port}"
|
62
69
|
|
@@ -66,7 +73,7 @@ class Redis
|
|
66
73
|
rescue => e
|
67
74
|
if scope
|
68
75
|
scope.span.set_tag("error", true)
|
69
|
-
scope.span.log_kv(
|
76
|
+
scope.span.log_kv("error.kind": e.class.name, message: e.message, "error.object": e)
|
70
77
|
end
|
71
78
|
raise e
|
72
79
|
ensure
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-instrumentation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SignalFx, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentracing
|
@@ -145,8 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
145
|
- !ruby/object:Gem::Version
|
146
146
|
version: '0'
|
147
147
|
requirements: []
|
148
|
-
|
149
|
-
rubygems_version: 2.5.2
|
148
|
+
rubygems_version: 3.0.6
|
150
149
|
signing_key:
|
151
150
|
specification_version: 4
|
152
151
|
summary: OpenTracing instrumentation for the Redis Ruby client.
|