Sha256: 6bdc65570a49a020338c5f56207204eee359beda949084c49f63820861051304
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true module ElasticAPM # @api private module Injectors # @api private class NetHTTPInjector # rubocop:disable Metrics/AbcSize, Metrics/MethodLength def install Net::HTTP.class_eval do alias request_without_apm request def request(req, body = nil, &block) unless ElasticAPM.current_transaction return request_without_apm(req, body, &block) end host, port = req['host'] && req['host'].split(':') method = req.method path = req.path scheme = use_ssl? ? 'https' : 'http' # inside a session host ||= address port ||= 80 # TODO: investigate _extra = { scheme: scheme, port: port, path: path } name = "#{method} #{host}" type = "ext.net_http.#{method}" ElasticAPM.span name, type do request_without_apm(req, body, &block) end end end end # rubocop:enable Metrics/AbcSize, Metrics/MethodLength end register 'Net::HTTP', 'net/http', NetHTTPInjector.new end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
elastic-apm-0.6.1 | lib/elastic_apm/injectors/net_http.rb |
elastic-apm-0.5.1 | lib/elastic_apm/injectors/net_http.rb |