Module: LogMetrics

Extended by:
ActiveSupport::Concern
Included in:
Form1010cg::PoaUploader
Defined in:
app/uploaders/log_metrics.rb

Constant Summary collapse

KEY_PREFIX =
'api.upload.'

Instance Method Summary collapse

Instance Method Details

#log_metrics(file) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/uploaders/log_metrics.rb', line 12

def log_metrics(file)
  class_name = self.class.to_s.gsub('::', '_').underscore
  class_prefix = "#{KEY_PREFIX}#{class_name}"

  args = [
    "#{class_prefix}.size",
    file.size
  ]

  kw_args = {}

  file.content_type.tap do |content_type|
    next if content_type.blank?

    kw_args[:tags] = ["content_type:#{content_type.split('/')[1]}"]
  end

  StatsD.measure(*args, **kw_args)
end