Class: OpenCensus::Stats::ViewData

Inherits:
Object
  • Object
show all
Defined in:
lib/opencensus/stats/view_data.rb

Overview

ViewData is a container to store stats.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataHash<Array<String>>, AggregationData (readonly)

against view columns.

Returns:



19
20
21
# File 'lib/opencensus/stats/view_data.rb', line 19

def data
  @data
end

#end_timeTime? (readonly)

Returns:

  • (Time, nil)


15
16
17
# File 'lib/opencensus/stats/view_data.rb', line 15

def end_time
  @end_time
end

#start_timeTime? (readonly)

Returns:

  • (Time, nil)


12
13
14
# File 'lib/opencensus/stats/view_data.rb', line 12

def start_time
  @start_time
end

#viewView (readonly)

Returns:



9
10
11
# File 'lib/opencensus/stats/view_data.rb', line 9

def view
  @view
end

Instance Method Details

#clearObject

Clear recorded ata



63
64
65
# File 'lib/opencensus/stats/view_data.rb', line 63

def clear
  data.clear
end

#record(measurement, attachments: nil) ⇒ Object

Record a measurement.

Parameters:

  • measurement (Measurement)
  • attachments (Hash<String,String>) (defaults to: nil)


48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/opencensus/stats/view_data.rb', line 48

def record measurement, attachments: nil
  tag_values = @view.columns.map { |column| measurement.tags[column] }

  unless @data.key? tag_values
    @data[tag_values] = @view.aggregation.create_aggregation_data
  end

  @data[tag_values].add(
    measurement.value,
    measurement.time,
    attachments: attachments
  )
end

#startObject

Set start time.



35
36
37
# File 'lib/opencensus/stats/view_data.rb', line 35

def start
  @start_time = Time.now.utc
end

#stopObject

Set stop time.



40
41
42
# File 'lib/opencensus/stats/view_data.rb', line 40

def stop
  @end_time = Time.now.utc
end