opentelemetry-instrumentation-pg 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d58f12ed858f82af3aa55e4c2962706477dcfcb72bfc4d16daab6366dc1abeee
|
4
|
+
data.tar.gz: d00d8d3ada02014905b0c91621f69734e859d27ad01f8d7b097ce4ce89eb70dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2478f862fa99d49340c803410bca43091a26dd02bb522090eb405be01ae5855b2cbe8c57836d6c244e8aa198b4ece17e60dc6bf12116c10abde250d91e4fb2e
|
7
|
+
data.tar.gz: 83494bdc37be6ae03813c323946b56ad5f007759d0db96971a3813f013403edd4535f80f7c2f610329b5c4b119bdbf5e9cc038323ff2ef4c13763bfc0d0947ba
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -30,6 +30,17 @@ OpenTelemetry::SDK.configure do |c|
|
|
30
30
|
end
|
31
31
|
```
|
32
32
|
|
33
|
+
The `PG` instrumentation allows the user to supply additional attributes via the `with_attributes` method. This makes it possible to supply additional attributes on PG spans. Attributes supplied in `with_attributes` supersede those automatically generated within `PG`'s automatic instrumentation. If you supply a `db.statement` attribute in `with_attributes`, this library's `:db_statement` configuration will not be applied.
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
require 'opentelemetry/instrumentation/pg'
|
37
|
+
|
38
|
+
conn = PG::Connection.open(host: "localhost", user: "root", dbname: "postgres")
|
39
|
+
OpenTelemetry::Instrumentation::PG.with_attributes('pizzatoppings' => 'mushrooms') do
|
40
|
+
conn.exec("SELECT 1")
|
41
|
+
end
|
42
|
+
```
|
43
|
+
|
33
44
|
### Configuration options
|
34
45
|
|
35
46
|
```ruby
|
@@ -49,7 +60,7 @@ end
|
|
49
60
|
|
50
61
|
## Examples
|
51
62
|
|
52
|
-
An example of usage can be seen in [`example/pg.rb`](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/instrumentation/pg/example/pg.rb).
|
63
|
+
An example of usage can be seen in [`example/pg.rb`](https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/main/instrumentation/pg/example/pg.rb).
|
53
64
|
|
54
65
|
## How can I get involved?
|
55
66
|
|
@@ -64,7 +75,7 @@ The `opentelemetry-instrumentation-pg` gem is distributed under the Apache 2.0 l
|
|
64
75
|
[pg-home]: https://github.com/ged/ruby-pg
|
65
76
|
[bundler-home]: https://bundler.io
|
66
77
|
[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby
|
67
|
-
[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE
|
78
|
+
[license-github]: https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/main/LICENSE
|
68
79
|
[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig
|
69
80
|
[community-meetings]: https://github.com/open-telemetry/community#community-meetings
|
70
81
|
[ruby-gitter]: https://gitter.im/open-telemetry/opentelemetry-ruby
|
@@ -66,7 +66,7 @@ module OpenTelemetry
|
|
66
66
|
# But, getting that metric in line would force us over the
|
67
67
|
# module size limit! We can't win here unless we want to start
|
68
68
|
# abstracting things into a million pieces.
|
69
|
-
def span_attrs(kind, *args)
|
69
|
+
def span_attrs(kind, *args)
|
70
70
|
if kind == :query
|
71
71
|
operation = extract_operation(args[0])
|
72
72
|
sql = obfuscate_sql(args[0]).to_s
|
@@ -85,6 +85,7 @@ module OpenTelemetry
|
|
85
85
|
|
86
86
|
attrs = { 'db.operation' => validated_operation(operation), 'db.postgresql.prepared_statement_name' => statement_name }
|
87
87
|
attrs['db.statement'] = sql unless config[:db_statement] == :omit
|
88
|
+
attrs.merge!(OpenTelemetry::Instrumentation::PG.attributes)
|
88
89
|
attrs.reject! { |_, v| v.nil? }
|
89
90
|
|
90
91
|
[span_name(operation), client_attributes.merge(attrs)]
|
@@ -11,6 +11,35 @@ module OpenTelemetry
|
|
11
11
|
module Instrumentation
|
12
12
|
# Contains the OpenTelemetry instrumentation for the Pg gem
|
13
13
|
module PG
|
14
|
+
extend self
|
15
|
+
|
16
|
+
CURRENT_ATTRIBUTES_KEY = Context.create_key('pg-attributes-hash')
|
17
|
+
|
18
|
+
private_constant :CURRENT_ATTRIBUTES_KEY
|
19
|
+
|
20
|
+
# Returns the attributes hash representing the postgres 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_KEY) || {}
|
28
|
+
end
|
29
|
+
|
30
|
+
# Activates/deactivates the merged attributes hash within the current Context,
|
31
|
+
# which makes the "current attributes hash" available implicitly.
|
32
|
+
#
|
33
|
+
# On exit, the attributes hash that was active before calling this method
|
34
|
+
# will be reactivated.
|
35
|
+
#
|
36
|
+
# @param [Span] span the span to activate
|
37
|
+
# @yield [Hash, Context] yields attributes hash and a context containing the
|
38
|
+
# attributes hash to the block.
|
39
|
+
def with_attributes(attributes_hash)
|
40
|
+
attributes_hash = attributes.merge(attributes_hash)
|
41
|
+
Context.with_value(CURRENT_ATTRIBUTES_KEY, attributes_hash) { |c, h| yield h, c }
|
42
|
+
end
|
14
43
|
end
|
15
44
|
end
|
16
45
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opentelemetry-instrumentation-pg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.22.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-
|
11
|
+
date: 2022-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -170,14 +170,14 @@ dependencies:
|
|
170
170
|
requirements:
|
171
171
|
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version:
|
173
|
+
version: 1.3.0
|
174
174
|
type: :development
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version:
|
180
|
+
version: 1.3.0
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: simplecov
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -239,14 +239,14 @@ files:
|
|
239
239
|
- lib/opentelemetry/instrumentation/pg/lru_cache.rb
|
240
240
|
- lib/opentelemetry/instrumentation/pg/patches/connection.rb
|
241
241
|
- lib/opentelemetry/instrumentation/pg/version.rb
|
242
|
-
homepage: https://github.com/open-telemetry/opentelemetry-
|
242
|
+
homepage: https://github.com/open-telemetry/opentelemetry-contrib
|
243
243
|
licenses:
|
244
244
|
- Apache-2.0
|
245
245
|
metadata:
|
246
|
-
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-pg/v0.
|
247
|
-
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/pg
|
248
|
-
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
|
249
|
-
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-pg/v0.
|
246
|
+
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby-contrib/opentelemetry-instrumentation-pg/v0.22.0/file.CHANGELOG.html
|
247
|
+
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/pg
|
248
|
+
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
|
249
|
+
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby-contrib/opentelemetry-instrumentation-pg/v0.22.0
|
250
250
|
post_install_message:
|
251
251
|
rdoc_options: []
|
252
252
|
require_paths:
|