<commit_before>ActiveSupport::Notifications.subscribe /process_action.action_controller/ do |*args|
  event       = ActiveSupport::Notifications::Event.new(*args)
  payload     = event.payload
  controller  = payload[:controller]
  action      = payload[:action]
  format      = payload[:format] || 'all'
  format      = "all" if format == "*/*"
  http_status = payload[:status]

  total_duration = event.duration.to_i

  meter_tags = {
    controller:  controller,
    format:      format,
    method:      payload[:method],
    http_status: http_status
  }

  meter_data = {
    action:      action,
    path:        payload[:path],
    params:      payload[:params].to_query,
    duration:    total_duration
  }

  instrumented_layers = {
    db_runtime:            :db_duration,
    view_runtime:          :view_duration,
    elasticsearch_runtime: :elasticsearch_duration
  }

  instrumented_layers.each do |layer, tag_value|
    next unless payload.has_key? layer
    duration = payload[layer].to_i
    meter_data[tag_value] = duration
    Meter.timing("request.layer_duration", duration, tags: meter_tags.merge(layer: tag_value))
  end

  Meter.timing "request.total_duration", total_duration, tags: meter_tags
  Meter.track  "requests", tags: meter_tags, data: meter_data
end<commit_msg>Don't track metrics for performance, use APM instead<commit_after>ActiveSupport::Notifications.subscribe /process_action.action_controller/ do |*args|
  event       = ActiveSupport::Notifications::Event.new(*args)
  payload     = event.payload
  controller  = payload[:controller]
  action      = payload[:action]
  format      = payload[:format] || 'all'
  format      = "all" if format == "*/*"
  http_status = payload[:status]

  total_duration = event.duration.to_i

  meter_tags = {
    controller:  controller,
    format:      format,
    method:      payload[:method],
    http_status: http_status
  }

  meter_data = {
    action:      action,
    path:        payload[:path],
    params:      payload[:params].to_query,
    duration:    total_duration
  }

  Meter.log 'requests', tags: meter_tags, data: meter_data
end
{'fraction_non_alphanumeric': 0.10922787193973635, 'fraction_numerical': 0.0, 'mean_word_length': 3.25, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6604632', 'n_tokens_mistral': 637, 'n_tokens_neox': 632, 'n_words': 132}