Sha256: 6db3bcbee4b9c5d53cb6c35fe39206d93dad1f07133f0e7bbaad274adb0f5668
Contents?: true
Size: 1.06 KB
Versions: 2
Compression:
Stored size: 1.06 KB
Contents
# frozen_string_literal: true module ElasticAPM # @api private module Spies # @api private class NetHTTPSpy # rubocop:disable Metrics/MethodLength, Metrics/AbcSize def install Net::HTTP.class_eval do alias request_without_apm request def request(req, body = nil, &block) unless (transaction = ElasticAPM.current_transaction) return request_without_apm(req, body, &block) end host, = req['host'] && req['host'].split(':') method = req.method host ||= address name = "#{method} #{host}" type = "ext.net_http.#{method}" ElasticAPM.with_span name, type do |span| req['Elastic-Apm-Traceparent'] = transaction.traceparent.to_header(span_id: span.id) request_without_apm(req, body, &block) end end end end # rubocop:enable Metrics/MethodLength, Metrics/AbcSize end register 'Net::HTTP', 'net/http', NetHTTPSpy.new end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
elastic-apm-2.0.1 | lib/elastic_apm/spies/net_http.rb |
elastic-apm-2.0.0 | lib/elastic_apm/spies/net_http.rb |