diff options
author | Andrew Newdigate <andrew@gitlab.com> | 2019-02-18 22:57:22 +0200 |
---|---|---|
committer | Andrew Newdigate <andrew@gitlab.com> | 2019-04-18 09:57:16 +0200 |
commit | 4f4de36cacbcd137e9db2a7b1449bb803bf1f395 (patch) | |
tree | 7514b0a3c310091bf0b909fc9544968fbe4619ab /lib | |
parent | d9e5edf198803aded681cb900c50bc454fade7f3 (diff) | |
download | gitlab-ce-4f4de36cacbcd137e9db2a7b1449bb803bf1f395.tar.gz |
Migrate correlation and tracing code to LabKitan-use-labkit
This change is a fairly straightforward refactor to extract the tracing
and correlation-id code from the gitlab rails codebase into the new
LabKit-Ruby project.
The corresponding import into LabKit-Ruby was in
https://gitlab.com/gitlab-org/labkit-ruby/merge_requests/1
The code itself remains very similar for now.
Extracting it allows us to reuse it in other projects, such as
Gitaly-Ruby. This will give us the advantages of correlation-ids and
distributed tracing in that project too.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/gitaly_client.rb | 6 | ||||
-rw-r--r-- | lib/gitlab/grape_logging/loggers/correlation_id_logger.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/json_logger.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/middleware/correlation_id.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/sentry.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/sidekiq_middleware/correlation_injector.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/sidekiq_middleware/correlation_logger.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/tracing/common.rb | 69 | ||||
-rw-r--r-- | lib/gitlab/tracing/factory.rb | 61 | ||||
-rw-r--r-- | lib/gitlab/tracing/grpc_interceptor.rb | 54 | ||||
-rw-r--r-- | lib/gitlab/tracing/jaeger_factory.rb | 97 | ||||
-rw-r--r-- | lib/gitlab/tracing/rack_middleware.rb | 46 | ||||
-rw-r--r-- | lib/gitlab/tracing/rails/action_view_subscriber.rb | 75 | ||||
-rw-r--r-- | lib/gitlab/tracing/rails/active_record_subscriber.rb | 49 | ||||
-rw-r--r-- | lib/gitlab/tracing/rails/rails_common.rb | 24 | ||||
-rw-r--r-- | lib/gitlab/tracing/sidekiq/client_middleware.rb | 26 | ||||
-rw-r--r-- | lib/gitlab/tracing/sidekiq/server_middleware.rb | 26 | ||||
-rw-r--r-- | lib/gitlab/tracing/sidekiq/sidekiq_common.rb | 22 | ||||
-rw-r--r-- | lib/peek/views/tracing.rb | 6 |
19 files changed, 14 insertions, 563 deletions
diff --git a/lib/gitlab/gitaly_client.rb b/lib/gitlab/gitaly_client.rb index 726c4d95da9..c432317eb24 100644 --- a/lib/gitlab/gitaly_client.rb +++ b/lib/gitlab/gitaly_client.rb @@ -52,9 +52,9 @@ module Gitlab end def self.interceptors - return [] unless Gitlab::Tracing.enabled? + return [] unless Labkit::Tracing.enabled? - [Gitlab::Tracing::GRPCInterceptor.instance] + [Labkit::Tracing::GRPCInterceptor.instance] end private_class_method :interceptors @@ -218,7 +218,7 @@ module Gitlab feature = feature_stack && feature_stack[0] metadata['call_site'] = feature.to_s if feature metadata['gitaly-servers'] = address_metadata(remote_storage) if remote_storage - metadata['x-gitlab-correlation-id'] = Gitlab::CorrelationId.current_id if Gitlab::CorrelationId.current_id + metadata['x-gitlab-correlation-id'] = Labkit::Correlation::CorrelationId.current_id if Labkit::Correlation::CorrelationId.current_id metadata.merge!(server_feature_flags) diff --git a/lib/gitlab/grape_logging/loggers/correlation_id_logger.rb b/lib/gitlab/grape_logging/loggers/correlation_id_logger.rb index fa4c5d86d44..bbe4b24c7d4 100644 --- a/lib/gitlab/grape_logging/loggers/correlation_id_logger.rb +++ b/lib/gitlab/grape_logging/loggers/correlation_id_logger.rb @@ -6,7 +6,7 @@ module Gitlab module Loggers class CorrelationIdLogger < ::GrapeLogging::Loggers::Base def parameters(_, _) - { Gitlab::CorrelationId::LOG_KEY => Gitlab::CorrelationId.current_id } + { Labkit::Correlation::CorrelationId::LOG_KEY => Labkit::Correlation::CorrelationId.current_id } end end end diff --git a/lib/gitlab/json_logger.rb b/lib/gitlab/json_logger.rb index a5a5759cc89..ab34fb03158 100644 --- a/lib/gitlab/json_logger.rb +++ b/lib/gitlab/json_logger.rb @@ -10,7 +10,7 @@ module Gitlab data = {} data[:severity] = severity data[:time] = timestamp.utc.iso8601(3) - data[Gitlab::CorrelationId::LOG_KEY] = Gitlab::CorrelationId.current_id + data[Labkit::Correlation::CorrelationId::LOG_KEY] = Labkit::Correlation::CorrelationId.current_id case message when String diff --git a/lib/gitlab/middleware/correlation_id.rb b/lib/gitlab/middleware/correlation_id.rb index 80dddc41c12..fffd5da827f 100644 --- a/lib/gitlab/middleware/correlation_id.rb +++ b/lib/gitlab/middleware/correlation_id.rb @@ -12,7 +12,7 @@ module Gitlab end def call(env) - ::Gitlab::CorrelationId.use_id(correlation_id(env)) do + ::Labkit::Correlation::CorrelationId.use_id(correlation_id(env)) do @app.call(env) end end diff --git a/lib/gitlab/sentry.rb b/lib/gitlab/sentry.rb index 956c16117f5..356e6445e0e 100644 --- a/lib/gitlab/sentry.rb +++ b/lib/gitlab/sentry.rb @@ -45,7 +45,7 @@ module Gitlab context # Make sure we've set everything we know in the context tags = { - Gitlab::CorrelationId::LOG_KEY.to_sym => Gitlab::CorrelationId.current_id + Labkit::Correlation::CorrelationId::LOG_KEY.to_sym => Labkit::Correlation::CorrelationId.current_id } Raven.capture_exception(exception, tags: tags, extra: extra) diff --git a/lib/gitlab/sidekiq_middleware/correlation_injector.rb b/lib/gitlab/sidekiq_middleware/correlation_injector.rb index b807b3a03ed..1539fd706ab 100644 --- a/lib/gitlab/sidekiq_middleware/correlation_injector.rb +++ b/lib/gitlab/sidekiq_middleware/correlation_injector.rb @@ -4,8 +4,8 @@ module Gitlab module SidekiqMiddleware class CorrelationInjector def call(worker_class, job, queue, redis_pool) - job[Gitlab::CorrelationId::LOG_KEY] ||= - Gitlab::CorrelationId.current_or_new_id + job[Labkit::Correlation::CorrelationId::LOG_KEY] ||= + Labkit::Correlation::CorrelationId.current_or_new_id yield end diff --git a/lib/gitlab/sidekiq_middleware/correlation_logger.rb b/lib/gitlab/sidekiq_middleware/correlation_logger.rb index cb8ff4a6284..cffc4483573 100644 --- a/lib/gitlab/sidekiq_middleware/correlation_logger.rb +++ b/lib/gitlab/sidekiq_middleware/correlation_logger.rb @@ -4,9 +4,9 @@ module Gitlab module SidekiqMiddleware class CorrelationLogger def call(worker, job, queue) - correlation_id = job[Gitlab::CorrelationId::LOG_KEY] + correlation_id = job[Labkit::Correlation::CorrelationId::LOG_KEY] - Gitlab::CorrelationId.use_id(correlation_id) do + Labkit::Correlation::CorrelationId.use_id(correlation_id) do yield end end diff --git a/lib/gitlab/tracing/common.rb b/lib/gitlab/tracing/common.rb deleted file mode 100644 index 3a08ede8138..00000000000 --- a/lib/gitlab/tracing/common.rb +++ /dev/null @@ -1,69 +0,0 @@ -# frozen_string_literal: true - -require 'opentracing' - -module Gitlab - module Tracing - module Common - def tracer - OpenTracing.global_tracer - end - - # Convience method for running a block with a span - def in_tracing_span(operation_name:, tags:, child_of: nil) - scope = tracer.start_active_span( - operation_name, - child_of: child_of, - tags: tags - ) - span = scope.span - - # Add correlation details to the span if we have them - correlation_id = Gitlab::CorrelationId.current_id - if correlation_id - span.set_tag('correlation_id', correlation_id) - end - - begin - yield span - rescue => e - log_exception_on_span(span, e) - raise e - ensure - scope.close - end - end - - def postnotify_span(operation_name, start_time, end_time, tags: nil, child_of: nil, exception: nil) - span = OpenTracing.start_span(operation_name, start_time: start_time, tags: tags, child_of: child_of) - - log_exception_on_span(span, exception) if exception - - span.finish(end_time: end_time) - end - - def log_exception_on_span(span, exception) - span.set_tag('error', true) - span.log_kv(kv_tags_for_exception(exception)) - end - - def kv_tags_for_exception(exception) - case exception - when Exception - { - 'event': 'error', - 'error.kind': exception.class.to_s, - 'message': Gitlab::UrlSanitizer.sanitize(exception.message), - 'stack': exception.backtrace&.join("\n") - } - else - { - 'event': 'error', - 'error.kind': exception.class.to_s, - 'error.object': Gitlab::UrlSanitizer.sanitize(exception.to_s) - } - end - end - end - end -end diff --git a/lib/gitlab/tracing/factory.rb b/lib/gitlab/tracing/factory.rb deleted file mode 100644 index fc714164353..00000000000 --- a/lib/gitlab/tracing/factory.rb +++ /dev/null @@ -1,61 +0,0 @@ -# frozen_string_literal: true - -require "cgi" - -module Gitlab - module Tracing - class Factory - OPENTRACING_SCHEME = "opentracing" - - def self.create_tracer(service_name, connection_string) - return unless connection_string.present? - - begin - opentracing_details = parse_connection_string(connection_string) - driver_name = opentracing_details[:driver_name] - - case driver_name - when "jaeger" - JaegerFactory.create_tracer(service_name, opentracing_details[:options]) - else - raise "Unknown driver: #{driver_name}" - end - rescue => e - # Can't create the tracer? Warn and continue sans tracer - warn "Unable to instantiate tracer: #{e}" - nil - end - end - - def self.parse_connection_string(connection_string) - parsed = URI.parse(connection_string) - - unless valid_uri?(parsed) - raise "Invalid tracing connection string" - end - - { - driver_name: parsed.host, - options: parse_query(parsed.query) - } - end - private_class_method :parse_connection_string - - def self.parse_query(query) - return {} unless query - - CGI.parse(query).symbolize_keys.transform_values(&:first) - end - private_class_method :parse_query - - def self.valid_uri?(uri) - return false unless uri - - uri.scheme == OPENTRACING_SCHEME && - uri.host.to_s =~ /^[a-z0-9_]+$/ && - uri.path.empty? - end - private_class_method :valid_uri? - end - end -end diff --git a/lib/gitlab/tracing/grpc_interceptor.rb b/lib/gitlab/tracing/grpc_interceptor.rb deleted file mode 100644 index 6c2aab73125..00000000000 --- a/lib/gitlab/tracing/grpc_interceptor.rb +++ /dev/null @@ -1,54 +0,0 @@ -# frozen_string_literal: true - -require 'opentracing' -require 'grpc' - -module Gitlab - module Tracing - class GRPCInterceptor < GRPC::ClientInterceptor - include Common - include Singleton - - def request_response(request:, call:, method:, metadata:) - wrap_with_tracing(method, 'unary', metadata) do - yield - end - end - - def client_streamer(requests:, call:, method:, metadata:) - wrap_with_tracing(method, 'client_stream', metadata) do - yield - end - end - - def server_streamer(request:, call:, method:, metadata:) - wrap_with_tracing(method, 'server_stream', metadata) do - yield - end - end - - def bidi_streamer(requests:, call:, method:, metadata:) - wrap_with_tracing(method, 'bidi_stream', metadata) do - yield - end - end - - private - - def wrap_with_tracing(method, grpc_type, metadata) - tags = { - 'component' => 'grpc', - 'span.kind' => 'client', - 'grpc.method' => method, - 'grpc.type' => grpc_type - } - - in_tracing_span(operation_name: "grpc:#{method}", tags: tags) do |span| - OpenTracing.inject(span.context, OpenTracing::FORMAT_TEXT_MAP, metadata) - - yield - end - end - end - end -end diff --git a/lib/gitlab/tracing/jaeger_factory.rb b/lib/gitlab/tracing/jaeger_factory.rb deleted file mode 100644 index 93520d5667b..00000000000 --- a/lib/gitlab/tracing/jaeger_factory.rb +++ /dev/null @@ -1,97 +0,0 @@ -# frozen_string_literal: true - -require 'jaeger/client' - -module Gitlab - module Tracing - class JaegerFactory - # When the probabilistic sampler is used, by default 0.1% of requests will be traced - DEFAULT_PROBABILISTIC_RATE = 0.001 - - # The default port for the Jaeger agent UDP listener - DEFAULT_UDP_PORT = 6831 - - # Reduce this from default of 10 seconds as the Ruby jaeger - # client doesn't have overflow control, leading to very large - # messages which fail to send over UDP (max packet = 64k) - # Flush more often, with smaller packets - FLUSH_INTERVAL = 5 - - def self.create_tracer(service_name, options) - kwargs = { - service_name: service_name, - sampler: get_sampler(options[:sampler], options[:sampler_param]), - reporter: get_reporter(service_name, options[:http_endpoint], options[:udp_endpoint]) - }.compact - - extra_params = options.except(:sampler, :sampler_param, :http_endpoint, :udp_endpoint, :strict_parsing, :debug) # rubocop: disable CodeReuse/ActiveRecord - if extra_params.present? - message = "jaeger tracer: invalid option: #{extra_params.keys.join(", ")}" - - if options[:strict_parsing] - raise message - else - warn message - end - end - - Jaeger::Client.build(kwargs) - end - - def self.get_sampler(sampler_type, sampler_param) - case sampler_type - when "probabilistic" - sampler_rate = sampler_param ? sampler_param.to_f : DEFAULT_PROBABILISTIC_RATE - Jaeger::Samplers::Probabilistic.new(rate: sampler_rate) - when "const" - const_value = sampler_param == "1" - Jaeger::Samplers::Const.new(const_value) - else - nil - end - end - private_class_method :get_sampler - - def self.get_reporter(service_name, http_endpoint, udp_endpoint) - encoder = Jaeger::Encoders::ThriftEncoder.new(service_name: service_name) - - if http_endpoint.present? - sender = get_http_sender(encoder, http_endpoint) - elsif udp_endpoint.present? - sender = get_udp_sender(encoder, udp_endpoint) - else - return - end - - Jaeger::Reporters::RemoteReporter.new( - sender: sender, - flush_interval: FLUSH_INTERVAL - ) - end - private_class_method :get_reporter - - def self.get_http_sender(encoder, address) - Jaeger::HttpSender.new( - url: address, - encoder: encoder, - logger: Logger.new(STDOUT) - ) - end - private_class_method :get_http_sender - - def self.get_udp_sender(encoder, address) - pair = address.split(":", 2) - host = pair[0] - port = pair[1] ? pair[1].to_i : DEFAULT_UDP_PORT - - Jaeger::UdpSender.new( - host: host, - port: port, - encoder: encoder, - logger: Logger.new(STDOUT) - ) - end - private_class_method :get_udp_sender - end - end -end diff --git a/lib/gitlab/tracing/rack_middleware.rb b/lib/gitlab/tracing/rack_middleware.rb deleted file mode 100644 index e6a31293f7b..00000000000 --- a/lib/gitlab/tracing/rack_middleware.rb +++ /dev/null @@ -1,46 +0,0 @@ -# frozen_string_literal: true - -require 'opentracing' - -module Gitlab - module Tracing - class RackMiddleware - include Common - - REQUEST_METHOD = 'REQUEST_METHOD' - - def initialize(app) - @app = app - end - - def call(env) - method = env[REQUEST_METHOD] - - context = tracer.extract(OpenTracing::FORMAT_RACK, env) - tags = { - 'component' => 'rack', - 'span.kind' => 'server', - 'http.method' => method, - 'http.url' => self.class.build_sanitized_url_from_env(env) - } - - in_tracing_span(operation_name: "http:#{method}", child_of: context, tags: tags) do |span| - @app.call(env).tap do |status_code, _headers, _body| - span.set_tag('http.status_code', status_code) - end - end - end - - # Generate a sanitized (safe) request URL from the rack environment - def self.build_sanitized_url_from_env(env) - request = ActionDispatch::Request.new(env) - - original_url = request.original_url - uri = URI.parse(original_url) - uri.query = request.filtered_parameters.to_query if uri.query.present? - - uri.to_s - end - end - end -end diff --git a/lib/gitlab/tracing/rails/action_view_subscriber.rb b/lib/gitlab/tracing/rails/action_view_subscriber.rb deleted file mode 100644 index 88816e1fb32..00000000000 --- a/lib/gitlab/tracing/rails/action_view_subscriber.rb +++ /dev/null @@ -1,75 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module Tracing - module Rails - class ActionViewSubscriber - include RailsCommon - - COMPONENT_TAG = 'ActionView' - RENDER_TEMPLATE_NOTIFICATION_TOPIC = 'render_template.action_view' - RENDER_COLLECTION_NOTIFICATION_TOPIC = 'render_collection.action_view' - RENDER_PARTIAL_NOTIFICATION_TOPIC = 'render_partial.action_view' - - # Instruments Rails ActionView events for opentracing. - # Returns a lambda, which, when called will unsubscribe from the notifications - def self.instrument - subscriber = new - - subscriptions = [ - ActiveSupport::Notifications.subscribe(RENDER_TEMPLATE_NOTIFICATION_TOPIC) do |_, start, finish, _, payload| - subscriber.notify_render_template(start, finish, payload) - end, - ActiveSupport::Notifications.subscribe(RENDER_COLLECTION_NOTIFICATION_TOPIC) do |_, start, finish, _, payload| - subscriber.notify_render_collection(start, finish, payload) - end, - ActiveSupport::Notifications.subscribe(RENDER_PARTIAL_NOTIFICATION_TOPIC) do |_, start, finish, _, payload| - subscriber.notify_render_partial(start, finish, payload) - end - ] - - create_unsubscriber subscriptions - end - - # For more information on the payloads: https://guides.rubyonrails.org/active_support_instrumentation.html - def notify_render_template(start, finish, payload) - generate_span_for_notification("render_template", start, finish, payload, tags_for_render_template(payload)) - end - - def notify_render_collection(start, finish, payload) - generate_span_for_notification("render_collection", start, finish, payload, tags_for_render_collection(payload)) - end - - def notify_render_partial(start, finish, payload) - generate_span_for_notification("render_partial", start, finish, payload, tags_for_render_partial(payload)) - end - - private - - def tags_for_render_template(payload) - { - 'component' => COMPONENT_TAG, - 'template.id' => payload[:identifier], - 'template.layout' => payload[:layout] - } - end - - def tags_for_render_collection(payload) - { - 'component' => COMPONENT_TAG, - 'template.id' => payload[:identifier], - 'template.count' => payload[:count] || 0, - 'template.cache.hits' => payload[:cache_hits] || 0 - } - end - - def tags_for_render_partial(payload) - { - 'component' => COMPONENT_TAG, - 'template.id' => payload[:identifier] - } - end - end - end - end -end diff --git a/lib/gitlab/tracing/rails/active_record_subscriber.rb b/lib/gitlab/tracing/rails/active_record_subscriber.rb deleted file mode 100644 index 32f5658e57e..00000000000 --- a/lib/gitlab/tracing/rails/active_record_subscriber.rb +++ /dev/null @@ -1,49 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module Tracing - module Rails - class ActiveRecordSubscriber - include RailsCommon - - ACTIVE_RECORD_NOTIFICATION_TOPIC = 'sql.active_record' - OPERATION_NAME_PREFIX = 'active_record:' - DEFAULT_OPERATION_NAME = 'sqlquery' - - # Instruments Rails ActiveRecord events for opentracing. - # Returns a lambda, which, when called will unsubscribe from the notifications - def self.instrument - subscriber = new - - subscription = ActiveSupport::Notifications.subscribe(ACTIVE_RECORD_NOTIFICATION_TOPIC) do |_, start, finish, _, payload| - subscriber.notify(start, finish, payload) - end - - create_unsubscriber [subscription] - end - - # For more information on the payloads: https://guides.rubyonrails.org/active_support_instrumentation.html - def notify(start, finish, payload) - generate_span_for_notification(notification_name(payload), start, finish, payload, tags_for_notification(payload)) - end - - private - - def notification_name(payload) - OPERATION_NAME_PREFIX + (payload[:name].presence || DEFAULT_OPERATION_NAME) - end - - def tags_for_notification(payload) - { - 'component' => 'ActiveRecord', - 'span.kind' => 'client', - 'db.type' => 'sql', - 'db.connection_id' => payload[:connection_id], - 'db.cached' => payload[:cached] || false, - 'db.statement' => payload[:sql] - } - end - end - end - end -end diff --git a/lib/gitlab/tracing/rails/rails_common.rb b/lib/gitlab/tracing/rails/rails_common.rb deleted file mode 100644 index 88e914f62f8..00000000000 --- a/lib/gitlab/tracing/rails/rails_common.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module Tracing - module Rails - module RailsCommon - extend ActiveSupport::Concern - include Gitlab::Tracing::Common - - class_methods do - def create_unsubscriber(subscriptions) - -> { subscriptions.each { |subscriber| ActiveSupport::Notifications.unsubscribe(subscriber) } } - end - end - - def generate_span_for_notification(operation_name, start, finish, payload, tags) - exception = payload[:exception] - - postnotify_span(operation_name, start, finish, tags: tags, exception: exception) - end - end - end - end -end diff --git a/lib/gitlab/tracing/sidekiq/client_middleware.rb b/lib/gitlab/tracing/sidekiq/client_middleware.rb deleted file mode 100644 index 2b71c1ea21e..00000000000 --- a/lib/gitlab/tracing/sidekiq/client_middleware.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -require 'opentracing' - -module Gitlab - module Tracing - module Sidekiq - class ClientMiddleware - include SidekiqCommon - - SPAN_KIND = 'client' - - def call(worker_class, job, queue, redis_pool) - in_tracing_span( - operation_name: "sidekiq:#{job['class']}", - tags: tags_from_job(job, SPAN_KIND)) do |span| - # Inject the details directly into the job - tracer.inject(span.context, OpenTracing::FORMAT_TEXT_MAP, job) - - yield - end - end - end - end - end -end diff --git a/lib/gitlab/tracing/sidekiq/server_middleware.rb b/lib/gitlab/tracing/sidekiq/server_middleware.rb deleted file mode 100644 index 5b43c4310e6..00000000000 --- a/lib/gitlab/tracing/sidekiq/server_middleware.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -require 'opentracing' - -module Gitlab - module Tracing - module Sidekiq - class ServerMiddleware - include SidekiqCommon - - SPAN_KIND = 'server' - - def call(worker, job, queue) - context = tracer.extract(OpenTracing::FORMAT_TEXT_MAP, job) - - in_tracing_span( - operation_name: "sidekiq:#{job['class']}", - child_of: context, - tags: tags_from_job(job, SPAN_KIND)) do |span| - yield - end - end - end - end - end -end diff --git a/lib/gitlab/tracing/sidekiq/sidekiq_common.rb b/lib/gitlab/tracing/sidekiq/sidekiq_common.rb deleted file mode 100644 index a911a29d773..00000000000 --- a/lib/gitlab/tracing/sidekiq/sidekiq_common.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module Tracing - module Sidekiq - module SidekiqCommon - include Gitlab::Tracing::Common - - def tags_from_job(job, kind) - { - 'component' => 'sidekiq', - 'span.kind' => kind, - 'sidekiq.queue' => job['queue'], - 'sidekiq.jid' => job['jid'], - 'sidekiq.retry' => job['retry'].to_s, - 'sidekiq.args' => job['args']&.join(", ") - } - end - end - end - end -end diff --git a/lib/peek/views/tracing.rb b/lib/peek/views/tracing.rb index 0de32a8fdda..94726a498ea 100644 --- a/lib/peek/views/tracing.rb +++ b/lib/peek/views/tracing.rb @@ -4,9 +4,9 @@ module Peek module Views class Tracing < View def results - { - tracing_url: Gitlab::Tracing.tracing_url - } + tracing_url = Labkit::Tracing.tracing_url(Gitlab.process_name) + + { tracing_url: tracing_url } end end end |