opentelemetry-instrumentation-redis 0.7.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +27 -0
- data/LICENSE +1 -1
- data/README.md +11 -0
- data/lib/opentelemetry-instrumentation-redis.rb +1 -1
- data/lib/opentelemetry/instrumentation.rb +1 -1
- data/lib/opentelemetry/instrumentation/redis.rb +41 -1
- data/lib/opentelemetry/instrumentation/redis/instrumentation.rb +1 -1
- data/lib/opentelemetry/instrumentation/redis/patches/client.rb +15 -9
- data/lib/opentelemetry/instrumentation/redis/utils.rb +2 -21
- data/lib/opentelemetry/instrumentation/redis/version.rb +2 -2
- metadata +23 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78f4cc4746e23f027e95d4f684fefb8700bcd7c95a027fd71bae15c92cdde480
|
4
|
+
data.tar.gz: bc7ca066ca09e317d869a8d219b5d2c4b54f0d4e003a38a7e91240db50c49579
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d03b391f9c894ecb908d321a3c415224ef45413f93ad678d8dfa33d8201a23590c20488ec29bd55d4872823b18fb81fcddcd193a0f9ec9565e42a7d899ade7ca
|
7
|
+
data.tar.gz: 82f24a709bdd20b8fb1332136534d9da7b09f083b8a27222291a4f542492a9efea2c76fd45ff44a056c0150abdbf69da243b142ea7d602368623240d3f995c39
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,32 @@
|
|
1
1
|
# Release History: opentelemetry-instrumentation-redis
|
2
2
|
|
3
|
+
### v0.11.0 / 2020-12-11
|
4
|
+
|
5
|
+
* ADDED: Accept config for redis peer service attribute
|
6
|
+
* ADDED: Move utf8 encoding to common utils
|
7
|
+
* FIXED: Copyright comments to not reference year
|
8
|
+
|
9
|
+
### v0.10.1 / 2020-12-09
|
10
|
+
|
11
|
+
* FIXED: Semantic conventions db.type -> db.system
|
12
|
+
|
13
|
+
### v0.10.0 / 2020-12-03
|
14
|
+
|
15
|
+
* (No significant changes)
|
16
|
+
|
17
|
+
### v0.9.0 / 2020-11-27
|
18
|
+
|
19
|
+
* BREAKING CHANGE: Add timeout for force_flush and shutdown
|
20
|
+
|
21
|
+
* ADDED: Redis attribute propagation
|
22
|
+
* ADDED: Add timeout for force_flush and shutdown
|
23
|
+
|
24
|
+
### v0.8.0 / 2020-10-27
|
25
|
+
|
26
|
+
* BREAKING CHANGE: Remove 'canonical' from status codes
|
27
|
+
|
28
|
+
* FIXED: Remove 'canonical' from status codes
|
29
|
+
|
3
30
|
### v0.7.0 / 2020-10-07
|
4
31
|
|
5
32
|
* DOCS: Added redis documentation
|
data/LICENSE
CHANGED
@@ -186,7 +186,7 @@
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
187
187
|
identification within third-party archives.
|
188
188
|
|
189
|
-
Copyright
|
189
|
+
Copyright The OpenTelemetry Authors
|
190
190
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
192
192
|
you may not use this file except in compliance with the License.
|
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).
|
@@ -1,15 +1,55 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright
|
3
|
+
# Copyright The OpenTelemetry Authors
|
4
4
|
#
|
5
5
|
# SPDX-License-Identifier: Apache-2.0
|
6
6
|
|
7
7
|
require 'opentelemetry'
|
8
|
+
require 'opentelemetry/common'
|
8
9
|
|
9
10
|
module OpenTelemetry
|
10
11
|
module Instrumentation
|
11
12
|
# Contains the OpenTelemetry instrumentation for the Redis gem
|
12
13
|
module Redis
|
14
|
+
extend self
|
15
|
+
|
16
|
+
CURRENT_ATTRIBUTES_HASH = Context.create_key('current-attributes-hash')
|
17
|
+
|
18
|
+
private_constant :CURRENT_ATTRIBUTES_HASH
|
19
|
+
|
20
|
+
# Returns the attributes hash representing the Redis client context found
|
21
|
+
# in the optional context or the current context if none is provided.
|
22
|
+
#
|
23
|
+
# @param [optional Context] context The context to lookup the current
|
24
|
+
# attributes hash. Defaults to Context.current
|
25
|
+
def attributes(context = nil)
|
26
|
+
context ||= Context.current
|
27
|
+
context.value(CURRENT_ATTRIBUTES_HASH) || {}
|
28
|
+
end
|
29
|
+
|
30
|
+
# Returns a context containing the merged attributes hash, derived from the
|
31
|
+
# optional parent context, or the current context if one was not provided.
|
32
|
+
#
|
33
|
+
# @param [optional Context] context The context to use as the parent for
|
34
|
+
# the returned context
|
35
|
+
def context_with_attributes(attributes_hash, parent_context: Context.current)
|
36
|
+
attributes_hash = attributes(parent_context).merge(attributes_hash)
|
37
|
+
parent_context.set_value(CURRENT_ATTRIBUTES_HASH, attributes_hash)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Activates/deactivates the merged attributes hash within the current Context,
|
41
|
+
# which makes the "current attributes hash" available implicitly.
|
42
|
+
#
|
43
|
+
# On exit, the attributes hash that was active before calling this method
|
44
|
+
# will be reactivated.
|
45
|
+
#
|
46
|
+
# @param [Span] span the span to activate
|
47
|
+
# @yield [Hash, Context] yields attributes hash and a context containing the
|
48
|
+
# attributes hash to the block.
|
49
|
+
def with_attributes(attributes_hash)
|
50
|
+
attributes_hash = attributes.merge(attributes_hash)
|
51
|
+
Context.with_value(CURRENT_ATTRIBUTES_HASH, attributes_hash) { |c, h| yield h, c }
|
52
|
+
end
|
13
53
|
end
|
14
54
|
end
|
15
55
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright
|
3
|
+
# Copyright The OpenTelemetry Authors
|
4
4
|
#
|
5
5
|
# SPDX-License-Identifier: Apache-2.0
|
6
6
|
|
@@ -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,18 +48,24 @@ module OpenTelemetry
|
|
48
48
|
host = options[:host]
|
49
49
|
port = options[:port]
|
50
50
|
|
51
|
-
{
|
52
|
-
'db.
|
51
|
+
attributes = {
|
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
|
+
attributes['peer.service'] = config[:peer_service] if config[:peer_service]
|
59
|
+
attributes.merge(OpenTelemetry::Instrumentation::Redis.attributes)
|
58
60
|
end
|
59
61
|
|
60
62
|
def tracer
|
61
63
|
Redis::Instrumentation.instance.tracer
|
62
64
|
end
|
65
|
+
|
66
|
+
def config
|
67
|
+
Redis::Instrumentation.instance.config
|
68
|
+
end
|
63
69
|
end
|
64
70
|
end
|
65
71
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright
|
3
|
+
# Copyright The OpenTelemetry Authors
|
4
4
|
#
|
5
5
|
# SPDX-License-Identifier: Apache-2.0
|
6
6
|
|
@@ -11,7 +11,6 @@ module OpenTelemetry
|
|
11
11
|
module Utils
|
12
12
|
extend self
|
13
13
|
|
14
|
-
STRING_PLACEHOLDER = ''.encode(::Encoding::UTF_8).freeze
|
15
14
|
PLACEHOLDER = '?'
|
16
15
|
VALUE_MAX_LEN = 50
|
17
16
|
CMD_MAX_LEN = 500
|
@@ -36,7 +35,7 @@ module OpenTelemetry
|
|
36
35
|
|
37
36
|
def format_arg(arg)
|
38
37
|
str = arg.is_a?(Symbol) ? arg.to_s.upcase : arg.to_s
|
39
|
-
str = utf8_encode(str, binary: true
|
38
|
+
str = OpenTelemetry::Common::Utilities.utf8_encode(str, binary: true)
|
40
39
|
truncate(str, VALUE_MAX_LEN)
|
41
40
|
rescue StandardError => e
|
42
41
|
OpenTelemetry.logger.debug("non formattable Redis arg #{str}: #{e}")
|
@@ -60,24 +59,6 @@ module OpenTelemetry
|
|
60
59
|
def truncate(string, size)
|
61
60
|
string.size > size ? "#{string[0...size - 3]}..." : string
|
62
61
|
end
|
63
|
-
|
64
|
-
def utf8_encode(str, options = {})
|
65
|
-
str = str.to_s
|
66
|
-
|
67
|
-
if options[:binary]
|
68
|
-
# This option is useful for "gracefully" displaying binary data that
|
69
|
-
# often contains text such as marshalled objects
|
70
|
-
str.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
|
71
|
-
elsif str.encoding == ::Encoding::UTF_8
|
72
|
-
str
|
73
|
-
else
|
74
|
-
str.encode(::Encoding::UTF_8)
|
75
|
-
end
|
76
|
-
rescue StandardError => e
|
77
|
-
OpenTelemetry.logger.debug("Error encoding string in UTF-8: #{e}")
|
78
|
-
|
79
|
-
options.fetch(:placeholder, STRING_PLACEHOLDER)
|
80
|
-
end
|
81
62
|
end
|
82
63
|
end
|
83
64
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright
|
3
|
+
# Copyright The OpenTelemetry Authors
|
4
4
|
#
|
5
5
|
# SPDX-License-Identifier: Apache-2.0
|
6
6
|
|
7
7
|
module OpenTelemetry
|
8
8
|
module Instrumentation
|
9
9
|
module Redis
|
10
|
-
VERSION = '0.
|
10
|
+
VERSION = '0.11.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.
|
4
|
+
version: 0.11.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-
|
11
|
+
date: 2020-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -16,14 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.11.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.11.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: opentelemetry-common
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.11.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.11.0
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: appraisal
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -185,7 +199,11 @@ files:
|
|
185
199
|
homepage: https://github.com/open-telemetry/opentelemetry-ruby
|
186
200
|
licenses:
|
187
201
|
- Apache-2.0
|
188
|
-
metadata:
|
202
|
+
metadata:
|
203
|
+
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-redis/v0.11.0/file.CHANGELOG.html
|
204
|
+
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/master/instrumentation/redis
|
205
|
+
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
|
206
|
+
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-redis/v0.11.0
|
189
207
|
post_install_message:
|
190
208
|
rdoc_options: []
|
191
209
|
require_paths:
|