Skip to content

Commit

Permalink
Update the filename prefix to avoid the possibility of loading files …
Browse files Browse the repository at this point in the history
…that used the previous format.

Signed-off-by: Stefan Sundin <stefan@stefansundin.com>
  • Loading branch information
stefansundin committed Dec 24, 2019
1 parent 207654d commit 1a7dee8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/prometheus/client/data_stores/direct_file_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ def validate_metric_settings(metric_settings)
end

class MetricStore
# Update the filename prefix when the file format changes
FILENAME_PREFIX = "metricv2"

attr_reader :metric_name, :store_settings

def initialize(metric_name:, store_settings:, metric_settings:)
Expand Down Expand Up @@ -168,12 +171,12 @@ def internal_store

# Filename for this metric's PStore (one per process)
def filemap_filename
filename = "metric_#{ metric_name }___#{ process_id }.bin"
filename = "#{ FILENAME_PREFIX }_#{ metric_name }___#{ process_id }.bin"
File.join(@store_settings[:dir], filename)
end

def stores_for_metric
Dir.glob(File.join(@store_settings[:dir], "metric_#{ metric_name }___*"))
Dir.glob(File.join(@store_settings[:dir], "#{ FILENAME_PREFIX }_#{ metric_name }___*"))
end

def process_id
Expand Down

0 comments on commit 1a7dee8

Please sign in to comment.