opentelemetry-instrumentation-mongo 0.20.0 → 0.21.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: cd55b775b9538cf3addb8aa08c1fbbf34d028855ee96bf9999fab9dedd17a47c
4
- data.tar.gz: 48347c6004b7daa37081568061a2d7303cfa6ccf4fa60160194f66b3a9a9a4d2
3
+ metadata.gz: 85f1636546167aa1e9e6603257eeb965dbb08f9c5bc26050c15cc929758e847d
4
+ data.tar.gz: 15dc6ba2a31cbe827bd81d16edc5aa8a8de6635a3822dba0479adf9de50d61bf
5
5
  SHA512:
6
- metadata.gz: 191a28783347264e83c5da357e0f573485795ec0737e2f4e67f335df70c1abce587582d4c17dca1f44020d0649bfd1941946dfae744f1350065a3d0169b35a6d
7
- data.tar.gz: 10c534b18f976758ac63be01539e51c872b40feabb06a88703a4e6c9f7268c92fb2d7b71a242530ee20cb04292eb96270b06e406928bbe3534f3b0fe36c2a474
6
+ metadata.gz: '08fd54a2850631ac755508538495dc9fc91507a7827437ca4e046dfaa685eaee3a81c54f3c995bc33d74754e7fda385c4a1fd1f67c362404cf0059a7a219b677'
7
+ data.tar.gz: e958b40ba06c2f5f28baf26877fba8ecb3056dc600c4068aa71a6d3919434447eba2cddb8f9269e28cc367fe8bf21b1e7696340ef807aae337814b9bcc36b6f0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Release History: opentelemetry-instrumentation-mongo
2
2
 
3
+ ### v0.21.0 / 2022-10-04
4
+
5
+ * ADDED: Support mongodb db statement without obfuscation
6
+
3
7
  ### v0.20.0 / 2022-06-09
4
8
 
5
9
  * Upgrading Base dependency version
data/README.md CHANGED
@@ -30,6 +30,20 @@ OpenTelemetry::SDK.configure do |c|
30
30
  end
