-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/DEX-2163/autoload-yabeda-server' into 'master'
[DEX-2163] feat: autostart yabeda server Closes DEX-2163 See merge request nstmrt/rubygems/outbox!90
- Loading branch information
Showing
8 changed files
with
77 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# frozen_string_literal: true | ||
|
||
module Sbmt | ||
module Outbox | ||
module Probes | ||
class Metrics | ||
DEFAULT_YABEDA_PORT = 9090 | ||
DEFAULT_YABEDA_PATH = "/metrics" | ||
class << self | ||
def run_metrics | ||
return unless autostart_yabeda_server? | ||
|
||
if defined?(Yabeda) | ||
$stdout.puts "Starting metrics http-server..." | ||
|
||
start_webrick( | ||
Yabeda::Prometheus::Mmap::Exporter::NOT_FOUND_HANDLER, | ||
middlewares: {::Yabeda::Prometheus::Exporter => {path: DEFAULT_YABEDA_PATH}}, | ||
port: yabeda_port | ||
) | ||
end | ||
end | ||
|
||
private | ||
|
||
def yabeda_port | ||
Sbmt::Outbox.yaml_config.dig(:metrics, :port) || DEFAULT_YABEDA_PORT | ||
end | ||
|
||
def start_webrick(app, middlewares:, port:) | ||
Thread.new do | ||
::Rack::Handler::WEBrick.run( | ||
::Rack::Builder.new do | ||
middlewares.each do |middleware, options| | ||
use middleware, **options | ||
end | ||
run app | ||
end, | ||
Host: "0.0.0.0", | ||
Port: port | ||
) | ||
end | ||
end | ||
|
||
def autostart_yabeda_server? | ||
Sbmt::Outbox.yaml_config.dig(:metrics, :enabled) || false | ||
end | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,6 @@ | |
|
||
module Sbmt | ||
module Outbox | ||
VERSION = "6.3.1" | ||
VERSION = "6.4.0" | ||
end | ||
end |