Class: DetailedTrace

Inherits:
Object
  • Object
show all
Defined in:
lib/scout_apm/detailed_trace.rb

Overview

{ “version”: 1, “identity”: {

"transaction_id": "req-....",
"revision": "abcdef",
"start_instant": "01-01-01T00:00:00.0000Z",
"stop_instant": "01-01-01T00:00:01.0000Z",
"type": "Web",
"naming": {
  "path": "/users",
  "code": "UsersController#index",
},
"score": {
  "total": 10.5,
  "percentile": 4.5,
  "age": 2.0,
  "memory_delta": 3,
  "allocations": 1
}

},

“tags”:

"allocations": 1000

,

“spans”: [

...

]

Constant Summary collapse

VERSION =
1

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transaction_id, revision, host, start_instant, stop_instant, type, path, code, spans, tags) ⇒ DetailedTrace

Returns a new instance of DetailedTrace.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/scout_apm/detailed_trace.rb', line 56

def initialize(transaction_id, revision, host, start_instant, stop_instant, type, path, code, spans, tags)
  @spans = spans
  @tags = DetailedTraceTags(tags)

  @transaction_id = transaction_id
  @revision = revision
  @host = host
  @start_instant = start_instant
  @stop_instant = stop_instant
  @type = type

  @path = path
  @code = code

  @total_score = 0
  @percentile_score = 0
  @age_score = 0
  @memory_delta_score = 0
  @memory_allocations_score = 0

end

Instance Attribute Details

#age_scoreObject (readonly)

Returns the value of attribute age_score.



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

def age_score
  @age_score
end

#codeObject (readonly)

UsersController#show or similar



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

def code
  @code
end

#durationObject (readonly)

Returns the value of attribute duration.



41
42
43
# File 'lib/scout_apm/detailed_trace.rb', line 41

def duration
  @duration
end

#hostObject (readonly)

Returns the value of attribute host.



43
44
45
# File 'lib/scout_apm/detailed_trace.rb', line 43

def host
  @host
end

#memory_allocations_scoreObject (readonly)

Returns the value of attribute memory_allocations_score.



52
53
54
# File 'lib/scout_apm/detailed_trace.rb', line 52

def memory_allocations_score
  @memory_allocations_score
end

#memory_delta_scoreObject (readonly)

Returns the value of attribute memory_delta_score.



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

def memory_delta_score
  @memory_delta_score
end

#pathObject (readonly)

/users/1



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

def path
  @path
end

#percentile_scoreObject (readonly)

Returns the value of attribute percentile_score.



49
50
51
# File 'lib/scout_apm/detailed_trace.rb', line 49

def percentile_score
  @percentile_score
end

#revisionObject (readonly)

Returns the value of attribute revision.



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

def revision
  @revision
end

#spansObject (readonly)

Returns the value of attribute spans.



34
35
36
# File 'lib/scout_apm/detailed_trace.rb', line 34

def spans
  @spans
end

#start_instantObject (readonly)

Returns the value of attribute start_instant.



39
40
41
# File 'lib/scout_apm/detailed_trace.rb', line 39

def start_instant
  @start_instant
end

#stop_instantObject (readonly)

Returns the value of attribute stop_instant.



40
41
42
# File 'lib/scout_apm/detailed_trace.rb', line 40

def stop_instant
  @stop_instant
end

#tagsObject (readonly)

Returns the value of attribute tags.



35
36
37
# File 'lib/scout_apm/detailed_trace.rb', line 35

def tags
  @tags
end

#total_scoreObject (readonly)

Returns the value of attribute total_score.



48
49
50
# File 'lib/scout_apm/detailed_trace.rb', line 48

def total_score
  @total_score
end

#transaction_idObject (readonly)

Returns the value of attribute transaction_id.



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

def transaction_id
  @transaction_id
end

#typeObject (readonly)

“Web” or “Job”



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

def type
  @type
end

Instance Method Details

#as_jsonObject



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/scout_apm/detailed_trace.rb', line 78

def as_json(*)
  {
    :version => VERSION,
    :identity => {
      :transaction_id => transaction_id,
      :revision => revision,
      :host => host,
      :start_instant => start_instant.iso8601(6),
      :stop_instant => stop_instant.iso8601(6),
      :type => type,
      :naming => {
        :path => path,
        :code => code,
      },
      :score => {
        :total => total_score,
        :percentile => percentile_score,
        :age => age_score,
        :memory_delta => memory_delta_score,
        :allocations => memory_allocations_score,
      }
    },
    :tags => tags.as_json,
    :spans => spans.map{|span| span.as_json},
  }
end

#callObject

Scorable interface

Needed so we can merge ScoredItemSet instances



109
110
111
# File 'lib/scout_apm/detailed_trace.rb', line 109

def call
  self
end

#nameObject



113
114
115
# File 'lib/scout_apm/detailed_trace.rb', line 113

def name
  code
end

#scoreObject



117
118
119
# File 'lib/scout_apm/detailed_trace.rb', line 117

def score
  @total_score
end