Module: Bugwatch::HttpTracker

Defined in:
lib/bugwatch/http_tracker.rb

Defined Under Namespace

Modules: NetHttpPatch

Constant Summary collapse

THREAD_KEY =
:bugwatch_http_tracker
CALLER_FILTER =
%r{/(bugwatch|ruby/gems)/}

Class Method Summary collapse

Class Method Details

.clearObject



46
47
48
# File 'lib/bugwatch/http_tracker.rb', line 46

def clear
  Thread.current[THREAD_KEY] = nil
end

.collecting?Boolean

Returns:

  • (Boolean)


50
51
52
53
# File 'lib/bugwatch/http_tracker.rb', line 50

def collecting?
  state = Thread.current[THREAD_KEY]
  state && state[:collecting]
end

.finish_requestObject



40
41
42
43
44
# File 'lib/bugwatch/http_tracker.rb', line 40

def finish_request
  state = Thread.current[THREAD_KEY]
  Thread.current[THREAD_KEY] = nil
  state
end

.start_request(collecting:) ⇒ Object



33
34
35
36
37
38
# File 'lib/bugwatch/http_tracker.rb', line 33

def start_request(collecting:)
  Thread.current[THREAD_KEY] = {
    calls:      [],
    collecting: collecting
  }
end

.subscribe!Object



27
28
29
30
31
# File 'lib/bugwatch/http_tracker.rb', line 27

def subscribe!
  return if Net::HTTP.ancestors.include?(NetHttpPatch)

  Net::HTTP.prepend(NetHttpPatch)
end