opentelemetry-instrumentation-graphql 0.21.1 → 0.23.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: 6933e85196eaf2f0f93f7c8d86e7713c0d56fecb2035eded886357c7c2d9579b
4
- data.tar.gz: f6d5f32f7c34453c7effc96a97451c75ccefe259b3d1ff2ea89616fd09353902
3
+ metadata.gz: 7e18d71207741e012a8bda9a7cc321806f0ec150912fa03873b2d15c1db70b66
4
+ data.tar.gz: cd76df3e726f5427792c02df86bdfd02c50893ddd8ecc6948863eb677087ef85
5
5
  SHA512:
6
- metadata.gz: 6e680d4a2f2e8d8b5c0dc9b011dd38fbb289b4c5c82af79b19ed5a4a415367fd8df8be013cfee0e69cca4d5b53a7066c2aeaa9063ef8b29798d58bb43792cf05
7
- data.tar.gz: 925f99580cdf0eeaa21a5f9613df6d7a6722ae774a6284b7b31e93915829da959857741a8104d1573a649691af839e80bc8276bd3352e631830ce7a03007f810
6
+ metadata.gz: 7c5d616ccd1f7a31f8795d315b9b35a4a21dc52f3609b912e004f10dce9510eedc6d7f42eb1df9596500ec9f88c46fcb8044b8f9ee790a1d56d08b3ff2058f67
7
+ data.tar.gz: 429d61013ccdc6e6fcac57417ba1e9297ccee0b2d6c53f3aa4357943f8b196e19008f3bc6e52510665987b1acb0b5b30ab74980d3ea13bf0586cc5520ec2a746
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Release History: opentelemetry-instrumentation-graphql
2
2
 
3
+ ### v0.23.0 / 2023-03-13
4
+
5
+ * BREAKING CHANGE: Lock graphql max version to 2.0.17
6
+
7
+ * FIXED: Lock graphql max version to 2.0.17
8
+
9
+ ### v0.22.0 / 2023-01-27
10
+
11
+ * ADDED: Normalize GraphQL span names for easier aggregation analysis
12
+
3
13
  ### v0.21.1 / 2023-01-14
4
14
 
5
15
  * DOCS: Fix gem homepage
data/README.md CHANGED
@@ -40,7 +40,12 @@ OpenTelemetry::SDK.configure do |c|
40
40
  # enable_platform_authorized maps to the authorized and authorized_lazy keys
41
41
  enable_platform_authorized: false,
42
42
  # enable_platform_resolve_type maps to the resolve_type and resolve_type_lazy keys
43
- enable_platform_resolve_type: false
43
+ enable_platform_resolve_type: false,
44
+
45
+ # Controls if platform tracing (field/authorized/resolve_type)
46
+ # should use the legacy span names (e.g. "MyType.myField") or the
47
+ # new normalized span names (e.g. "graphql.execute_field").
48
+ legacy_platform_span_names: false
44
49
  }
45
50
  end
