opentelemetry-instrumentation-mysql2 0.26.1 → 0.27.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: 0ad3ae6b6610cf9d0556d5bf4dceef82d4b3707806a61fb0216042e4aa00d255
|
4
|
+
data.tar.gz: 5091b545504f3d953650f5a84d0ff2397852e4b578f3019d7e329c998c4d97b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16da6501db3c0b84afc847fc42f7280211c6716a63912a9dff00febb18c75c854348713ceb7fae4a1579ee28f6a02b880e0e2255716c8a3d2297a49a663e686c
|
7
|
+
data.tar.gz: f59648d2163a0867a7726ad05bedf61b6dccd47493cdf8bcdafec6ccb85b3e61aaa2c45656281763a7b3787a93787d34490ed05809641ee4668a133615dad83a
|
data/CHANGELOG.md
CHANGED
@@ -14,7 +14,40 @@ module OpenTelemetry
|
|
14
14
|
# Module to prepend to Mysql2::Client for instrumentation
|
15
15
|
module Client
|
16
16
|
def query(sql, options = {})
|
17
|
-
|
17
|
+
tracer.in_span(
|
18
|
+
_otel_span_name(sql),
|
19
|
+
attributes: _otel_span_attributes(sql),
|
20
|
+
kind: :client
|
21
|
+
) do
|
22
|
+
super(sql, options)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def prepare(sql)
|
27
|
+
tracer.in_span(
|
28
|
+
_otel_span_name(sql),
|
29
|
+
attributes: _otel_span_attributes(sql),
|
30
|
+
kind: :client
|
31
|
+
) do
|
32
|
+
super(sql)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def _otel_span_name(sql)
|
39
|
+
OpenTelemetry::Helpers::MySQL.database_span_name(
|
40
|
+
sql,
|
41
|
+
OpenTelemetry::Instrumentation::Mysql2.attributes[
|
42
|
+
SemanticConventions::Trace::DB_OPERATION
|
43
|
+
],
|
44
|
+
_otel_database_name,
|
45
|
+
config
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
def _otel_span_attributes(sql)
|
50
|
+
attributes = _otel_client_attributes
|
18
51
|
case config[:db_statement]
|
19
52
|
when :include
|
20
53
|
attributes[SemanticConventions::Trace::DB_STATEMENT] = sql
|
@@ -24,30 +57,18 @@ module OpenTelemetry
|
|
24
57
|
sql, obfuscation_limit: config[:obfuscation_limit], adapter: :mysql
|
25
58
|
)
|
26
59
|
end
|
27
|
-
tracer.in_span(
|
28
|
-
OpenTelemetry::Helpers::MySQL.database_span_name(
|
29
|
-
sql,
|
30
|
-
OpenTelemetry::Instrumentation::Mysql2.attributes[
|
31
|
-
SemanticConventions::Trace::DB_OPERATION
|
32
|
-
],
|
33
|
-
database_name,
|
34
|
-
config
|
35
|
-
),
|
36
|
-
attributes: attributes.merge!(OpenTelemetry::Instrumentation::Mysql2.attributes),
|
37
|
-
kind: :client
|
38
|
-
) do
|
39
|
-
super(sql, options)
|
40
|
-
end
|
41
|
-
end
|
42
60
|
|
43
|
-
|
61
|
+
attributes.merge!(OpenTelemetry::Instrumentation::Mysql2.attributes)
|
62
|
+
attributes.compact!
|
63
|
+
attributes
|
64
|
+
end
|
44
65
|
|
45
|
-
def
|
66
|
+
def _otel_database_name
|
46
67
|
# https://github.com/brianmario/mysql2/blob/ca08712c6c8ea672df658bb25b931fea22555f27/lib/mysql2/client.rb#L78
|
47
68
|
(query_options[:database] || query_options[:dbname] || query_options[:db])&.to_s
|
48
69
|
end
|
49
70
|
|
50
|
-
def
|
71
|
+
def _otel_client_attributes
|
51
72
|
# The client specific attributes can be found via the query_options instance variable
|
52
73
|
# exposed on the mysql2 Client
|
53
74
|
# https://github.com/brianmario/mysql2/blob/ca08712c6c8ea672df658bb25b931fea22555f27/lib/mysql2/client.rb#L25-L26
|
@@ -59,8 +80,9 @@ module OpenTelemetry
|
|
59
80
|
SemanticConventions::Trace::NET_PEER_NAME => host,
|
60
81
|
SemanticConventions::Trace::NET_PEER_PORT => port
|
61
82
|
}
|
62
|
-
|
63
|
-
attributes[SemanticConventions::Trace::
|
83
|
+
|
84
|
+
attributes[SemanticConventions::Trace::DB_NAME] = _otel_database_name
|
85
|
+
attributes[SemanticConventions::Trace::PEER_SERVICE] = config[:peer_service]
|
64
86
|
attributes
|
65
87
|
end
|
66
88
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opentelemetry-instrumentation-mysql2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.27.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: 2024-02-
|
11
|
+
date: 2024-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -255,10 +255,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
|
|
255
255
|
licenses:
|
256
256
|
- Apache-2.0
|
257
257
|
metadata:
|
258
|
-
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-mysql2/0.
|
258
|
+
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-mysql2/0.27.0/file/CHANGELOG.md
|
259
259
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/mysql2
|
260
260
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
|
261
|
-
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-mysql2/0.
|
261
|
+
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-mysql2/0.27.0
|
262
262
|
post_install_message:
|
263
263
|
rdoc_options: []
|
264
264
|
require_paths:
|