-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
146 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# encoding: UTF-8 | ||
|
||
require 'rack/test' | ||
require 'rack' | ||
require 'prometheus/middleware/collector' | ||
require 'prometheus/middleware/exporter' | ||
|
||
require_relative "../support/api" | ||
|
||
describe API do | ||
include Rack::Test::Methods | ||
|
||
let(:app) { described_class } | ||
|
||
context 'GET /metrics' do | ||
it 'fails on the second request' do | ||
get '/metrics' | ||
expect { last_response }.not_to raise_error | ||
expect { get '/metrics' }.not_to raise_error | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# encoding: UTF-8 | ||
|
||
require 'rack/test' | ||
require 'rack' | ||
require 'prometheus/middleware/collector' | ||
require 'prometheus/middleware/exporter' | ||
require "concurrent" | ||
|
||
require_relative "../support/api" | ||
|
||
describe API do | ||
include Rack::Test::Methods | ||
|
||
let(:app) { described_class } | ||
|
||
context 'GET /metrics' do | ||
it "fails when it's multi threaded request" do | ||
latch = Concurrent::CountDownLatch.new(1) | ||
|
||
t1 = Thread.new do | ||
latch.wait | ||
res = get '/metrics' | ||
|
||
expect(res.body).not_to be_empty | ||
end | ||
|
||
t2 = Thread.new do | ||
latch.wait | ||
res = get '/metrics' | ||
|
||
expect(res.body).not_to be_empty | ||
end | ||
|
||
t3 = Thread.new do | ||
latch.wait | ||
res = get '/metrics' | ||
expect(res.body).not_to be_empty | ||
end | ||
|
||
t4 = Thread.new do | ||
latch.wait | ||
res = get '/metrics' | ||
|
||
expect(res.body).not_to be_empty | ||
end | ||
|
||
latch.count_down | ||
|
||
[t1, t2, t3, t4].each(&:join) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require 'rack' | ||
|
||
API = Rack::Builder.new do | ||
use Rack::Deflater | ||
use Prometheus::Middleware::Collector | ||
use Prometheus::Middleware::Exporter | ||
|
||
map "/" do | ||
run ->(_) { [200, {'Content-Type' => 'text/html'}, ['OK']] } | ||
end | ||
end | ||
|
||
|