graphql 2.4.3 → 2.4.13

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.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/lib/graphql/analysis/analyzer.rb +2 -1
  3. data/lib/graphql/analysis/visitor.rb +38 -41
  4. data/lib/graphql/analysis.rb +15 -12
  5. data/lib/graphql/autoload.rb +38 -0
  6. data/lib/graphql/backtrace/table.rb +95 -55
  7. data/lib/graphql/backtrace.rb +1 -19
  8. data/lib/graphql/current.rb +6 -1
  9. data/lib/graphql/dashboard/statics/bootstrap-5.3.3.min.css +6 -0
  10. data/lib/graphql/dashboard/statics/bootstrap-5.3.3.min.js +7 -0
  11. data/lib/graphql/dashboard/statics/dashboard.css +3 -0
  12. data/lib/graphql/dashboard/statics/dashboard.js +78 -0
  13. data/lib/graphql/dashboard/statics/header-icon.png +0 -0
  14. data/lib/graphql/dashboard/statics/icon.png +0 -0
  15. data/lib/graphql/dashboard/views/graphql/dashboard/landings/show.html.erb +18 -0
  16. data/lib/graphql/dashboard/views/graphql/dashboard/traces/index.html.erb +63 -0
  17. data/lib/graphql/dashboard/views/layouts/graphql/dashboard/application.html.erb +60 -0
  18. data/lib/graphql/dashboard.rb +142 -0
  19. data/lib/graphql/dataloader/active_record_association_source.rb +64 -0
  20. data/lib/graphql/dataloader/active_record_source.rb +26 -0
  21. data/lib/graphql/dataloader/async_dataloader.rb +21 -9
  22. data/lib/graphql/dataloader/null_dataloader.rb +1 -1
  23. data/lib/graphql/dataloader/source.rb +3 -3
  24. data/lib/graphql/dataloader.rb +43 -14
  25. data/lib/graphql/execution/interpreter/resolve.rb +3 -3
  26. data/lib/graphql/execution/interpreter/runtime/graphql_result.rb +11 -4
  27. data/lib/graphql/execution/interpreter/runtime.rb +67 -40
  28. data/lib/graphql/execution/interpreter.rb +16 -6
  29. data/lib/graphql/execution/multiplex.rb +0 -4
  30. data/lib/graphql/introspection/directive_location_enum.rb +1 -1
  31. data/lib/graphql/invalid_name_error.rb +1 -1
  32. data/lib/graphql/invalid_null_error.rb +5 -15
  33. data/lib/graphql/language/cache.rb +13 -0
  34. data/lib/graphql/language/document_from_schema_definition.rb +8 -7
  35. data/lib/graphql/language/lexer.rb +11 -4
  36. data/lib/graphql/language/nodes.rb +3 -0
  37. data/lib/graphql/language/parser.rb +2 -2
  38. data/lib/graphql/language/printer.rb +8 -8
  39. data/lib/graphql/language/static_visitor.rb +37 -33
  40. data/lib/graphql/language/visitor.rb +59 -55
  41. data/lib/graphql/pagination/connection.rb +1 -1
  42. data/lib/graphql/query/context/scoped_context.rb +1 -1
  43. data/lib/graphql/query/context.rb +6 -5
  44. data/lib/graphql/query/variable_validation_error.rb +1 -1
  45. data/lib/graphql/query.rb +20 -22
  46. data/lib/graphql/railtie.rb +7 -0
  47. data/lib/graphql/schema/addition.rb +1 -1
  48. data/lib/graphql/schema/argument.rb +3 -5
  49. data/lib/graphql/schema/build_from_definition.rb +8 -7
  50. data/lib/graphql/schema/directive/flagged.rb +1 -1
  51. data/lib/graphql/schema/directive.rb +2 -2
  52. data/lib/graphql/schema/enum.rb +36 -1
  53. data/lib/graphql/schema/enum_value.rb +1 -1
  54. data/lib/graphql/schema/field/scope_extension.rb +1 -1
  55. data/lib/graphql/schema/field.rb +12 -12
  56. data/lib/graphql/schema/field_extension.rb +1 -1
  57. data/lib/graphql/schema/has_single_input_argument.rb +3 -1
  58. data/lib/graphql/schema/input_object.rb +70 -34
  59. data/lib/graphql/schema/interface.rb +3 -2
  60. data/lib/graphql/schema/loader.rb +1 -1
  61. data/lib/graphql/schema/member/has_arguments.rb +25 -17
  62. data/lib/graphql/schema/member/has_dataloader.rb +60 -0
  63. data/lib/graphql/schema/member/has_directives.rb +4 -4
  64. data/lib/graphql/schema/member/has_fields.rb +19 -1
  65. data/lib/graphql/schema/member/has_interfaces.rb +5 -5
  66. data/lib/graphql/schema/member/has_validators.rb +1 -1
  67. data/lib/graphql/schema/member/scoped.rb +1 -1
  68. data/lib/graphql/schema/member/type_system_helpers.rb +1 -1
  69. data/lib/graphql/schema/member.rb +1 -0
  70. data/lib/graphql/schema/object.rb +25 -8
  71. data/lib/graphql/schema/relay_classic_mutation.rb +0 -1
  72. data/lib/graphql/schema/resolver.rb +11 -10
  73. data/lib/graphql/schema/subscription.rb +52 -6
  74. data/lib/graphql/schema/union.rb +1 -1
  75. data/lib/graphql/schema/validator/required_validator.rb +23 -6
  76. data/lib/graphql/schema/validator.rb +1 -1
  77. data/lib/graphql/schema/visibility/migration.rb +1 -0
  78. data/lib/graphql/schema/visibility/profile.rb +69 -237
  79. data/lib/graphql/schema/visibility/visit.rb +190 -0
  80. data/lib/graphql/schema/visibility.rb +169 -28
  81. data/lib/graphql/schema/warden.rb +18 -5
  82. data/lib/graphql/schema.rb +90 -43
  83. data/lib/graphql/static_validation/rules/argument_names_are_unique.rb +1 -1
  84. data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +1 -1
  85. data/lib/graphql/static_validation/rules/fields_will_merge.rb +1 -1
  86. data/lib/graphql/static_validation/rules/no_definitions_are_present.rb +1 -1
  87. data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +1 -1
  88. data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +1 -1
  89. data/lib/graphql/static_validation/rules/variable_names_are_unique.rb +1 -1
  90. data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +1 -1
  91. data/lib/graphql/static_validation/validation_context.rb +1 -0
  92. data/lib/graphql/static_validation/validator.rb +6 -1
  93. data/lib/graphql/subscriptions/action_cable_subscriptions.rb +1 -1
  94. data/lib/graphql/subscriptions/default_subscription_resolve_extension.rb +12 -10
  95. data/lib/graphql/subscriptions/event.rb +12 -1
  96. data/lib/graphql/subscriptions/serialize.rb +1 -1
  97. data/lib/graphql/subscriptions.rb +1 -1
  98. data/lib/graphql/testing/helpers.rb +2 -2
  99. data/lib/graphql/tracing/active_support_notifications_trace.rb +7 -3
  100. data/lib/graphql/tracing/active_support_notifications_tracing.rb +1 -1
  101. data/lib/graphql/tracing/appoptics_trace.rb +9 -1
  102. data/lib/graphql/tracing/appoptics_tracing.rb +2 -0
  103. data/lib/graphql/tracing/appsignal_trace.rb +12 -0
  104. data/lib/graphql/tracing/appsignal_tracing.rb +2 -0
  105. data/lib/graphql/tracing/call_legacy_tracers.rb +66 -0
  106. data/lib/graphql/tracing/data_dog_trace.rb +11 -0
  107. data/lib/graphql/tracing/data_dog_tracing.rb +2 -0
  108. data/lib/graphql/tracing/detailed_trace/memory_backend.rb +60 -0
  109. data/lib/graphql/tracing/detailed_trace/redis_backend.rb +72 -0
  110. data/lib/graphql/tracing/detailed_trace.rb +93 -0
  111. data/lib/graphql/tracing/legacy_hooks_trace.rb +1 -0
  112. data/lib/graphql/tracing/legacy_trace.rb +4 -61
  113. data/lib/graphql/tracing/new_relic_trace.rb +164 -41
  114. data/lib/graphql/tracing/new_relic_tracing.rb +2 -0
  115. data/lib/graphql/tracing/notifications_trace.rb +4 -0
  116. data/lib/graphql/tracing/notifications_tracing.rb +2 -0
  117. data/lib/graphql/tracing/null_trace.rb +9 -0
  118. data/lib/graphql/tracing/perfetto_trace/trace.proto +141 -0
  119. data/lib/graphql/tracing/perfetto_trace/trace_pb.rb +33 -0
  120. data/lib/graphql/tracing/perfetto_trace.rb +737 -0
  121. data/lib/graphql/tracing/platform_trace.rb +5 -0
  122. data/lib/graphql/tracing/prometheus_trace/graphql_collector.rb +2 -0
  123. data/lib/graphql/tracing/prometheus_trace.rb +31 -0
  124. data/lib/graphql/tracing/prometheus_tracing.rb +2 -0
  125. data/lib/graphql/tracing/scout_trace.rb +11 -0
  126. data/lib/graphql/tracing/scout_tracing.rb +2 -0
  127. data/lib/graphql/tracing/sentry_trace.rb +11 -0
  128. data/lib/graphql/tracing/statsd_trace.rb +15 -0
  129. data/lib/graphql/tracing/statsd_tracing.rb +2 -0
  130. data/lib/graphql/tracing/trace.rb +128 -1
  131. data/lib/graphql/tracing.rb +30 -30
  132. data/lib/graphql/types/relay/connection_behaviors.rb +3 -3
  133. data/lib/graphql/types/relay/edge_behaviors.rb +2 -2
  134. data/lib/graphql/types.rb +18 -11
  135. data/lib/graphql/version.rb +1 -1
  136. data/lib/graphql.rb +55 -47
  137. metadata +152 -10
  138. data/lib/graphql/backtrace/inspect_result.rb +0 -38
  139. data/lib/graphql/backtrace/trace.rb +0 -93
  140. data/lib/graphql/backtrace/tracer.rb +0 -80
  141. data/lib/graphql/schema/null_mask.rb +0 -11
