Class: Telltale::Data

Inherits:
Object
  • Object
show all
Defined in:
lib/telltale/data.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(started, finished, payload) ⇒ Data

Returns a new instance of Data.



9
10
11
12
13
# File 'lib/telltale/data.rb', line 9

def initialize(started, finished, payload)
  @started = started
  @finished = finished
  @payload = payload
end

Instance Attribute Details

#finishedObject (readonly)

Returns the value of attribute finished.



3
4
5
# File 'lib/telltale/data.rb', line 3

def finished
  @finished
end

#payloadObject (readonly)

Returns the value of attribute payload.



3
4
5
# File 'lib/telltale/data.rb', line 3

def payload
  @payload
end

#startedObject (readonly)

Returns the value of attribute started.



3
4
5
# File 'lib/telltale/data.rb', line 3

def started
  @started
end

Class Method Details

.compile(started, finished, payload) ⇒ Object



5
6
7
# File 'lib/telltale/data.rb', line 5

def self.compile(started, finished, payload)
  new(started, finished, payload).all
end

Instance Method Details

#allObject



15
16
17
# File 'lib/telltale/data.rb', line 15

def all
  [total_time, request_count]
end

#request_countObject



28
29
30
31
32
33
34
35
# File 'lib/telltale/data.rb', line 28

def request_count
  {
    metric: "#{metric_prefix}.rails.request_count",
    value: 1,
    timestamp: Time.now.to_i,
    tags: tags,
  }
end

#total_timeObject



19
20
21
22
23
24
25
26
# File 'lib/telltale/data.rb', line 19

def total_time
  {
    metric: "#{metric_prefix}.rails.total_time",
    value: ((finished - started) * 1000).ceil,
    timestamp: Time.now.to_i,
    tags: tags,
  }
end