opentelemetry-instrumentation-graphql 0.27.0 → 0.28.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: e3ee635af1f62a05846c78d64428fa90b5ac8f1261b90be335d6f02b8de7584b
4
- data.tar.gz: 631182b40fa00d6e7fdd042c4b1bfa9f20f3128e305970c96ff202351620330a
3
+ metadata.gz: cf9a17d56d662feb78eacc36f2f23dc43d4a01244993b638b87f2c1ce1edc5da
4
+ data.tar.gz: 899d075eb41a2d13c0da8d9e6b3ccc08c0b568b476a0be89262e04baa85c31bf
5
5
  SHA512:
6
- metadata.gz: 5af62b6f0ac50d37da5345ed03fc706b15a9ed86030f85d7bd2e1361062d8dd4a400fc842b826f6995b23341a2a5f7b71a7ca119f077c036a12ce947d41a3b04
7
- data.tar.gz: c1450b329869c2194a14983da27c98c1389a64aea06300ac9a5815745cfa4e84e0ff1125d98c732e3d1a9b37f658b21165f283eeeef90dfcf8c6df822bcfa2d9
6
+ metadata.gz: 0217566ff1adebe65c331b91ca473989c47ffa43fc027d029fd125eb51388d739e2b283b43eadc80771cb81665c868418a7b06adb8f2be8ee80243259f733d88
7
+ data.tar.gz: ea52c6fd2b8b9bc378038046a25b92e1dbc11386764e88482439ba974a7fd1f5b6f2e42850b11b270c4ce69410e4a49419dc042328dc9b9c8bc7981c35e91db5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Release History: opentelemetry-instrumentation-graphql
2
2
 