31
31
  ```
32
32
 
33
+ ### Configuration options
34
+
35
+ ```ruby
36
+ OpenTelemetry::SDK.configure do |c|
37
+ c.use 'OpenTelemetry::Instrumentation::Mongo', {
38
+ # Sets how db_statement appears in your traces. The options are:
39
+ # :obfuscate - (default) query parameters are visible, but values are masked.
40
+ # :include - query parameters and values are both fully visible.
41
+ # :omit - db_statement is omitted entirely.
42
+ db_statement: :include,
43
+ }
44
+ end
45
+ ```
46
+
33
47
  ## Example
34
48
 
35
49
  To run the example:
@@ -57,8 +71,7 @@ Apache 2.0 license. See [LICENSE][license-github] for more information.
57
71
  [mongo-home]: https://github.com/mongodb/mongo-ruby-driver
58
72
  [bundler-home]: https://bundler.io
59
73
  [repo-github]: https://github.com/open-telemetry/opentelemetry-ruby
60
- [license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE
74
+ [license-github]: https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/main/LICENSE
61
75
  [ruby-sig]: https://github.com/open-telemetry/community#ruby-sig
62
76
  [community-meetings]: https://github.com/open-telemetry/community#community-meetings
63
77
  [discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions
64
-
@@ -14,10 +14,10 @@ module OpenTelemetry
14
14
 
15
15
  attr_reader :command, :command_name, :collection, :payload
16
16
 
17
- def initialize(command)
17
+ def initialize(command, obfuscate)
18
18
  @command = command
19
19
  @command_name, @collection = command.first
20
- @collection = MASK_VALUE unless @collection.is_a?(String) || @collection.is_a?(Integer)
20
+ @obfuscate = obfuscate
21
21
  @payload = {}
22
22
  end
23
23
 
@@ -35,7 +35,7 @@ module OpenTelemetry
35
35
  build_pipeline
36
36
  end
37
37
 
38
- def build_command # rubocop:disable Metrics/AbcSize
38
+ def build_command
39
39
  add_val(payload, command, 'key')
40
40
  add_map(payload, command, 'query')
41
41
  add_map(payload, command, 'filter')
@@ -87,14 +87,21 @@ module OpenTelemetry
87
87
 
88
88
  def add_map(payload, command, key)
89
89
  value = command[key]
90
- return unless value&.is_a?(Hash) && !value.empty?
90
+ return unless value.is_a?(Hash) && !value.empty?
91
91
 
92
92
  payload[key] = mask(value)
93
93
  end
94
94
 
95
95
  def mask(hash)
96
96
  hash.each_with_object({}) do |(k, v), h|
97
- h[k] = v.is_a?(Hash) ? mask(v) : MASK_VALUE
97
+ value = if v.is_a?(Hash)
98
+ mask(v)
99
+ elsif @obfuscate
100
+ MASK_VALUE
101
+ else
102
+ v
103
+ end
104
+ h[k] = value
98
105
  end
99
106
  end
100
107
  end
@@ -25,7 +25,7 @@ module OpenTelemetry
25
25
  end
26
26
 
27
27
  option :peer_service, default: nil, validate: :string
28
- option :db_statement, default: :include, validate: %I[omit include]
28
+ option :db_statement, default: :obfuscate, validate: %I[omit obfuscate include]
29
29
 
30
30
  private
31
31
 
@@ -13,7 +13,7 @@ module OpenTelemetry
13
13
  class Subscriber
14
14
  THREAD_KEY = :__opentelemetry_mongo_spans__
15
15
 
16
- def started(event) # rubocop:disable Metrics/AbcSize
16
+ def started(event)
17
17
  # start a trace and store it in the current thread; using the `operation_id`
18
18
  # is safe since it's a unique id used to link events together. Also only one
19
19
  # thread is involved in this execution so thread-local storage should be safe. Reference:
@@ -33,7 +33,9 @@ module OpenTelemetry
33
33
  config = Mongo::Instrumentation.instance.config
34
34
  attributes['peer.service'] = config[:peer_service] if config[:peer_service]
35
35
  # attributes['db.statement'] = CommandSerializer.new(event.command).serialize
36
- attributes['db.statement'] = CommandSerializer.new(event.command).serialize if config[:db_statement] == :include
36
+ omit = config[:db_statement] == :omit
37
+ obfuscate = config[:db_statement] == :obfuscate
38
+ attributes['db.statement'] = CommandSerializer.new(event.command, obfuscate).serialize unless omit
37
39
  attributes['db.mongodb.collection'] = collection if collection
38
40
  attributes.compact!
39
41
 
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module Mongo
10
- VERSION = '0.20.0'
10
+ VERSION = '0.21.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-mongo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.0
4
+ version: 0.21.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: 2022-06-09 00:00:00.000000000 Z
11
+ date: 2022-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '1.1'
111
+ - !ruby/object:Gem::Dependency
112
+ name: opentelemetry-test-helpers
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: pry
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -156,14 +170,14 @@ dependencies:
156
170
  requirements:
157
171
  - - "~>"
158
172
  - !ruby/object:Gem::Version
159
- version: 0.73.0
173
+ version: 1.3.0
160
174
  type: :development
161
175
  prerelease: false
162
176
  version_requirements: !ruby/object:Gem::Requirement
163
177
  requirements:
164
178
  - - "~>"
165
179
  - !ruby/object:Gem::Version
166
- version: 0.73.0
180
+ version: 1.3.0
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: simplecov
169
183
  requirement: !ruby/object:Gem::Requirement
@@ -238,14 +252,14 @@ files:
238
252
  - lib/opentelemetry/instrumentation/mongo/instrumentation.rb
239
253
  - lib/opentelemetry/instrumentation/mongo/subscriber.rb
240
254
  - lib/opentelemetry/instrumentation/mongo/version.rb
241
- homepage: https://github.com/open-telemetry/opentelemetry-ruby
255
+ homepage: https://github.com/open-telemetry/opentelemetry-contrib
242
256
  licenses:
243
257
  - Apache-2.0
244
258
  metadata:
245
- changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-mongo/v0.20.0/file.CHANGELOG.html
246
- source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/mongo
247
- bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
248
- documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-mongo/v0.20.0
259
+ changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby-contrib/opentelemetry-instrumentation-mongo/v0.21.0/file.CHANGELOG.html
260
+ source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/mongo
261
+ bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
262
+ documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby-contrib/opentelemetry-instrumentation-mongo/v0.21.0
249
263
  post_install_message:
250
264
  rdoc_options: []
251
265
  require_paths: