opentelemetry-instrumentation-graphql 0.26.8 → 0.27.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: 1c36e26e0ccdc84604de671dc5bd2d6dcd7fd06bbaa9c0159e7d30513813bfdd
4
- data.tar.gz: 051b5110592eddb5495868aab95469a88813476c413cc345bd9cb1ae75e22c3d
3
+ metadata.gz: e3ee635af1f62a05846c78d64428fa90b5ac8f1261b90be335d6f02b8de7584b
4
+ data.tar.gz: 631182b40fa00d6e7fdd042c4b1bfa9f20f3128e305970c96ff202351620330a
5
5
  SHA512:
6
- metadata.gz: 5df687d48d5b7062b6c3b3377aa367b14d12550ae82192e06c93cc9cfe1c0c052fe5172d00939ca57a0e17a578e11c84d41ee2d5c54ef2e118e31a1421b7bbc9
7
- data.tar.gz: e2f39bfb71a33bdb69c588bacae73c57680e014e4a0e0a435f2031518674bfb2802bfdb8cefba8fb7c22349ca113916349696f518b05dfbc802888e41fc2fc4d
6
+ metadata.gz: 5af62b6f0ac50d37da5345ed03fc706b15a9ed86030f85d7bd2e1361062d8dd4a400fc842b826f6995b23341a2a5f7b71a7ca119f077c036a12ce947d41a3b04
7
+ data.tar.gz: c1450b329869c2194a14983da27c98c1389a64aea06300ac9a5815745cfa4e84e0ff1125d98c732e3d1a9b37f658b21165f283eeeef90dfcf8c6df822bcfa2d9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Release History: opentelemetry-instrumentation-graphql
2
2
 
