redis-instrumentation 0.1.1 → 0.2.0

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
- SHA1:
3
- metadata.gz: 2d04217feb47f5d217db782cf7636e61fb9b91dd
4
- data.tar.gz: dd50b32ff96d43ade45d29183dc2fee532abc2e6
2
+ SHA256:
3
+ metadata.gz: b8eab7cfc0b5e410c65e7140d1a3ccc5f959ac30fe3b63f651cede6dc244b946
4
+ data.tar.gz: 33a4dfcf246154419ff92198a5c5586f1bcdbb00bf3a7cc3a1442054070a7239
5
5
  SHA512:
6
- metadata.gz: 396b6c3bff9aa492ca40d9a6675c357d9a1b4ee4429ba3dfb53a5375d999c1b1c8ad0126b5912fbb887b288889d7b328aff4008e52c31b447b52db8bab5096e1
7
- data.tar.gz: 89795a5a9457dcfdbfb50af35efd28697745908ae6d28db686d43a34cd610b0ad4fe7701e5226d61cbc70b4d9abee4603e5e0d6a5bd21069a14b1462626e784d
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 an optional argument, `tracer`, to set a custom OpenTracing
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
- tags['db.statement'] = command.join(' ')
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(key: "message", value: e.message)
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
- tags['db.statement'] = commands.empty? ? "" : commands.map{ |arr| arr.join(' ') }.join(', ')
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(key: "message", value: e.message)
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
@@ -1,3 +1,3 @@
1
1
  module RedisInstrumentation
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.1
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: 2019-08-14 00:00:00.000000000 Z
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
- rubyforge_project:
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.