Class: Stoplight::Infrastructure::Redis::Storage::Metrics

Inherits:
Object
  • Object
show all
Defined in:
lib/stoplight/infrastructure/redis/storage/metrics.rb

Direct Known Subclasses

UnboundedMetrics, WindowMetrics

Instance Method Summary collapse

Instance Method Details

#deserialize_failure(failure_json) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/stoplight/infrastructure/redis/storage/metrics.rb', line 22

def deserialize_failure(failure_json)
  return if failure_json.nil?

  object = JSON.parse(failure_json)
  error_object = object["error"]

  error_class = error_object["class"]
  error_message = error_object["message"]
  time = Time.at(object["time"])

  Domain::Failure.new(error_class, error_message, time)
end

#serialize_exception(exception, timestamp:) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/stoplight/infrastructure/redis/storage/metrics.rb', line 10

def serialize_exception(exception, timestamp:)
  JSON.generate(
    {
      error: {
        class: exception.class.name,
        message: exception.message
      },
      time: timestamp
    }
  )
end