diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2015-12-29 13:40:42 +0100 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2015-12-29 14:53:45 +0100 |
commit | 620e7bb3d60c3685b494b26e256b793a47621da4 (patch) | |
tree | 68291922508c3ea49ffa16f0f8c3bd92d2489ae3 /app/workers | |
parent | 03478e6d5b98a723fbb349dac2c8495f75909a08 (diff) | |
download | gitlab-ce-620e7bb3d60c3685b494b26e256b793a47621da4.tar.gz |
Write to InfluxDB directly via UDP
This removes the need for Sidekiq and any overhead/problems introduced
by TCP. There are a few things to take into account:
1. When writing data to InfluxDB you may still get an error if the
server becomes unavailable during the write. Because of this we're
catching all exceptions and just ignore them (for now).
2. Writing via UDP apparently requires the timestamp to be in
nanoseconds. Without this data either isn't written properly.
3. Due to the restrictions on UDP buffer sizes we're writing metrics one
by one, instead of writing all of them at once.
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/metrics_worker.rb | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/app/workers/metrics_worker.rb b/app/workers/metrics_worker.rb deleted file mode 100644 index b15dc819c5c..00000000000 --- a/app/workers/metrics_worker.rb +++ /dev/null @@ -1,33 +0,0 @@ -class MetricsWorker - include Sidekiq::Worker - - sidekiq_options queue: :metrics - - def perform(metrics) - prepared = prepare_metrics(metrics) - - Gitlab::Metrics.pool.with do |connection| - connection.write_points(prepared) - end - end - - def prepare_metrics(metrics) - metrics.map do |hash| - new_hash = hash.symbolize_keys - - new_hash[:tags].each do |key, value| - if value.blank? - new_hash[:tags].delete(key) - else - new_hash[:tags][key] = escape_value(value) - end - end - - new_hash - end - end - - def escape_value(value) - value.to_s.gsub('=', '\\=') - end -end |