opentelemetry-instrumentation-redis 0.8.0 → 0.9.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
2
  SHA256:
3
- metadata.gz: f3e631a5b9876f26498dfe8efd928cc664c5de73975b6a8c1921514b4cf87550
4
- data.tar.gz: f6d40b30457ea65d8d19d3d349d4e4dad7b5ea36549f85b067338396b2384afd
3
+ metadata.gz: 1920f7074fc5c2fd6af2d2ecdda802d5206e5badfd43ad5ac645af1d0cac5a0e
4
+ data.tar.gz: af34ef6574c6425486f273b6d219f89314ea001575fb1057eb94e60a4f47b6df
5
5
  SHA512:
6
- metadata.gz: c2358a85cc9562c6e1a675e549746154da8f72877317e4055cf6582121c3c61e303e92d2d01840af213ad27f07dbd507d80707ab7a79bc0adb1994cb6cfddcf9
7
- data.tar.gz: aad5ddbe0c9465fc2cee76886535d20f88b61ab1bdc6a27340f9de76c27efbddfbf9fcf23c52f1021d8e819d3d46e631b39b77b211b81a5fb70b917fd77efb28
6
+ metadata.gz: 4cabad81823ae23a7355bf9eb22611eaa6b86b646741651e72f49e08acb42efd196d5a8a1f4adde5b6c63415208ded15697f4869e70a29b0e629973955ba67ad
7
+ data.tar.gz: 4bd86b68fc024dddd1f91f6f1fa430a54696f4b63fff102a14d3badc6920bd3ab28df32c2632636b173e52074792fc1df4a88d3317b91f9f17d84f35d1d9385a
@@ -1,5 +1,12 @@
1
1
  # Release History: opentelemetry-instrumentation-redis
2
2
 
3
+ ### v0.9.0 / 2020-11-27
4
+
5
+ * BREAKING CHANGE: Add timeout for force_flush and shutdown
6
+
7
+ * ADDED: Redis attribute propagation
8
+ * ADDED: Add timeout for force_flush and shutdown
9
+
3
10
  ### v0.8.0 / 2020-10-27
4
11
 
5
12
  * BREAKING CHANGE: Remove 'canonical' from status codes
data/README.md CHANGED
@@ -30,6 +30,17 @@ OpenTelemetry::SDK.configure do |c|
30
30
  end