46
51
  ```
@@ -12,7 +12,7 @@ module OpenTelemetry
12
12
  # The Instrumentation class contains logic to detect and install the GraphQL instrumentation
13
13
  class Instrumentation < OpenTelemetry::Instrumentation::Base
14
14
  compatible do
15
- gem_version < Gem::Version.new('3.0.0')
15
+ gem_version <= Gem::Version.new('2.0.17')
16
16
  end
17
17
 
18
18
  install do |config|
@@ -35,6 +35,11 @@ module OpenTelemetry
35
35
  # The enable_platform_resolve_type key expects a boolean value,
36
36
  # and enables the tracing of "resolve_type" and "resolve_type_lazy".
37
37
  #
38
+ # The legacy_platform_span_names key expects a boolean value,
39
+ # and controls if platform tracing (field/authorized/resolve_type)
40
+ # should use the legacy span names (e.g. "MyType.myField") or the
41
+ # new normalized span names (e.g. "graphql.execute_field").
42
+ #
38
43
  # The schemas key expects an array of Schemas, and is used to specify
39
44
  # which schemas are to be instrumented. If this value is not supplied
40
45
  # the default behaviour is to instrument all schemas.
@@ -42,6 +47,7 @@ module OpenTelemetry
42
47
  option :enable_platform_field, default: false, validate: :boolean
43
48
  option :enable_platform_authorized, default: false, validate: :boolean
44
49
  option :enable_platform_resolve_type, default: false, validate: :boolean
50
+ option :legacy_platform_span_names, default: false, validate: :boolean
45
51
 
46
52
  private
47
53
 
@@ -45,19 +45,31 @@ module OpenTelemetry
45
45
  def platform_field_key(type, field)
46
46
  return unless config[:enable_platform_field]
47
47
 
48
- "#{type.graphql_name}.#{field.graphql_name}"
48
+ if config[:legacy_platform_span_names]
49
+ "#{type.graphql_name}.#{field.graphql_name}"
50
+ else
51
+ 'graphql.execute_field'
52
+ end
49
53
  end
50
54
 
51
55
  def platform_authorized_key(type)
52
56
  return unless config[:enable_platform_authorized]
53
57
 
54
- "#{type.graphql_name}.authorized"
58
+ if config[:legacy_platform_span_names]
59
+ "#{type.graphql_name}.authorized"
60
+ else
61
+ 'graphql.authorized'
62
+ end
55
63
  end
56
64
 
57
65
  def platform_resolve_type_key(type)
58
66
  return unless config[:enable_platform_resolve_type]
59
67
 
60
- "#{type.graphql_name}.resolve_type"
68
+ if config[:legacy_platform_span_names]
69
+ "#{type.graphql_name}.resolve_type"
70
+ else
71
+ 'graphql.resolve_type'
72
+ end
61
73
  end
62
74
 
63
75
  private
@@ -70,9 +82,19 @@ module OpenTelemetry
70
82
  GraphQL::Instrumentation.instance.config
71
83
  end
72
84
 
73
- def attributes_for(key, data)
85
+ def attributes_for(key, data) # rubocop:disable Metrics/CyclomaticComplexity
74
86
  attributes = {}
75
87
  case key
88
+ when 'execute_field', 'execute_field_lazy'
89
+ attributes['graphql.field.parent'] = data[:owner]&.graphql_name # owner is the concrete type, not interface
90
+ attributes['graphql.field.name'] = data[:field]&.graphql_name
91
+ attributes['graphql.lazy'] = key == 'execute_field_lazy'
92
+ when 'authorized', 'authorized_lazy'
93
+ attributes['graphql.type.name'] = data[:type]&.graphql_name
94
+ attributes['graphql.lazy'] = key == 'authorized_lazy'
95
+ when 'resolve_type', 'resolve_type_lazy'
96
+ attributes['graphql.type.name'] = data[:type]&.graphql_name
97
+ attributes['graphql.lazy'] = key == 'resolve_type_lazy'
76
98
  when 'execute_query'
77
99
  attributes['graphql.operation.name'] = data[:query].selected_operation_name if data[:query].selected_operation_name
78
100
  attributes['graphql.operation.type'] = data[:query].selected_operation.operation_type
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module GraphQL
10
- VERSION = '0.21.1'
10
+ VERSION = '0.23.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.21.1
4
+ version: 0.23.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-01-14 00:00:00.000000000 Z
11
+ date: 2023-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -73,9 +73,9 @@ dependencies:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: 1.9.0
76
- - - "<"
76
+ - - "<="
77
77
  - !ruby/object:Gem::Version
78
- version: 3.0.0
78
+ version: 2.0.17
79
79
  type: :development
80
80
  prerelease: false
81
81
  version_requirements: !ruby/object:Gem::Requirement
@@ -83,9 +83,9 @@ dependencies:
83
83
  - - ">="
84
84
  - !ruby/object:Gem::Version
85
85
  version: 1.9.0
86
- - - "<"
86
+ - - "<="
87
87
  - !ruby/object:Gem::Version
88
- version: 3.0.0
88
+ version: 2.0.17
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: minitest
91
91
  requirement: !ruby/object:Gem::Requirement
@@ -233,10 +233,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
233
233
  licenses:
234
234
  - Apache-2.0
235
235
  metadata:
236
- changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-graphql/0.21.1/file/CHANGELOG.md
236
+ changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-graphql/0.23.0/file/CHANGELOG.md
237
237
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/graphql
238
238
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
239
- documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-graphql/0.21.1
239
+ documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-graphql/0.23.0
240
240
  post_install_message:
241
241
  rdoc_options: []
242
242
  require_paths: