Skip to content

Commit 6356a4a

Browse files
authored
Merge pull request #39 from bigcommerce/INFRA-25589-metrics-scrape-content-type
INFRA-25589: fix(metrics) Add version=0.0.4 to Content-Type for Prometheus exposition format 0.0.4 compliance
2 parents a2863f8 + e4f0951 commit 6356a4a

5 files changed

Lines changed: 12 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ Changelog for the bc-prometheus-ruby gem.
22

33
### Pending Release
44

5+
## 0.8.2
6+
7+
- Add `version=0.0.4` to `Content-Type` header for Prometheus exposition format 0.0.4 compliance
8+
59
## 0.8.1
610

711
- Prometheus client respects the enabled setting

lib/bigcommerce/prometheus/servers/puma/controllers/metrics_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def call
3939
@response.write(collected_metrics)
4040
end
4141

42-
set_header('Content-Type', 'text/plain; charset=utf-8')
42+
set_header('Content-Type', 'text/plain; version=0.0.4; charset=utf-8')
4343
@response
4444
end
4545

lib/bigcommerce/prometheus/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
#
1818
module Bigcommerce
1919
module Prometheus
20-
VERSION = '0.8.2.pre'
20+
VERSION = '0.8.2'
2121
end
2222
end

spec/bigcommerce/prometheus/servers/puma/controllers/metrics_controller_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
ruby_collector_sessions_total 19'
5050
end
5151

52+
it 'sets Prometheus text format 0.0.4 content type' do
53+
expect(subject.headers['Content-Type']).to eq('text/plain; version=0.0.4; charset=utf-8')
54+
end
55+
5256
context 'when the metrics fail to parse' do
5357
let(:timeout_exception) { ::Timeout::Error }
5458
before do

spec/bigcommerce/prometheus/servers/puma/rack_app_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
}
4242
end
4343

44-
it 'returns content type of text/plain' do
44+
it 'returns Prometheus text format 0.0.4 content type' do
4545
_status, headers, _body = subject
46-
expect(headers['Content-Type']).to eq('text/plain; charset=utf-8')
46+
expect(headers['Content-Type']).to eq('text/plain; version=0.0.4; charset=utf-8')
4747
end
4848
end
4949

0 commit comments

Comments
 (0)