@@ -1,67 +1,10 @@
1
1
  # frozen_string_literal: true
2
- module GraphQL
3
- module Tracing
4
- # This trace class calls legacy-style tracer with payload hashes.
5
- # New-style `trace_with` modules significantly reduce the overhead of tracing,
6
- # but that advantage is lost when legacy-style tracers are also used (since the payload hashes are still constructed).
7
- module CallLegacyTracers
8
- def lex(query_string:)
9
- (@multiplex || @query).trace("lex", { query_string: query_string }) { super }
10
- end
11
-
12
- def parse(query_string:)
13
- (@multiplex || @query).trace("parse", { query_string: query_string }) { super }
14
- end
15
-
16
- def validate(query:, validate:)
17
- query.trace("validate", { validate: validate, query: query }) { super }
18
- end
19
-
20
- def analyze_multiplex(multiplex:)
21
- multiplex.trace("analyze_multiplex", { multiplex: multiplex }) { super }
22
- end
23
-
24
- def analyze_query(query:)
25
- query.trace("analyze_query", { query: query }) { super }
26
- end
27
-
28
- def execute_multiplex(multiplex:)
29
- multiplex.trace("execute_multiplex", { multiplex: multiplex }) { super }
30
- end
31
-
32
- def execute_query(query:)
33
- query.trace("execute_query", { query: query }) { super }
34
- end
35
-
36
- def execute_query_lazy(query:, multiplex:)
37
- multiplex.trace("execute_query_lazy", { multiplex: multiplex, query: query }) { super }
38
- end
39
2
 
