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.



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

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.



6
7
8
# File 'lib/magick/performance_metrics.rb', line 6

def duration
  @duration
end

#feature_nameObject (readonly)

Returns the value of attribute feature_name.



6
7
8
# File 'lib/magick/performance_metrics.rb', line 6

def feature_name
  @feature_name
end

#operationObject (readonly)

Returns the value of attribute operation.



6
7
8
# File 'lib/magick/performance_metrics.rb', line 6

def operation
  @operation
end

#successObject (readonly)

Returns the value of attribute success.



6
7
8
# File 'lib/magick/performance_metrics.rb', line 6

def success
  @success
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



6
7
8
# File 'lib/magick/performance_metrics.rb', line 6

def timestamp
  @timestamp
end

Instance Method Details

#to_hObject



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

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