Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/graphql/generic_tracing.rb')
-rw-r--r--lib/gitlab/graphql/generic_tracing.rb71
1 files changed, 0 insertions, 71 deletions
diff --git a/lib/gitlab/graphql/generic_tracing.rb b/lib/gitlab/graphql/generic_tracing.rb
deleted file mode 100644
index dc3f6574631..00000000000
--- a/lib/gitlab/graphql/generic_tracing.rb
+++ /dev/null
@@ -1,71 +0,0 @@
-# frozen_string_literal: true
-
-# This class is used as a hook to observe graphql runtime events. From this
-# hook both gitlab metrics and opentracking measurements are generated
-
-module Gitlab
- module Graphql
- class GenericTracing < GraphQL::Tracing::PlatformTracing
- self.platform_keys = {
- 'lex' => 'graphql.lex',
- 'parse' => 'graphql.parse',
- 'validate' => 'graphql.validate',
- 'analyze_query' => 'graphql.analyze',
- 'analyze_multiplex' => 'graphql.analyze',
- 'execute_multiplex' => 'graphql.execute',
- 'execute_query' => 'graphql.execute',
- 'execute_query_lazy' => 'graphql.execute',
- 'execute_field' => 'graphql.execute',
- 'execute_field_lazy' => 'graphql.execute'
- }
-
- def platform_field_key(type, field)
- "#{type.name}.#{field.name}"
- end
-
- def platform_authorized_key(type)
- "#{type.graphql_name}.authorized"
- end
-
- def platform_resolve_type_key(type)
- "#{type.graphql_name}.resolve_type"
- end
-
- def platform_trace(platform_key, key, data, &block)
- tags = { platform_key: platform_key, key: key }
- start = Gitlab::Metrics::System.monotonic_time
-
- with_labkit_tracing(tags, &block)
- ensure
- duration = Gitlab::Metrics::System.monotonic_time - start
-
- graphql_duration_seconds.observe(tags, duration) unless deactivated?
- end
-
- private
-
- def deactivated?
- Feature.enabled?(:graphql_generic_tracing_metrics_deactivate)
- end
-
- def with_labkit_tracing(tags, &block)
- return yield unless Labkit::Tracing.enabled?
-
- name = "#{tags[:platform_key]}.#{tags[:key]}"
- span_tags = {
- 'component' => 'web',
- 'span.kind' => 'server'
- }.merge(tags.stringify_keys)
-
- Labkit::Tracing.with_tracing(operation_name: name, tags: span_tags, &block)
- end
-
- def graphql_duration_seconds
- @graphql_duration_seconds ||= Gitlab::Metrics.histogram(
- :graphql_duration_seconds,
- 'GraphQL execution time'
- )
- end
- end
- end
-end