opentelemetry-instrumentation-redis 0.6.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +9 -0
- data/CHANGELOG.md +26 -0
- data/README.md +64 -0
- data/lib/opentelemetry/instrumentation.rb +6 -0
- data/lib/opentelemetry/instrumentation/redis.rb +39 -0
- data/lib/opentelemetry/instrumentation/redis/patches/client.rb +9 -9
- data/lib/opentelemetry/instrumentation/redis/version.rb +1 -1
- metadata +12 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a93d653f708181eb2444eb61c70e36aa2952af1feed88bc51b577a13b8ceeba
|
4
|
+
data.tar.gz: 2c7d4e6502891c82db5ca55a9a0f741818e00bff1146dcd265fb8730df44e4bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '01946188e0f89d528e359eede3796d87928882b60861b84e9759f812b140ea300c60f4527be595d947fb648095cbe57c9a9a7e7dec6e3614afb5b1a47625815b'
|
7
|
+
data.tar.gz: 37adb69dca5235cdd89fe6363d159fddd365dc3a5186e7dc764f44208231758e3d9a3cf23e8cd55fb1eabf5d4f98e805ab6917907eb07642a42b30e2cf37d823
|
data/.yardopts
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,31 @@
|
|
1
1
|
# Release History: opentelemetry-instrumentation-redis
|
2
2
|
|
3
|
+
### v0.10.1 / 2020-12-09
|
4
|
+
|
5
|
+
* FIXED: Semantic conventions db.type -> db.system
|
6
|
+
|
7
|
+
### v0.10.0 / 2020-12-03
|
8
|
+
|
9
|
+
* (No significant changes)
|
10
|
+
|
11
|
+
### v0.9.0 / 2020-11-27
|
12
|
+
|
13
|
+
* BREAKING CHANGE: Add timeout for force_flush and shutdown
|
14
|
+
|
15
|
+
* ADDED: Redis attribute propagation
|
16
|
+
* ADDED: Add timeout for force_flush and shutdown
|
17
|
+
|
18
|
+
### v0.8.0 / 2020-10-27
|
19
|
+
|
20
|
+
* BREAKING CHANGE: Remove 'canonical' from status codes
|
21
|
+
|
22
|
+
* FIXED: Remove 'canonical' from status codes
|
23
|
+
|
24
|
+
### v0.7.0 / 2020-10-07
|
25
|
+
|
26
|
+
* DOCS: Added redis documentation
|
27
|
+
* DOCS: Standardize toplevel docs structure and readme
|
28
|
+
|
3
29
|
### v0.6.0 / 2020-09-10
|
4
30
|
|
5
31
|
* (No significant changes)
|
data/README.md
ADDED
@@ -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:
|
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:
|
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
|
-
|
52
|
-
'db.
|
51
|
+
OpenTelemetry::Instrumentation::Redis.attributes.merge(
|
52
|
+
'db.system' => '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
|
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.
|
4
|
+
version: 0.10.1
|
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-09
|
11
|
+
date: 2020-12-09 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.
|
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.
|
26
|
+
version: 0.10.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: appraisal
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -171,8 +171,10 @@ executables: []
|
|
171
171
|
extensions: []
|
172
172
|
extra_rdoc_files: []
|
173
173
|
files:
|
174
|
+
- ".yardopts"
|
174
175
|
- CHANGELOG.md
|
175
176
|
- LICENSE
|
177
|
+
- README.md
|
176
178
|
- lib/opentelemetry-instrumentation-redis.rb
|
177
179
|
- lib/opentelemetry/instrumentation.rb
|
178
180
|
- lib/opentelemetry/instrumentation/redis.rb
|
@@ -183,7 +185,11 @@ files:
|
|
183
185
|
homepage: https://github.com/open-telemetry/opentelemetry-ruby
|
184
186
|
licenses:
|
185
187
|
- Apache-2.0
|
186
|
-
metadata:
|
188
|
+
metadata:
|
189
|
+
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-redis/v0.10.1/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.1
|
187
193
|
post_install_message:
|
188
194
|
rdoc_options: []
|
189
195
|
require_paths:
|
@@ -199,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
205
|
- !ruby/object:Gem::Version
|
200
206
|
version: '0'
|
201
207
|
requirements: []
|
202
|
-
rubygems_version: 3.1.
|
208
|
+
rubygems_version: 3.1.4
|
203
209
|
signing_key:
|
204
210
|
specification_version: 4
|
205
211
|
summary: Redis instrumentation for the OpenTelemetry framework
|