40
- def execute_field(field:, query:, ast_node:, arguments:, object:)
41
- query.trace("execute_field", { field: field, query: query, ast_node: ast_node, arguments: arguments, object: object, owner: field.owner, path: query.context[:current_path] }) { super }
42
- end
43
-
44
- def execute_field_lazy(field:, query:, ast_node:, arguments:, object:)
45
- query.trace("execute_field_lazy", { field: field, query: query, ast_node: ast_node, arguments: arguments, object: object, owner: field.owner, path: query.context[:current_path] }) { super }
46
- end
47
-
48
- def authorized(query:, type:, object:)
49
- query.trace("authorized", { context: query.context, type: type, object: object, path: query.context[:current_path] }) { super }
50
- end
51
-
52
- def authorized_lazy(query:, type:, object:)
53
- query.trace("authorized_lazy", { context: query.context, type: type, object: object, path: query.context[:current_path] }) { super }
54
- end
55
-
56
- def resolve_type(query:, type:, object:)
57
- query.trace("resolve_type", { context: query.context, type: type, object: object, path: query.context[:current_path] }) { super }
58
- end
59
-
60
- def resolve_type_lazy(query:, type:, object:)
61
- query.trace("resolve_type_lazy", { context: query.context, type: type, object: object, path: query.context[:current_path] }) { super }
62
- end
63
- end
3
+ require "graphql/tracing/trace"
4
+ require "graphql/tracing/call_legacy_tracers"
64
5
 
6
+ module GraphQL
7
+ module Tracing
65
8
  class LegacyTrace < Trace
66
9
  include CallLegacyTracers
67
10
  end
@@ -1,74 +1,197 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "graphql/tracing/platform_trace"
4
+
3
5
  module GraphQL
4
6
  module Tracing
7
+ # A tracer for reporting GraphQL-Ruby time to New Relic
8
+ #
9
+ # @example Installing the tracer
10
+ # class MySchema < GraphQL::Schema
11
+ # trace_with GraphQL::Tracing::NewRelicTrace
12
+ #
13
+ # # Optional, use the operation name to set the new relic transaction name:
14
+ # # trace_with GraphQL::Tracing::NewRelicTrace, set_transaction_name: true
15
+ # end
16
+ #
17
+ # @example Installing without trace events for `authorized?` or `resolve_type` calls
18
+ # trace_with GraphQL::Tracing::NewRelicTrace, trace_authorized: false, trace_resolve_type: false
5
19
  module NewRelicTrace
6
- include PlatformTrace
7
-
8
20
  # @param set_transaction_name [Boolean] If true, the GraphQL operation name will be used as the transaction name.
9
21
  # This is not advised if you run more than one query per HTTP request, for example, with `graphql-client` or multiplexing.
10
22
  # It can also be specified per-query with `context[:set_new_relic_transaction_name]`.
