opentelemetry-instrumentation-redis 0.5.0 → 0.10.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: d87409ac9ebb5065f9eb91380b7faf74824a15f496596c96f3341eba53581e22
4
- data.tar.gz: bc8d4e6f3a176662055cf4abb4c2d55a9a0aa8584d798f32cebca5cab19cb86b
3
+ metadata.gz: 114bcbc6abbcb6db657f2f04062d62c4c99b8122a0ade3a5da6fa611dd72e68c
4
+ data.tar.gz: 24b22dda3eaa35007d9d01278e3ccdd56d3dfd004117996726ef7dc9d95aa73e
5
5
  SHA512:
6
- metadata.gz: 298cf5385ab6829c7c671ca09f12293c353d2eecf080f82500f48df84ddc925b091cf106db6673396be51eeb03aec5614ed1c3cf4d0e72bf23971bd669545acc
7
- data.tar.gz: 44f0c89b788a0331077397c127ae5ed5942a16f099963904e2eba0a2c799d0c15fcb6a3d55f4a8dd1564006c35eb5c07077c75b23596c9124fdfae7e8e5c5e7d
6
+ metadata.gz: 04f036f00d5edb595d4eb25af5cb27f88c9cf71f9e2a5fbca3dde01ec5c43b297c8270fafb0444faad66e63671c6bf1dc0910315f8b2235c10ed20fe99c0eea5
7
+ data.tar.gz: fe136b8cdec06cb035e1c5678d2c5232c62e5d41d06ba336ad2c584c2d158b8f52a318414e1236681d1e4911d90a8b044ec620126052000bc2bd6b45821fdd6d
@@ -0,0 +1,9 @@
1
+ --no-private
2
+ --title=OpenTelemetry Redis Instrumentation
3
+ --markup=markdown
4
+ --main=README.md
5
+ ./lib/opentelemetry/instrumentation/**/*.rb
6
+ ./lib/opentelemetry/instrumentation.rb
7
+ -
8
+ README.md
9
+ CHANGELOG.md
@@ -0,0 +1,27 @@
1
+ # Release History: opentelemetry-instrumentation-redis
2
+
3
+ ### v0.10.0 / 2020-12-03
4
+
5
+ * (No significant changes)
6
+
7
+ ### v0.9.0 / 2020-11-27
8
+
9
+ * BREAKING CHANGE: Add timeout for force_flush and shutdown
10
+
11
+ * ADDED: Redis attribute propagation
12
+ * ADDED: Add timeout for force_flush and shutdown
13
+
14
+ ### v0.8.0 / 2020-10-27
15
+
16
+ * BREAKING CHANGE: Remove 'canonical' from status codes
17
+
18
+ * FIXED: Remove 'canonical' from status codes
19
+
20
+ ### v0.7.0 / 2020-10-07
21
+
22
+ * DOCS: Added redis documentation
23
+ * DOCS: Standardize toplevel docs structure and readme
24
+
25
+ ### v0.6.0 / 2020-09-10
26
+
27
+ * (No significant changes)
@@ -0,0 +1,64 @@
1
+ # OpenTelemetry Redis Instrumentation
2
+
3
+ The OpenTelemetry Redis Ruby gem is a community maintained instrumentation for [Redis][redis-home]. This is an in-memory data store that is used as a database, cache, and message broker.
4
+
5
+ ## How do I get started?
6
+
7
+ Install the gem using:
8
+
9
+ ```
10
+ gem install opentelemetry-instrumentation-redis
11
+ ```
12
+
13
+ Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-redis` in your `Gemfile`.
14
+
15
+ ## Usage
16
+
17
+ To install the instrumentation, call `use` with the name of the instrumentation.
18
+
19
+ ```ruby
20
+ OpenTelemetry::SDK.configure do |c|
21
+ c.use 'OpenTelemetry::Instrumentation::Redis'
22
+ end
23
+ ```
24
+
25
+ Alternatively, you can also call `use_all` to install all the available instrumentation.
26
+
27
+ ```ruby
28
+ OpenTelemetry::SDK.configure do |c|
29
+ c.use_all
30
+ end
31
+ ```
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
+
44
+ ## Example
45
+
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).
47
+
48
+ ## How can I get involved?
49
+
50
+ The `opentelemetry-instrumentation-redis` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`.
51
+
52
+ The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us on our [gitter channel][ruby-gitter] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig].
53
+
54
+ ## License
55
+
56
+ Apache 2.0 license. See [LICENSE][license-github] for more information.
57
+
58
+ [redis-home]: https://redis.io
59
+ [bundler-home]: https://bundler.io
60
+ [repo-github]: https://github.com/open-telemetry/opentelemetry-ruby
61
+ [license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/master/LICENSE
62
+ [ruby-sig]: https://github.com/open-telemetry/community#ruby-sig
63
+ [community-meetings]: https://github.com/open-telemetry/community#community-meetings
64
+ [ruby-gitter]: https://gitter.im/open-telemetry/opentelemetry-ruby
@@ -4,6 +4,12 @@
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
7
+ # OpenTelemetry is an open source observability framework, providing a
8
+ # general-purpose API, SDK, and related tools required for the instrumentation
9
+ # of cloud-native software, frameworks, and libraries.
10
+ #
11
+ # The OpenTelemetry module provides global accessors for telemetry objects.
12
+ # See the documentation for the `opentelemetry-api` gem for details.
7
13
  module OpenTelemetry
8
14
  # "Instrumentation" are specified by
9
15
  # https://github.com/open-telemetry/opentelemetry-specification/blob/784635d01d8690c8f5fcd1f55bdbc8a13cf2f4f2/specification/glossary.md#instrumentation-library
@@ -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.5.0'
10
+ VERSION = '0.10.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.5.0
4
+ version: 0.10.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-07-17 00:00:00.000000000 Z
11
+ date: 2020-12-03 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.5.0
19
+ version: 0.10.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.5.0
26
+ version: 0.10.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: appraisal
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -171,7 +171,10 @@ executables: []
171
171
  extensions: []
172
172
  extra_rdoc_files: []
173
173
  files:
174
+ - ".yardopts"
175
+ - CHANGELOG.md
174
176
  - LICENSE
177
+ - README.md
175
178
  - lib/opentelemetry-instrumentation-redis.rb
176
179
  - lib/opentelemetry/instrumentation.rb
177
180
  - lib/opentelemetry/instrumentation/redis.rb
@@ -182,7 +185,11 @@ files:
182
185
  homepage: https://github.com/open-telemetry/opentelemetry-ruby
183
186
  licenses:
184
187
  - Apache-2.0
185
- metadata: {}
188
+ metadata:
189
+ changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-redis/v0.10.0/file.CHANGELOG.html
190
+ source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/master/instrumentation/redis
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.10.0
186
193
  post_install_message:
187
194
  rdoc_options: []
188
195
  require_paths:
@@ -198,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
205
  - !ruby/object:Gem::Version
199
206
  version: '0'
200
207
  requirements: []
201
- rubygems_version: 3.0.3
208
+ rubygems_version: 3.1.4
202
209
  signing_key:
203
210
  specification_version: 4
204
211
  summary: Redis instrumentation for the OpenTelemetry framework