31
31
  ```
32
32
 
33
+ The Redis instrumentation allows the user to supply additional attributes via context propagation. This may be used to propagate attributes from instrumentation for things like Resque and Sidekiq, for example, to attach to the Redis client spans.
34
+
35
+ ```ruby
36
+ require 'opentelemetry/instrumentation/redis'
37
+
38
+ redis = ::Redis.new
39
+ OpenTelemetry::Instrumentation::Redis.with_attributes('peer.service' => 'cache') do
40
+ redis.set('K', 'x')
41
+ end
42
+ ```
43
+
33
44
  ## Example
34
45
 
35
46
  An example of usage can be seen in [`example/redis.rb`](https://github.com/open-telemetry/opentelemetry-ruby/blob/master/instrumentation/redis/example/redis.rb).
@@ -10,6 +10,45 @@ module OpenTelemetry
10
10
  module Instrumentation
11
11
  # Contains the OpenTelemetry instrumentation for the Redis gem
12
12
  module Redis
13
+ extend self
14
+
15
+ CURRENT_ATTRIBUTES_HASH = Context.create_key('current-attributes-hash')
16
+
17
+ private_constant :CURRENT_ATTRIBUTES_HASH
18
+
19
+ # Returns the attributes hash representing the Redis client context found
20
+ # in the optional context or the current context if none is provided.
21
+ #
22
+ # @param [optional Context] context The context to lookup the current
23
+ # attributes hash. Defaults to Context.current
24
+ def attributes(context = nil)
25
+ context ||= Context.current
26
+ context.value(CURRENT_ATTRIBUTES_HASH) || {}
27
+ end
28
+
29
+ # Returns a context containing the merged attributes hash, derived from the
30
+ # optional parent context, or the current context if one was not provided.
31
+ #
32
+ # @param [optional Context] context The context to use as the parent for
33
+ # the returned context
34
+ def context_with_attributes(attributes_hash, parent_context: Context.current)
35
+ attributes_hash = attributes(parent_context).merge(attributes_hash)
36
+ parent_context.set_value(CURRENT_ATTRIBUTES_HASH, attributes_hash)
37
+ end
38
+
39
+ # Activates/deactivates the merged attributes hash within the current Context,
40
+ # which makes the "current attributes hash" available implicitly.
41
+ #
42
+ # On exit, the attributes hash that was active before calling this method
43
+ # will be reactivated.
44
+ #
45
+ # @param [Span] span the span to activate
46
+ # @yield [Hash, Context] yields attributes hash and a context containing the
47
+ # attributes hash to the block.
48
+ def with_attributes(attributes_hash)
49
+ attributes_hash = attributes.merge(attributes_hash)
50
+ Context.with_value(CURRENT_ATTRIBUTES_HASH, attributes_hash) { |c, h| yield h, c }
51
+ end
13
52
  end
14
53
  end
15
54
  end
@@ -13,11 +13,11 @@ module OpenTelemetry
13
13
  def call(*args, &block)
14
14
  response = nil
15
15
 
16
+ attributes = client_attributes
17
+ attributes['db.statement'] = Utils.format_statement(args)
16
18
  tracer.in_span(
17
19
  Utils.format_command(args),
18
- attributes: client_attributes.merge(
19
- 'db.statement' => Utils.format_statement(args)
20
- ),
20
+ attributes: attributes,
21
21
  kind: :client
22
22
  ) do
23
23
  response = super(*args, &block)
@@ -29,11 +29,11 @@ module OpenTelemetry
29
29
  def call_pipeline(*args, &block)
30
30
  response = nil
31
31
 
32
+ attributes = client_attributes
33
+ attributes['db.statement'] = Utils.format_pipeline_statement(args)
32
34
  tracer.in_span(
33
35
  'pipeline',
34
- attributes: client_attributes.merge(
35
- 'db.statement' => Utils.format_pipeline_statement(args)
36
- ),
36
+ attributes: attributes,
37
37
  kind: :client
38
38
  ) do
39
39
  response = super(*args, &block)
@@ -48,13 +48,13 @@ module OpenTelemetry
48
48
  host = options[:host]
49
49
  port = options[:port]
50
50
 
51
- {
51
+ OpenTelemetry::Instrumentation::Redis.attributes.merge(
52
52
  'db.type' => 'redis',
53
53
  'db.instance' => options[:db].to_s,
54
54
  'db.url' => "redis://#{host}:#{port}",
55
55
  'net.peer.name' => host,
56
56
  'net.peer.port' => port
57
- }
57
+ )
58
58
  end
59
59
 
60
60
  def tracer
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module Redis
10
- VERSION = '0.8.0'
10
+ VERSION = '0.9.0'
11
11
  end
12
12
  end
13
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentelemetry-instrumentation-redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenTelemetry Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-27 00:00:00.000000000 Z
11
+ date: 2020-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.8.0
19
+ version: 0.9.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.8.0
26
+ version: 0.9.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: appraisal
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -186,10 +186,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
186
186
  licenses:
187
187
  - Apache-2.0
188
188
  metadata:
189
- changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-redis/v0.8.0/file.CHANGELOG.html
189
+ changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-redis/v0.9.0/file.CHANGELOG.html
190
190
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/master/instrumentation/redis
191
191
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
192
- documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-redis/v0.8.0
192
+ documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-redis/v0.9.0
193
193
  post_install_message:
194
194
  rdoc_options: []
195
195
  require_paths: