Skip to content
This repository was archived by the owner on Sep 29, 2021. It is now read-only.

Commit e082bc7

Browse files
committed
Set promethues to return json parsed response
1 parent d4a32a4 commit e082bc7

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ def ruby_version?(constraint)
77
end
88

99
gem 'faraday'
10+
gem 'faraday_middleware'
1011

1112
group :test do
1213
gem 'coveralls'

lib/prometheus/alert_buffer_client/client.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
require 'json'
44
require 'faraday'
5+
require 'faraday_middleware'
56

67
module Prometheus
78
# Alert Client is a ruby implementation for a Prometheus-alert-buffer client.
@@ -39,7 +40,10 @@ def initialize(options = {})
3940

4041
@client = Faraday.new(
4142
faraday_options(options),
42-
)
43+
) do |conn|
44+
conn.response(:json)
45+
conn.adapter(Faraday.default_adapter)
46+
end
4347
end
4448

4549

@@ -57,8 +61,8 @@ def get(options = {})
5761
req.params['fromIndex'] = options[:from_index]
5862
end
5963

60-
JSON.parse(response.body)
61-
rescue
64+
response.body
65+
rescue
6266
raise RequestError, 'Bad response from server'
6367
end
6468

0 commit comments

Comments
 (0)