3
+ ### v0.27.0 / 2023-11-28
4
+
5
+ * CHANGED: Performance optimization cache attribute hashes [#723](https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/723)
6
+
3
7
  ### v0.26.8 / 2023-11-23
4
8
 
5
9
  * CHANGED: Applied Rubocop Performance Recommendations [#727](https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/727)
@@ -16,8 +16,46 @@ module OpenTelemetry
16
16
  def initialize(trace_scalars: false, **_options)
17
17
  @trace_scalars = trace_scalars
18
18
  @_otel_field_key_cache = Hash.new { |h, k| h[k] = _otel_field_key(k) }
19
+ @_otel_field_key_cache.compare_by_identity
19
20
  @_otel_authorized_key_cache = Hash.new { |h, k| h[k] = _otel_authorized_key(k) }
21
+ @_otel_authorized_key_cache.compare_by_identity
20
22
  @_otel_resolve_type_key_cache = Hash.new { |h, k| h[k] = _otel_resolve_type_key(k) }
23
+ @_otel_resolve_type_key_cache.compare_by_identity
24
+
25
+ @_otel_type_attrs_cache = Hash.new do |h, type|
26
+ h[type] = {
27
+ 'graphql.type.name' => type.graphql_name,
28
+ 'graphql.lazy' => false
29
+ }.freeze
30
+ end
31
+ @_otel_type_attrs_cache.compare_by_identity
32
+
33
+ @_otel_lazy_type_attrs_cache = Hash.new do |h, type|
34
+ h[type] = {
35
+ 'graphql.type.name' => type.graphql_name,
36
+ 'graphql.lazy' => true
37
+ }.freeze
38
+ end
39
+ @_otel_lazy_type_attrs_cache.compare_by_identity
40
+
41
+ @_otel_field_attrs_cache = Hash.new do |h, field|
42
+ h[field] = {
43
+ 'graphql.field.parent' => field.owner&.graphql_name,
44
+ 'graphql.field.name' => field.graphql_name,
45
+ 'graphql.lazy' => false
46
+ }.freeze
47
+ end
48
+ @_otel_field_attrs_cache.compare_by_identity
49
+
50
+ @_otel_lazy_field_attrs_cache = Hash.new do |h, field|
51
+ h[field] = {
52
+ 'graphql.field.parent' => field.owner&.graphql_name,
53
+ 'graphql.field.name' => field.graphql_name,
54
+ 'graphql.lazy' => true
55
+ }.freeze
56
+ end
57
+ @_otel_lazy_field_attrs_cache.compare_by_identity
58
+
21
59
  super
22
60
  end
23
61
 
@@ -73,26 +111,18 @@ module OpenTelemetry
73
111
 
74
112
  def execute_field(field:, query:, ast_node:, arguments:, object:, &block)
75
113
  platform_key = _otel_execute_field_key(field: field)
76
- return super unless platform_key
114
+ return super(field: field, query: query, ast_node: ast_node, object: object, arguments: arguments, &block) unless platform_key
77
115
 
78
- attributes = {
79
- 'graphql.field.parent' => field.owner&.graphql_name,
80
- 'graphql.field.name' => field.graphql_name,
81
- 'graphql.lazy' => false
82
- }
116
+ attributes = @_otel_field_attrs_cache[field]
83
117
 
84
118
  tracer.in_span(platform_key, attributes: attributes, &block)
85
119
  end
86
120
 
87
121
  def execute_field_lazy(field:, query:, ast_node:, arguments:, object:, &block)
88
122
  platform_key = _otel_execute_field_key(field: field)
89
- return super unless platform_key
123
+ return super(field: field, query: query, ast_node: ast_node, object: object, arguments: arguments, &block) unless platform_key
90
124
 
91
- attributes = {
92
- 'graphql.field.parent' => field.owner&.graphql_name,
93
- 'graphql.field.name' => field.graphql_name,
94
- 'graphql.lazy' => true
95
- }
125
+ attributes = @_otel_lazy_field_attrs_cache[field]
96
126
 
97
127
  tracer.in_span(platform_key, attributes: attributes, &block)
98
128
  end
@@ -101,10 +131,7 @@ module OpenTelemetry
101
131
  platform_key = @_otel_authorized_key_cache[type]
102
132
  return super unless platform_key
103
133
 
104
- attributes = {
105
- 'graphql.type.name' => type.graphql_name,
106
- 'graphql.lazy' => false
107
- }
134
+ attributes = @_otel_type_attrs_cache[type]
108
135
 
109
136
  tracer.in_span(platform_key, attributes: attributes, &block)
110
137
  end
@@ -113,33 +140,19 @@ module OpenTelemetry
113
140
  platform_key = @_otel_authorized_key_cache[type]
114
141
  return super unless platform_key
115
142
 
116
- attributes = {
117
- 'graphql.type.name' => type.graphql_name,
118
- 'graphql.lazy' => true
119
- }
120
-
143
+ attributes = @_otel_lazy_type_attrs_cache[type]
121
144
  tracer.in_span(platform_key, attributes: attributes, &block)
122
145
  end
123
146
 
124
147
  def resolve_type(query:, type:, object:, &block)
125
148
  platform_key = @_otel_resolve_type_key_cache[type]
126
-
127
- attributes = {
128
- 'graphql.type.name' => type.graphql_name,
129
- 'graphql.lazy' => false
130
- }
131
-
149
+ attributes = @_otel_type_attrs_cache[type]
132
150
  tracer.in_span(platform_key, attributes: attributes, &block)
133
151
  end
134
152
 
135
153
  def resolve_type_lazy(query:, type:, object:, &block)
136
154
  platform_key = @_otel_resolve_type_key_cache[type]
137
-
138
- attributes = {
139
- 'graphql.type.name' => type.graphql_name,
140
- 'graphql.lazy' => true
141
- }
142
-
155
+ attributes = @_otel_lazy_type_attrs_cache[type]
143
156
  tracer.in_span(platform_key, attributes: attributes, &block)
144
157
  end
145
158
 
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module GraphQL
10
- VERSION = '0.26.8'
10
+ VERSION = '0.27.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-graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.26.8
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: 2023-11-23 00:00:00.000000000 Z
11
+ date: 2023-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -234,10 +234,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
234
234
  licenses:
235
235
  - Apache-2.0
236
236
  metadata:
237
- changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-graphql/0.26.8/file/CHANGELOG.md
237
+ changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-graphql/0.27.0/file/CHANGELOG.md
238
238
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/graphql
239
239
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
240
- documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-graphql/0.26.8
240
+ documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-graphql/0.27.0
241
241
  post_install_message:
242
242
  rdoc_options: []
243
243
  require_paths: