mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-29 06:26:07 +10:00
While it's useful to keep track of the different versions (Ruby, GitLab, etc) doing so for every point wastes disk space and possibly also RAM (which InfluxDB is all to eager to gobble up). If we want to see the performance differences between different GitLab versions simply looking at the performance since the last release date should suffice.
32 lines
964 B
Ruby
32 lines
964 B
Ruby
module Gitlab
|
|
module Metrics
|
|
# Class for storing details of a single metric (label, value, etc).
|
|
class Metric
|
|
attr_reader :series, :values, :tags, :created_at
|
|
|
|
# series - The name of the series (as a String) to store the metric in.
|
|
# values - A Hash containing the values to store.
|
|
# tags - A Hash containing extra tags to add to the metrics.
|
|
def initialize(series, values, tags = {})
|
|
@values = values
|
|
@series = series
|
|
@tags = tags
|
|
@created_at = Time.now.utc
|
|
end
|
|
|
|
# Returns a Hash in a format that can be directly written to InfluxDB.
|
|
def to_hash
|
|
{
|
|
series: @series,
|
|
tags: @tags.merge(
|
|
hostname: Metrics.hostname,
|
|
process_type: Sidekiq.server? ? 'sidekiq' : 'rails'
|
|
),
|
|
values: @values,
|
|
timestamp: @created_at.to_i * 1_000_000_000
|
|
}
|
|
end
|
|
end
|
|
end
|
|
end
|