aboutsummaryrefslogtreecommitdiff
path: root/lib/longboat
diff options
context:
space:
mode:
Diffstat (limited to 'lib/longboat')
-rw-r--r--lib/longboat/collector.rb4
-rw-r--r--lib/longboat/config.rb9
-rw-r--r--lib/longboat/jobs.rb2
3 files changed, 10 insertions, 5 deletions
diff --git a/lib/longboat/collector.rb b/lib/longboat/collector.rb
index c812b05..d1a5d93 100644
--- a/lib/longboat/collector.rb
+++ b/lib/longboat/collector.rb
@@ -1,10 +1,12 @@
module Longboat
class Collector
- def initialize
+ def initialize(config)
@metrics = {}
+ @config = config
end
def report!(name, value, help: nil, type: nil, labels: {}, timestamp: Time.now)
+ name = "#{@config[:metric_prefix]}#{name}"
@metrics[name] ||= {help: help, type: type}
@metrics[name][labels] = {value: value, timestamp: timestamp}
end
diff --git a/lib/longboat/config.rb b/lib/longboat/config.rb
index 874a5be..8f4907c 100644
--- a/lib/longboat/config.rb
+++ b/lib/longboat/config.rb
@@ -5,11 +5,14 @@ module Longboat
def self.parse!
Optimist::options do
# Collection interval
- opt :collect_every, "Collection interval", type: Integer, default: 60
+ opt :collect_every, "Collection interval", type: Integer, default: 60
+
+ # Job data
+ opt :metric_prefix, "Prefix for metric names", type: String, default: "longboat_"
# Sinatra server
- opt :server_bind, "Server listening address", type: String, default: "127.0.0.1:8564"
- opt :server_path, "Path to metrics", type: String, default: "/metrics"
+ opt :server_bind, "Server listening address", type: String, default: "127.0.0.1:8564"
+ opt :server_path, "Path to metrics", type: String, default: "/metrics"
end
end
end
diff --git a/lib/longboat/jobs.rb b/lib/longboat/jobs.rb
index 86d3c64..f0ada5a 100644
--- a/lib/longboat/jobs.rb
+++ b/lib/longboat/jobs.rb
@@ -41,7 +41,7 @@ module Longboat
private
def job_config
- @config.slice(:collect_every)
+ @config.slice(:collect_every, :metric_prefix)
end
end
end