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(agent_context, uri, metric_name, total_call_time, metrics, allocation_metrics, context, time, raw_stackprof, mem_delta, allocations, score, truncated_metrics, span_trace) ⇒ SlowTransaction

Returns a new instance of SlowTransaction.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/scout_apm/slow_transaction.rb', line 23

def initialize(agent_context, uri, metric_name, total_call_time, metrics, allocation_metrics, context, time, raw_stackprof, mem_delta, allocations, score, truncated_metrics, span_trace)
  @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 - agent_context.process_start_time)
  @hostname = agent_context.environment.hostname
  @score = score
  @git_sha = agent_context.environment.git_revision.sha
  @truncated_metrics = truncated_metrics
  @span_trace = span_trace

  agent_context.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

#git_shaObject

hack - we need to reset these server side.



19
20
21
# File 'lib/scout_apm/slow_transaction.rb', line 19

def git_sha
  @git_sha
end

#hostnameObject

hack - we need to reset these server side.



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

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.



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

def seconds_since_startup
  @seconds_since_startup
end

#span_traceObject (readonly)

Returns the value of attribute span_trace.



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

def span_trace
  @span_trace
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

#truncated_metricsObject (readonly)

True/False that says if we had to truncate the metrics of this trace



21
22
23
# File 'lib/scout_apm/slow_transaction.rb', line 21

def truncated_metrics
  @truncated_metrics
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



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/scout_apm/slow_transaction.rb', line 54

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

#callObject

Scorable interface

Needed so we can merge ScoredItemSet instances



79
80
81
# File 'lib/scout_apm/slow_transaction.rb', line 79

def call
  self
end

#clear_metrics!Object

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



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

def clear_metrics!
  @metrics = nil
  self
end

#context_hashObject



71
72
73
# File 'lib/scout_apm/slow_transaction.rb', line 71

def context_hash
  context.to_hash
end

#has_metrics?Boolean

Returns:

  • (Boolean)


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

def has_metrics?
  metrics and metrics.any?
end

#nameObject



83
84
85
# File 'lib/scout_apm/slow_transaction.rb', line 83

def name
  metric_name
end

#scoreObject



87
88
89
# File 'lib/scout_apm/slow_transaction.rb', line 87

def score
  @score
end