opentelemetry-instrumentation-graphql 0.27.0 → 0.28.1

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: f00ed9257643984b964d093745f8e3212575567ea4190f2fb3ff4c614b09c4aa
4
+ data.tar.gz: 7f19d02503bdbcfc97dd4b6a901f849c171bc06ba3634b8e056b456a3804100c
5
5
  SHA512:
6
- metadata.gz: 5af62b6f0ac50d37da5345ed03fc706b15a9ed86030f85d7bd2e1361062d8dd4a400fc842b826f6995b23341a2a5f7b71a7ca119f077c036a12ce947d41a3b04
7
- data.tar.gz: c1450b329869c2194a14983da27c98c1389a64aea06300ac9a5815745cfa4e84e0ff1125d98c732e3d1a9b37f658b21165f283eeeef90dfcf8c6df822bcfa2d9
6
+ metadata.gz: c16f277c3afedda24198d4217c733838dfa536ebda31a378af3bed3f18bae5e6b8a2f882b0e079cf5c41e6acbf1b4a7e21ed957d74953c7969d929290b957a3d
7
+ data.tar.gz: 3cc3ae60b0f6b9014c5158f014306712507b71c39aca511531a665596e2a9afc2ec750d52276d1ad6ff30d0353408b9ccba997961149f2e41b3885b3a4014e8d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Release History: opentelemetry-instrumentation-graphql
2
2
 
3
+ ### v0.28.1 / 2024-04-10
4
+
5
+ * FIXED: Analyze span names in GraphQL instrumentation
6
+
7
+ ### v0.28.0 / 2024-02-16
8
+
9
+ * BREAKING CHANGE: GraphQL Legacy Tracer perf improvements [#867](https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/867).
10
+
11
+ * ADDED: GraphQL Legacy Tracer perf improvements [#867](https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/867).
12
+
3
13
  ### v0.27.0 / 2023-11-28
4
14
 
5
15
  * CHANGED: Performance optimization cache attribute hashes [#723](https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/723)
@@ -89,11 +89,11 @@ module OpenTelemetry
89
89
  end
90
90
 
91
91
  def analyze_multiplex(multiplex:, &block)
92
- tracer.in_span('graphql.analyze_query', &block)
92
+ tracer.in_span('graphql.analyze_multiplex', &block)
93
93
  end
94
94
 
95
95
  def analyze_query(query:, &block)
96
- tracer.in_span('graphql.analyze_multiplex', &block)
96
+ tracer.in_span('graphql.analyze_query', &block)
97
97
  end
98
98
 
99
99
  def execute_query(query:, &block)
@@ -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.1'
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.1
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-04-10 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.62'
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.62'
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.1/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.1
241
241
  post_install_message:
242
242
  rdoc_options: []
243
243
  require_paths: