Class: Magick::PerformanceMetrics::Metric

Inherits:
Object
  • Object
show all
Defined in:
lib/magick/performance_metrics.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(feature_name, operation, duration, success: true) ⇒ Metric

Returns a new instance of Metric.



10
11
12
13
14
15
16
# File 'lib/magick/performance_metrics.rb', line 10

def initialize(feature_name, operation, duration, success: true)
  @feature_name = feature_name.to_s
  @operation = operation.to_s
  @duration = duration
  @timestamp = Time.now
  @success = success
end

Instance Attribute Details

#durationObject (readonly)

Returns the value of attribute duration.



8
9
10
# File 'lib/magick/performance_metrics.rb', line 8

def duration
  @duration
end

#feature_nameObject (readonly)

Returns the value of attribute feature_name.



8
9
10
# File 'lib/magick/performance_metrics.rb', line 8

def feature_name
  @feature_name
end

#operationObject (readonly)

Returns the value of attribute operation.



8
9
10
# File 'lib/magick/performance_metrics.rb', line 8

def operation
  @operation
end

#successObject (readonly)

Returns the value of attribute success.



8
9
10
# File 'lib/magick/performance_metrics.rb', line 8

def success
  @success
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



8
9
10
# File 'lib/magick/performance_metrics.rb', line 8

def timestamp
  @timestamp
end

Instance Method Details

#to_hObject



18
19
20
21
22
23
24
25
26
# File 'lib/magick/performance_metrics.rb', line 18

def to_h
  {
    feature_name: feature_name,
    operation: operation,
    duration: duration,
    timestamp: timestamp.iso8601,
    success: success
  }
end