11
- def initialize(set_transaction_name: false, **_rest)
23
+ # @param trace_authorized [Boolean] If `false`, skip tracing `authorized?` calls
24
+ # @param trace_resolve_type [Boolean] If `false`, skip tracing `resolve_type?` calls
25
+ # @param trace_scalars [Boolean] If `true`, Enum and Scalar fields will be traced by default
26
+ def initialize(set_transaction_name: false, trace_authorized: true, trace_resolve_type: true, trace_scalars: false, **_rest)
12
27
  @set_transaction_name = set_transaction_name
28
+ @trace_authorized = trace_authorized
29
+ @trace_resolve_type = trace_resolve_type
30
+ @trace_scalars = trace_scalars
31
+ @nr_field_names = Hash.new do |h, field|
32
+ h[field] = "GraphQL/#{field.owner.graphql_name}/#{field.graphql_name}"
33
+ end.compare_by_identity
34
+
35
+ @nr_authorized_names = Hash.new do |h, type|
36
+ h[type] = "GraphQL/Authorized/#{type.graphql_name}"
37
+ end.compare_by_identity
38
+
39
+ @nr_resolve_type_names = Hash.new do |h, type|
40
+ h[type] = "GraphQL/ResolveType/#{type.graphql_name}"
41
+ end.compare_by_identity
42
+
43
+ @nr_source_names = Hash.new do |h, source_inst|
44
+ h[source_inst] = "GraphQL/Source/#{source_inst.class.name}"
45
+ end.compare_by_identity
46
+
47
+ @nr_parse = @nr_validate = @nr_analyze = @nr_execute = nil
48
+ super
49
+ end
50
+
51
+ def begin_parse(query_str)
52
+ @nr_parse = NewRelic::Agent::Tracer.start_transaction_or_segment(partial_name: "GraphQL/parse", category: :web)
53
+ super
54
+ end
55
+
56
+ def end_parse(query_str)
57
+ @nr_parse.finish
58
+ super
59
+ end
60
+
61
+ def begin_validate(query, validate)
62
+ @nr_validate = NewRelic::Agent::Tracer.start_transaction_or_segment(partial_name: "GraphQL/validate", category: :web)
13
63
  super
14
64
  end
15
65
 
16
- def execute_query(query:)
17
- set_this_txn_name = query.context[:set_new_relic_transaction_name]
18
- if set_this_txn_name == true || (set_this_txn_name.nil? && @set_transaction_name)
66
+ def end_validate(query, validate, validation_errors)
67
+ @nr_validate.finish
68
+ super
69
+ end
70
+
71
+ def begin_analyze_multiplex(multiplex, analyzers)
72
+ @nr_analyze = NewRelic::Agent::Tracer.start_transaction_or_segment(partial_name: "GraphQL/analyze", category: :web)
73
+ super
74
+ end
75
+
76
+ def end_analyze_multiplex(multiplex, analyzers)
77
+ @nr_analyze.finish
78
+ super
79
+ end
80
+
81
+ def begin_execute_multiplex(multiplex)
82
+ query = multiplex.queries.first
83
+ set_this_txn_name = query.context[:set_new_relic_transaction_name]
84
+ if set_this_txn_name || (set_this_txn_name.nil? && @set_transaction_name)
19
85
  NewRelic::Agent.set_transaction_name(transaction_name(query))
20
86
  end
21
- NewRelic::Agent::MethodTracerHelpers.trace_execution_scoped("GraphQL/execute") do
22
- super
87
+ @nr_execute = NewRelic::Agent::Tracer.start_transaction_or_segment(partial_name: "GraphQL/execute", category: :web)
88
+ super
89
+ end
90
+
91
+ def end_execute_multiplex(multiplex)
92
+ @nr_execute.finish
93
+ super
94
+ end
95
+
96
+ def begin_execute_field(field, object, arguments, query)
97
+ return_type = field.type.unwrap
98
+ trace_field = if return_type.kind.scalar? || return_type.kind.enum?
99
+ (field.trace.nil? && @trace_scalars) || field.trace
100
+ else
101
+ true
23
102
  end
103
+ if trace_field
104
+ start_segment(partial_name: @nr_field_names[field], category: :web)
105
+ end
106
+ super
107
+ end
108
+
109
+ def end_execute_field(field, objects, arguments, query, result)
110
+ finish_segment
111
+ super
24
112
  end
25
113
 
26
- {
27
- "lex" => "GraphQL/lex",
28
- "parse" => "GraphQL/parse",
29
- "validate" => "GraphQL/validate",
30
- "analyze_query" => "GraphQL/analyze",
31
- "analyze_multiplex" => "GraphQL/analyze",
32
- "execute_multiplex" => "GraphQL/execute",
33
- "execute_query_lazy" => "GraphQL/execute",
34
- }.each do |trace_method, platform_key|
35
- module_eval <<-RUBY, __FILE__, __LINE__
36
- def #{trace_method}(**_keys)
37
- NewRelic::Agent::MethodTracerHelpers.trace_execution_scoped("#{platform_key}") do
38
- super
39
- end
40
- end
41
- RUBY
42
- end
43
-
44
- def platform_execute_field(platform_key)
45
- NewRelic::Agent::MethodTracerHelpers.trace_execution_scoped(platform_key) do
46
- yield
114
+ def begin_authorized(type, obj, ctx)
115
+ if @trace_authorized
116
+ start_segment(partial_name: @nr_authorized_names[type], category: :web)
47
117
  end
