File: grpc_common.rb

package info (click to toggle)
ruby-gitlab-labkit 0.36.1-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 444 kB
  • sloc: ruby: 1,705; makefile: 6
file content (23 lines) | stat: -rw-r--r-- 622 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

module Labkit
  module Correlation
    module GRPC
      # This module is shared between the client and server interceptor middlewares.
      # It is not part of the public API
      module GRPCCommon
        CORRELATION_METADATA_KEY = "x-gitlab-correlation-id"

        def rpc_split(method)
          owner = method.owner
          method_name, = owner.rpc_descs.find do |k, _|
            ::GRPC::GenericService.underscore(k.to_s) == method.name.to_s
          end
          method_name ||= "(unknown)"

          [owner.service_name, method_name]
        end
      end
    end
  end
end