Class: ScoutApm::SlowTransaction

Inherits:
Object
  • Object
show all
Includes:
BucketNameSplitter
Defined in:
lib/scout_apm/slow_transaction.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BucketNameSplitter

#bucket_name, #bucket_type, #key

Constructor Details

#initialize(uri, metric_name, total_call_time, metrics, allocation_metrics, context, time, raw_stackprof, mem_delta, allocations, score) ⇒ SlowTransaction

Returns a new instance of SlowTransaction.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/scout_apm/slow_transaction.rb', line 19

def initialize(uri, metric_name, total_call_time, metrics, allocation_metrics, context, time, raw_stackprof, mem_delta, allocations, score)
  @uri = uri
  @metric_name = metric_name
  @total_call_time = total_call_time
  @metrics = metrics
  @allocation_metrics = allocation_metrics
  @context = context
  @time = time || Time.now
  @prof = []
  @mem_delta = mem_delta
  @allocations = allocations
  @seconds_since_startup = (Time.now - ScoutApm::Agent.instance.process_start_time)
  @hostname = ScoutApm::Environment.instance.hostname
  @score = score
  ScoutApm::Agent.instance.logger.debug { "Slow Request [#{uri}] - Call Time: #{total_call_time} Mem Delta: #{mem_delta} Score: #{score}"}
end

Instance Attribute Details

#allocation_metricsObject (readonly)

Returns the value of attribute allocation_metrics.



8
9
10
# File 'lib/scout_apm/slow_transaction.rb', line 8

def allocation_metrics
  @allocation_metrics
end

#allocationsObject (readonly)

Returns the value of attribute allocations.



15
16
17
# File 'lib/scout_apm/slow_transaction.rb', line 15

def allocations
  @allocations
end

#contextObject (readonly)

Returns the value of attribute context.



11
12
13
# File 'lib/scout_apm/slow_transaction.rb', line 11

def context
  @context
end

#hostnameObject

hack - we need to reset these server side.



16
17
18
# File 'lib/scout_apm/slow_transaction.rb', line 16

def hostname
  @hostname
end

#mem_deltaObject (readonly)

Returns the value of attribute mem_delta.



14
15
16
# File 'lib/scout_apm/slow_transaction.rb', line 14

def mem_delta
  @mem_delta
end

#metaObject (readonly)

Returns the value of attribute meta.



9
10
11
# File 'lib/scout_apm/slow_transaction.rb', line 9

def meta
  @meta
end

#metric_nameObject (readonly)

Returns the value of attribute metric_name.



5
6
7
# File 'lib/scout_apm/slow_transaction.rb', line 5

def metric_name
  @metric_name
end

#metricsObject (readonly)

Returns the value of attribute metrics.



7
8
9
# File 'lib/scout_apm/slow_transaction.rb', line 7

def metrics
  @metrics
end

#profObject (readonly)

Returns the value of attribute prof.



13
14
15
# File 'lib/scout_apm/slow_transaction.rb', line 13

def prof
  @prof
end

#seconds_since_startupObject

hack - we need to reset these server side.



17
18
19
# File 'lib/scout_apm/slow_transaction.rb', line 17

def seconds_since_startup
  @seconds_since_startup
end

#timeObject (readonly)

Returns the value of attribute time.



12
13
14
# File 'lib/scout_apm/slow_transaction.rb', line 12

def time
  @time
end

#total_call_timeObject (readonly)

Returns the value of attribute total_call_time.



6
7
8
# File 'lib/scout_apm/slow_transaction.rb', line 6

def total_call_time
  @total_call_time
end

#uriObject (readonly)

Returns the value of attribute uri.



10
11
12
# File 'lib/scout_apm/slow_transaction.rb', line 10

def uri
  @uri
end

Instance Method Details

#as_jsonObject



46
47
48
49
# File 'lib/scout_apm/slow_transaction.rb', line 46

def as_json
  json_attributes = [:key, :time, :total_call_time, :uri, [:context, :context_hash], :score, :prof, :mem_delta, :allocations, :seconds_since_startup, :hostname]
  ScoutApm::AttributeArranger.call(self, json_attributes)
end

#callObject

Scorable interface

Needed so we can merge ScoredItemSet instances



59
60
61
# File 'lib/scout_apm/slow_transaction.rb', line 59

def call
  self
end

#clear_metrics!Object

Used to remove metrics when the payload will be too large.



37
38
39
40
# File 'lib/scout_apm/slow_transaction.rb', line 37

def clear_metrics!
  @metrics = nil
  self
end

#context_hashObject



51
52
53
# File 'lib/scout_apm/slow_transaction.rb', line 51

def context_hash
  context.to_hash
end

#has_metrics?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/scout_apm/slow_transaction.rb', line 42

def has_metrics?
  metrics and metrics.any?
end

#nameObject



63
64
65
# File 'lib/scout_apm/slow_transaction.rb', line 63

def name
  metric_name
end

#scoreObject



67
68
69
# File 'lib/scout_apm/slow_transaction.rb', line 67

def score
  @score
end