118
+ super
48
119
  end
49
120
 
50
- def platform_authorized(platform_key)
51
- NewRelic::Agent::MethodTracerHelpers.trace_execution_scoped(platform_key) do
52
- yield
121
+ def end_authorized(type, obj, ctx, is_authed)
122
+ if @trace_authorized
123
+ finish_segment
53
124
  end
125
+ super
54
126
  end
55
127
 
56
- def platform_resolve_type(platform_key)
57
- NewRelic::Agent::MethodTracerHelpers.trace_execution_scoped(platform_key) do
58
- yield
128
+ def begin_resolve_type(type, value, context)
129
+ if @trace_resolve_type
130
+ start_segment(partial_name: @nr_resolve_type_names[type], category: :web)
59
131
  end
132
+ super
60
133
  end
61
134
 
62
- def platform_field_key(field)
63
- "GraphQL/#{field.owner.graphql_name}/#{field.graphql_name}"
135
+ def end_resolve_type(type, value, context, resolved_type)
136
+ if @trace_resolve_type
137
+ finish_segment
138
+ end
139
+ super
64
140
  end
65
141
 
66
- def platform_authorized_key(type)
67
- "GraphQL/Authorize/#{type.graphql_name}"
142
+ def begin_dataloader_source(source)
143
+ start_segment(partial_name: @nr_source_names[source], category: :web)
144
+ super
145
+ end
146
+
147
+ def end_dataloader_source(source)
148
+ finish_segment
149
+ super
150
+ end
151
+
152
+ def dataloader_fiber_yield(source)
153
+ prev_segment = finish_segment
154
+ Fiber[:graphql_nr_previous_segment] = prev_segment
155
+ super
156
+ end
157
+
158
+ def dataloader_fiber_resume(source)
159
+ prev_segment = Fiber[:graphql_nr_previous_segment]
160
+ Fiber[:graphql_nr_previous_segment] = nil
161
+ seg_partial_name = prev_segment.name.sub(/^.*(GraphQL.*)$/, '\1')
162
+ start_segment(partial_name: seg_partial_name, category: :web)
163
+ super
164
+ end
165
+
166
+ private
167
+
168
+ def start_segment(...)
169
+ Fiber[:graphql_nr_segment] = NewRelic::Agent::Tracer.start_transaction_or_segment(...)
170
+ end
171
+
172
+ def finish_segment
173
+ segment = Fiber[:graphql_nr_segment]
174
+ if segment
175
+ segment.finish
176
+ Fiber[:graphql_nr_segment] = nil
177
+ segment
178
+ end
179
+ end
180
+
181
+ def transaction_name(query)
182
+ selected_op = query.selected_operation
183
+ txn_name = if selected_op
184
+ op_type = selected_op.operation_type
185
+ op_name = selected_op.name || fallback_transaction_name(query.context) || "anonymous"
186
+ "#{op_type}.#{op_name}"
187
+ else
188
+ "query.anonymous"
189
+ end
190
+ "GraphQL/#{txn_name}"
68
191
  end
69
192
 
70
- def platform_resolve_type_key(type)
71
- "GraphQL/ResolveType/#{type.graphql_name}"
193
+ def fallback_transaction_name(context)
194
+ context[:tracing_fallback_transaction_name]
72
195
  end
73
196
  end
74
197
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "graphql/tracing/platform_tracing"
4
+
3
5
  module GraphQL
4
6
  module Tracing
5
7
  class NewRelicTracing < PlatformTracing
@@ -16,6 +16,8 @@ module GraphQL
16
16
  super
17
17
  end
18
18
 
