class ActiveEndpoint::Proxy
Public Class Methods
new()
click to toggle source
# File lib/active_endpoint/proxy.rb, line 3 def initialize @created_at = Time.now @matcher = ActiveEndpoint::Routes::Matcher.new @logger = ActiveEndpoint.logger @notifier = ActiveSupport::Notifications end
Public Instance Methods
track(env) { |block| ... }
click to toggle source
# File lib/active_endpoint/proxy.rb, line 10 def track(env, &block) request = ActiveEndpoint::Request.new(env) if ActiveEndpoint.log_debug_info @logger.debug('ActiveEndpoint::Blacklist', ActiveEndpoint.blacklist.inspect) @logger.debug('ActiveEndpoint::Constraints', ActiveEndpoint.constraints.inspect) end if @matcher.whitelisted?(request) track_begin(request) status, headers, response = yield block track_end(response) [status, headers, response] else register(request) if @matcher.unregistred?(request) yield block end rescue => error @logger.error(self.class, error) yield block end
Private Instance Methods
register(request)
click to toggle source
# File lib/active_endpoint/proxy.rb, line 54 def register(request) unregistred = { created_at: @created_at, finished_at: @finished_at, request: request.probe } @notifier.instrument('active_endpoint.unregistred_probe', probe: unregistred) if @matcher.allow_register?(request) end
track_begin(request)
click to toggle source
# File lib/active_endpoint/proxy.rb, line 36 def track_begin(request) @request = request.probe end
track_end(response, finished_at = Time.now)
click to toggle source
# File lib/active_endpoint/proxy.rb, line 40 def track_end(response, finished_at = Time.now) @response = ActiveEndpoint::Response.new(response).probe @finished_at = finished_at probe = { created_at: @created_at, finished_at: @finished_at, request: @request, response: @response } @notifier.instrument('active_endpoint.tracked_probe', probe: probe) if @matcher.allow_account?(@request) end