File: request_instrumenter.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 (35 lines) | stat: -rw-r--r-- 1,013 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
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true

module Labkit
  module Tracing
    module ExternalHttp
      # For more information on the payloads: lib/labkit/net_http_publisher.rb
      class RequestInstrumenter < Labkit::Tracing::AbstractInstrumenter
        def span_name(_payload)
          "external_http:request"
        end

        def tags(payload)
          # Duration is calculated by start and end time
          # Exception is already captured in lib/labkit/tracing/tracing_utils.rb
          tags = {
            "component" => "external_http",
            "method" => payload[:method],
            "code" => payload[:code],
            "host" => payload[:host],
            "port" => payload[:port],
            "path" => payload[:path],
            "scheme" => payload[:scheme],
          }

          unless payload[:proxy_host].nil?
            tags["proxy_host"] = payload[:proxy_host]
            tags["proxy_port"] = payload[:proxy_port]
          end

          tags
        end
      end
    end
  end
end