19
+ # rubocop:disable Development/NoEvalCop This eval takes static inputs at load-time
20
+
19
21
  {
20
22
  "lex" => "lex.graphql",
21
23
  "parse" => "parse.graphql",
@@ -39,6 +41,8 @@ module GraphQL
39
41
  RUBY
40
42
  end
41
43
 
44
+ # rubocop:enable Development/NoEvalCop
45
+
42
46
  include PlatformTrace
43
47
  end
44
48
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "graphql/tracing/platform_tracing"
4
+
3
5
  module GraphQL
4
6
  module Tracing
5
7
  # This implementation forwards events to a notification handler (i.e.
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "graphql/tracing/trace"
4
+
5
+ module GraphQL
6
+ module Tracing
7
+ NullTrace = Trace.new
8
+ end
9
+ end
@@ -0,0 +1,141 @@
1
+ // This is an abbreviated version of the full Perfetto schema.
2
+ // Most of them are for OS or Chrome traces and we'll never use them.
3
+ // Full doc: https://github.com/google/perfetto/tree/main/protos/perfetto
4
+ //
5
+ // Build it with
6
+ // protoc --ruby_out=lib/graphql/tracing/perfetto_trace --proto_path=lib/graphql/tracing/perfetto_trace trace.proto
7
+ syntax = "proto2";
8
+ package perfetto_trace.protos;
9
+ option ruby_package = "GraphQL::Tracing::PerfettoTrace";
10
+
11
+ message Trace {
12
+ repeated TracePacket packet = 1;
13
+ }
14
+
15
+ message TracePacket {
16
+ optional uint64 timestamp = 8;
17
+ oneof data {
18
+ TrackEvent track_event = 11;
19
+ TrackDescriptor track_descriptor = 60;
20
+ }
21
+ oneof optional_trusted_packet_sequence_id {
22
+ uint32 trusted_packet_sequence_id = 10;
23
+ }
24
+ optional InternedData interned_data = 12;
25
+ optional bool first_packet_on_sequence = 87;
26
+ optional bool previous_packet_dropped = 42;
27
+ optional uint32 sequence_flags = 13;
28
+ }
29
+
30
+ message TrackEvent {
31
+ repeated uint64 category_iids = 3;
32
+ repeated string categories = 22;
33
+ oneof name_field {
34
+ uint64 name_iid = 10;
35
+ string name = 23;
36
+ }
37
+ enum Type {
38
+ TYPE_UNSPECIFIED = 0;
39
+ TYPE_SLICE_BEGIN = 1;
40
+ TYPE_SLICE_END = 2;
41
+ TYPE_INSTANT = 3;
42
+ TYPE_COUNTER = 4;
43
+ }
44
+ optional Type type = 9;
45
+ optional uint64 track_uuid = 11;
46
+ oneof counter_value_field {
47
+ int64 counter_value = 30;
48
+ double double_counter_value = 44;
49
+ }
50
+ repeated uint64 extra_counter_track_uuids = 31;
51
+ repeated int64 extra_counter_values = 12;
52
+ repeated uint64 extra_double_counter_track_uuids = 45;
53
+ repeated double extra_double_counter_values = 46;
54
+ repeated fixed64 flow_ids = 47;
55
+ repeated fixed64 terminating_flow_ids = 48;
56
+ repeated DebugAnnotation debug_annotations = 4;
57
+ }
58
+
59
+ message DebugAnnotation {
60
+ oneof name_field {
61
+ uint64 name_iid = 1;
62
+ string name = 10;
63
+ }
64
+ oneof value {
65
+ bool bool_value = 2;
66
+ uint64 uint_value = 3;
67
+ int64 int_value = 4;
68
+ double double_value = 5;
69
+ string string_value = 6;
70
+ uint64 string_value_iid = 17;
71
+ }
72
+ repeated DebugAnnotation dict_entries = 11;
73
+ repeated DebugAnnotation array_values = 12;
74
+ uint64 string_value_iid = 17;
75
+ }
76
+
77
+ message TrackDescriptor {
78
+ optional uint64 uuid = 1;
79
+ optional uint64 parent_uuid = 5;
80
+
81
+ oneof static_or_dynamic_name {
82
+ string name = 2;
83
+ }
84
+
85
+ optional CounterDescriptor counter = 8;
86
+ enum ChildTracksOrdering {
87
+ UNKNOWN = 0;
88
+ LEXICOGRAPHIC = 1;
89
+ CHRONOLOGICAL = 2;
90
+ EXPLICIT = 3;
91
+ }
92
+ optional ChildTracksOrdering child_ordering = 11;
93
+ optional int32 sibling_order_rank = 12;
94
+ }
95
+
96
+ message CounterDescriptor {
97
+ enum BuiltinCounterType {
98
+ COUNTER_UNSPECIFIED = 0;
99
+ COUNTER_THREAD_TIME_NS = 1;
100
+ COUNTER_THREAD_INSTRUCTION_COUNT = 2;
101
+ }
102
+ enum Unit {
103
+ UNIT_UNSPECIFIED = 0;
104
+ UNIT_TIME_NS = 1;
105
+ UNIT_COUNT = 2;
106
+ UNIT_SIZE_BYTES = 3;
107
+ }
108
+ optional BuiltinCounterType type = 1;
109
+ repeated string categories = 2;
110
+ optional Unit unit = 3;
111
+ optional string unit_name = 6;
112
+ optional int64 unit_multiplier = 4;
113
+ optional bool is_incremental = 5;
114
+ }
115
+
116
+ message InternedData {
117
+ repeated EventCategory event_categories = 1;
118
+ repeated EventName event_names = 2;
119
+ repeated DebugAnnotationName debug_annotation_names = 3;
120
+ repeated InternedString debug_annotation_string_values = 29;
121
+ }
122
+
123
+ message InternedString {
124
+ optional uint64 iid = 1;
125
+ optional bytes str = 2;
126
+ }
127
+
128
+ message EventCategory {
129
+ optional uint64 iid = 1;
130
+ optional string name = 2;
131
+ }
132
+
133
+ message EventName {
134
+ optional uint64 iid = 1;
135
+ optional string name = 2;
136
+ }
137
+
138
+ message DebugAnnotationName {
139
+ optional uint64 iid = 1;
140
+ optional string name = 2;
141
+ }
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # source: trace.proto
4
+
5
+ require 'google/protobuf'
6
+
7
+
8
+ descriptor_data = "\n\x0btrace.proto\x12\x15perfetto_trace.protos\";\n\x05Trace\x12\x32\n\x06packet\x18\x01 \x03(\x0b\x32\".perfetto_trace.protos.TracePacket\"\x8a\x03\n\x0bTracePacket\x12\x11\n\ttimestamp\x18\x08 \x01(\x04\x12\x38\n\x0btrack_event\x18\x0b \x01(\x0b\x32!.perfetto_trace.protos.TrackEventH\x00\x12\x42\n\x10track_descriptor\x18< \x01(\x0b\x32&.perfetto_trace.protos.TrackDescriptorH\x00\x12$\n\x1atrusted_packet_sequence_id\x18\n \x01(\rH\x01\x12:\n\rinterned_data\x18\x0c \x01(\x0b\x32#.perfetto_trace.protos.InternedData\x12 \n\x18\x66irst_packet_on_sequence\x18W \x01(\x08\x12\x1f\n\x17previous_packet_dropped\x18* \x01(\x08\x12\x16\n\x0esequence_flags\x18\r \x01(\rB\x06\n\x04\x64\x61taB%\n#optional_trusted_packet_sequence_id\"\xf2\x04\n\nTrackEvent\x12\x15\n\rcategory_iids\x18\x03 \x03(\x04\x12\x12\n\ncategories\x18\x16 \x03(\t\x12\x12\n\x08name_iid\x18\n \x01(\x04H\x00\x12\x0e\n\x04name\x18\x17 \x01(\tH\x00\x12\x34\n\x04type\x18\t \x01(\x0e\x32&.perfetto_trace.protos.TrackEvent.Type\x12\x12\n\ntrack_uuid\x18\x0b \x01(\x04\x12\x17\n\rcounter_value\x18\x1e \x01(\x03H\x01\x12\x1e\n\x14\x64ouble_counter_value\x18, \x01(\x01H\x01\x12!\n\x19\x65xtra_counter_track_uuids\x18\x1f \x03(\x04\x12\x1c\n\x14\x65xtra_counter_values\x18\x0c \x03(\x03\x12(\n extra_double_counter_track_uuids\x18- \x03(\x04\x12#\n\x1b\x65xtra_double_counter_values\x18. \x03(\x01\x12\x10\n\x08\x66low_ids\x18/ \x03(\x06\x12\x1c\n\x14terminating_flow_ids\x18\x30 \x03(\x06\x12\x41\n\x11\x64\x65\x62ug_annotations\x18\x04 \x03(\x0b\x32&.perfetto_trace.protos.DebugAnnotation\"j\n\x04Type\x12\x14\n\x10TYPE_UNSPECIFIED\x10\x00\x12\x14\n\x10TYPE_SLICE_BEGIN\x10\x01\x12\x12\n\x0eTYPE_SLICE_END\x10\x02\x12\x10\n\x0cTYPE_INSTANT\x10\x03\x12\x10\n\x0cTYPE_COUNTER\x10\x04\x42\x0c\n\nname_fieldB\x15\n\x13\x63ounter_value_field\"\xd5\x02\n\x0f\x44\x65\x62ugAnnotation\x12\x12\n\x08name_iid\x18\x01 \x01(\x04H\x00\x12\x0e\n\x04name\x18\n \x01(\tH\x00\x12\x14\n\nbool_value\x18\x02 \x01(\x08H\x01\x12\x14\n\nuint_value\x18\x03 \x01(\x04H\x01\x12\x13\n\tint_value\x18\x04 \x01(\x03H\x01\x12\x16\n\x0c\x64ouble_value\x18\x05 \x01(\x01H\x01\x12\x16\n\x0cstring_value\x18\x06 \x01(\tH\x01\x12\x1a\n\x10string_value_iid\x18\x11 \x01(\x04H\x01\x12<\n\x0c\x64ict_entries\x18\x0b \x03(\x0b\x32&.perfetto_trace.protos.DebugAnnotation\x12<\n\x0c\x61rray_values\x18\x0c \x03(\x0b\x32&.perfetto_trace.protos.DebugAnnotationB\x0c\n\nname_fieldB\x07\n\x05value\"\xe1\x02\n\x0fTrackDescriptor\x12\x0c\n\x04uuid\x18\x01 \x01(\x04\x12\x13\n\x0bparent_uuid\x18\x05 \x01(\x04\x12\x0e\n\x04name\x18\x02 \x01(\tH\x00\x12\x39\n\x07\x63ounter\x18\x08 \x01(\x0b\x32(.perfetto_trace.protos.CounterDescriptor\x12R\n\x0e\x63hild_ordering\x18\x0b \x01(\x0e\x32:.perfetto_trace.protos.TrackDescriptor.ChildTracksOrdering\x12\x1a\n\x12sibling_order_rank\x18\x0c \x01(\x05\"V\n\x13\x43hildTracksOrdering\x12\x0b\n\x07UNKNOWN\x10\x00\x12\x11\n\rLEXICOGRAPHIC\x10\x01\x12\x11\n\rCHRONOLOGICAL\x10\x02\x12\x0c\n\x08\x45XPLICIT\x10\x03\x42\x18\n\x16static_or_dynamic_name\"\xb9\x03\n\x11\x43ounterDescriptor\x12I\n\x04type\x18\x01 \x01(\x0e\x32;.perfetto_trace.protos.CounterDescriptor.BuiltinCounterType\x12\x12\n\ncategories\x18\x02 \x03(\t\x12;\n\x04unit\x18\x03 \x01(\x0e\x32-.perfetto_trace.protos.CounterDescriptor.Unit\x12\x11\n\tunit_name\x18\x06 \x01(\t\x12\x17\n\x0funit_multiplier\x18\x04 \x01(\x03\x12\x16\n\x0eis_incremental\x18\x05 \x01(\x08\"o\n\x12\x42uiltinCounterType\x12\x17\n\x13\x43OUNTER_UNSPECIFIED\x10\x00\x12\x1a\n\x16\x43OUNTER_THREAD_TIME_NS\x10\x01\x12$\n COUNTER_THREAD_INSTRUCTION_COUNT\x10\x02\"S\n\x04Unit\x12\x14\n\x10UNIT_UNSPECIFIED\x10\x00\x12\x10\n\x0cUNIT_TIME_NS\x10\x01\x12\x0e\n\nUNIT_COUNT\x10\x02\x12\x13\n\x0fUNIT_SIZE_BYTES\x10\x03\"\xa0\x02\n\x0cInternedData\x12>\n\x10\x65vent_categories\x18\x01 \x03(\x0b\x32$.perfetto_trace.protos.EventCategory\x12\x35\n\x0b\x65vent_names\x18\x02 \x03(\x0b\x32 .perfetto_trace.protos.EventName\x12J\n\x16\x64\x65\x62ug_annotation_names\x18\x03 \x03(\x0b\x32*.perfetto_trace.protos.DebugAnnotationName\x12M\n\x1e\x64\x65\x62ug_annotation_string_values\x18\x1d \x03(\x0b\x32%.perfetto_trace.protos.InternedString\"*\n\x0eInternedString\x12\x0b\n\x03iid\x18\x01 \x01(\x04\x12\x0b\n\x03str\x18\x02 \x01(\x0c\"*\n\rEventCategory\x12\x0b\n\x03iid\x18\x01 \x01(\x04\x12\x0c\n\x04name\x18\x02 \x01(\t\"&\n\tEventName\x12\x0b\n\x03iid\x18\x01 \x01(\x04\x12\x0c\n\x04name\x18\x02 \x01(\t\"0\n\x13\x44\x65\x62ugAnnotationName\x12\x0b\n\x03iid\x18\x01 \x01(\x04\x12\x0c\n\x04name\x18\x02 \x01(\tB\"\xea\x02\x1fGraphQL::Tracing::PerfettoTrace"
9
+
10
+ pool = Google::Protobuf::DescriptorPool.generated_pool
11
+ pool.add_serialized_file(descriptor_data)
12
+
13
+ module GraphQL
14
+ module Tracing
15
+ module PerfettoTrace
16
+ Trace = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("perfetto_trace.protos.Trace").msgclass
17
+ TracePacket = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("perfetto_trace.protos.TracePacket").msgclass
18
+ TrackEvent = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("perfetto_trace.protos.TrackEvent").msgclass
19
+ TrackEvent::Type = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("perfetto_trace.protos.TrackEvent.Type").enummodule
20
+ DebugAnnotation = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("perfetto_trace.protos.DebugAnnotation").msgclass
21
+ TrackDescriptor = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("perfetto_trace.protos.TrackDescriptor").msgclass
22
+ TrackDescriptor::ChildTracksOrdering = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("perfetto_trace.protos.TrackDescriptor.ChildTracksOrdering").enummodule
23
+ CounterDescriptor = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("perfetto_trace.protos.CounterDescriptor").msgclass
24
+ CounterDescriptor::BuiltinCounterType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("perfetto_trace.protos.CounterDescriptor.BuiltinCounterType").enummodule
25
+ CounterDescriptor::Unit = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("perfetto_trace.protos.CounterDescriptor.Unit").enummodule
26
+ InternedData = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("perfetto_trace.protos.InternedData").msgclass
27
+ InternedString = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("perfetto_trace.protos.InternedString").msgclass
28
+ EventCategory = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("perfetto_trace.protos.EventCategory").msgclass
29
+ EventName = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("perfetto_trace.protos.EventName").msgclass
30
+ DebugAnnotationName = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("perfetto_trace.protos.DebugAnnotationName").msgclass
31
+ end
32
+ end
33
+ end