3
+ ### v0.28.0 / 2024-02-16
4
+
5
+ * BREAKING CHANGE: GraphQL Legacy Tracer perf improvements [#867](https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/867).
6
+
7
+ * ADDED: GraphQL Legacy Tracer perf improvements [#867](https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/867).
8
+
3
9
  ### v0.27.0 / 2023-11-28
4
10
 
5
11
  * CHANGED: Performance optimization cache attribute hashes [#723](https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/723)
@@ -13,6 +13,8 @@ module OpenTelemetry
13
13
  # GraphQLTracer contains the OpenTelemetry tracer implementation compatible with
14
14
  # the GraphQL tracer API
15
15
  class GraphQLTracer < ::GraphQL::Tracing::PlatformTracing
16
+ DEFAULT_HASH = {}.freeze
17
+
16
18
  self.platform_keys = {
17
19
  'lex' => 'graphql.lex',
18
20
  'parse' => 'graphql.parse',
@@ -86,24 +88,60 @@ module OpenTelemetry
86
88
  end
87
89
 
88
90
  def attributes_for(key, data)
89
- attributes = {}
90
91
  case key
91
- when 'execute_field', 'execute_field_lazy'
92
- attributes['graphql.field.parent'] = data[:owner]&.graphql_name # owner is the concrete type, not interface
93
- attributes['graphql.field.name'] = data[:field]&.graphql_name
94
- attributes['graphql.lazy'] = key == 'execute_field_lazy'
95
- when 'authorized', 'authorized_lazy'
96
- attributes['graphql.type.name'] = data[:type]&.graphql_name
97
- attributes['graphql.lazy'] = key == 'authorized_lazy'
98
- when 'resolve_type', 'resolve_type_lazy'
99
- attributes['graphql.type.name'] = data[:type]&.graphql_name
100
- attributes['graphql.lazy'] = key == 'resolve_type_lazy'
92
+ when 'execute_field'
93
+ field_attr_cache = data[:query].context.namespace(:otel_attrs)[:execute_field_attrs] ||= attr_cache do |field|
94
+ attrs = {}
95
+ attrs['graphql.field.parent'] = field.owner.graphql_name if field.owner.graphql_name
96
+ attrs['graphql.field.name'] = field.graphql_name if field.graphql_name
97
+ attrs['graphql.lazy'] = false
98
+ attrs.freeze
99
+ end
100
+ field_attr_cache[data[:field]]
101
+ when 'execute_field_lazy'
102
+ lazy_field_attr_cache = data[:query].context.namespace(:otel_attrs)[:execute_field_lazy_attrs] ||= attr_cache do |field|
103
+ attrs = {}
104
+ attrs['graphql.field.parent'] = field.owner.graphql_name if field.owner.graphql_name
105
+ attrs['graphql.field.name'] = field.graphql_name if field.graphql_name
106
+ attrs['graphql.lazy'] = true
107
+ attrs.freeze
108
+ end
109
+ lazy_field_attr_cache[data[:field]]
110
+ when 'authorized', 'resolve_type'
111
+ type_attrs_cache = data[:context].namespace(:otel_attrs)[:type_attrs] ||= attr_cache do |type|
112
+ attrs = {}
113
+ attrs['graphql.type.name'] = type.graphql_name if type.graphql_name
114
+ attrs['graphql.lazy'] = false
115
+ attrs.freeze
116
+ end
117
+ type_attrs_cache[data[:type]]
118
+ when 'authorized_lazy', 'resolve_type_lazy'
119
+ type_lazy_attrs_cache = data[:context].namespace(:otel_attrs)[:type_lazy_attrs] ||= attr_cache do |type|
120
+ attrs = {}
121
+ attrs['graphql.type.name'] = type.graphql_name if type.graphql_name
122
+ attrs['graphql.lazy'] = true
123
+ attrs.freeze
124
+ end
125
+ type_lazy_attrs_cache[data[:type]]
101
126
  when 'execute_query'
102
- attributes['graphql.operation.name'] = data[:query].selected_operation_name if data[:query].selected_operation_name
103
- attributes['graphql.operation.type'] = data[:query].selected_operation.operation_type
104
- attributes['graphql.document'] = data[:query].query_string
127
+ attrs = {}
128
+ attrs['graphql.document'] = data[:query].query_string if data[:query].query_string
129
+ # rubocop:disable Style/SafeNavigation - using safe navigation creates more objects, we want to avoid this
130
+ attrs['graphql.operation.type'] = data[:query].selected_operation.operation_type if data[:query].selected_operation && data[:query].selected_operation.operation_type
131
+ # rubocop:enable Style/SafeNavigation
132
+ attrs['graphql.operation.name'] = data[:query].selected_operation_name || 'anonymous'
133
+ attrs.freeze
134
+ else
135
+ DEFAULT_HASH
136
+ end
137
+ end
138
+
139
+ def attr_cache
140
+ cache_h = Hash.new do |h, k|
141
+ h[k] = yield(k)
105
142
  end
106
- attributes
143
+ cache_h.compare_by_identity
144
+ cache_h
107
145
  end
108
146
  end
109
147
  end
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module GraphQL
10
- VERSION = '0.27.0'
10
+ VERSION = '0.28.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.27.0
4
+ version: 0.28.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-28 00:00:00.000000000 Z
11
+ date: 2024-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -148,28 +148,28 @@ dependencies:
148
148
  requirements:
149
149
  - - "~>"
150
150
  - !ruby/object:Gem::Version
151
- version: 1.56.1
151
+ version: 1.60.1
152
152
  type: :development
153
153
  prerelease: false
154
154
  version_requirements: !ruby/object:Gem::Requirement
155
155
  requirements:
156
156
  - - "~>"
157
157
  - !ruby/object:Gem::Version
158
- version: 1.56.1
158
+ version: 1.60.1
159
159
  - !ruby/object:Gem::Dependency
160
160
  name: rubocop-performance
161
161
  requirement: !ruby/object:Gem::Requirement
162
162
  requirements:
163
163
  - - "~>"
164
164
  - !ruby/object:Gem::Version
165
- version: 1.19.1
165
+ version: '1.20'
166
166
  type: :development
167
167
  prerelease: false
168
168
  version_requirements: !ruby/object:Gem::Requirement
169
169
  requirements:
170
170
  - - "~>"
171
171
  - !ruby/object:Gem::Version
172
- version: 1.19.1
172
+ version: '1.20'
173
173
  - !ruby/object:Gem::Dependency
174
174
  name: simplecov
175
175
  requirement: !ruby/object:Gem::Requirement
@@ -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.27.0/file/CHANGELOG.md
237
+ changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-graphql/0.28.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.27.0
240
+ documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-graphql/0.28.0
241
241
  post_install_message:
242
242
  rdoc_options: []
243
243
  require_paths: