Module: Sleuth
- Defined in:
- lib/sleuth.rb,
lib/sleuth/middleware.rb,
lib/sleuth/transaction.rb,
lib/sleuth/outbound_handler.rb
Defined Under Namespace
Classes: Event, Middleware, OutboundHeader, Transaction
Constant Summary
collapse
"X_SLEUTH_TRANSACTION"
Class Method Summary
collapse
Class Method Details
.current_id ⇒ Object
34
35
36
|
# File 'lib/sleuth.rb', line 34
def current_id
ActiveSupport::Notifications.transaction_id
end
|
.current_transaction ⇒ Object
38
39
40
|
# File 'lib/sleuth.rb', line 38
def current_transaction
Transaction.running[current_id]
end
|
.http ⇒ Object
14
15
16
17
18
|
# File 'lib/sleuth.rb', line 14
def http
@http ||= Rack::Client.new {
use OutboundHeader
}
end
|
.instrument(payload) ⇒ Object
20
21
22
23
24
|
# File 'lib/sleuth.rb', line 20
def instrument(payload)
ActiveSupport::Notifications.instrument(:sleuth, payload) do
yield
end
end
|
.transaction(current_name, parent = nil) ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/sleuth.rb', line 26
def transaction(current_name, parent = nil)
ActiveSupport::Notifications.transaction do
Transaction.create(current_name, current_id, parent)
yield
end
end
|
.watch(log_path) ⇒ Object
42
43
44
45
46
47
|
# File 'lib/sleuth.rb', line 42
def watch(log_path)
logger = ActiveSupport::BufferedLogger.new(log_path)
ActiveSupport::Notifications.subscribe('sleuth') do |*args|
logger.debug(Transaction.message_for(*args))
end
end
|