Module: ScoutApm::Instruments::ElasticsearchTransportClientInstrumentationPrepend

Defined in:
lib/scout_apm/instruments/elasticsearch.rb

Instance Method Summary collapse

Instance Method Details

#_sanitize_name(name) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/scout_apm/instruments/elasticsearch.rb', line 96

def _sanitize_name(name)
  name = name.split("/").last.gsub(/^_/, '')
  allowed_names = ["bench",
                  "bulk",
                  "count",
                  "exists",
                  "explain",
                  "field_stats",
                  "health",
                  "mget",
                  "mlt",
                  "mpercolate",
                  "msearch",
                  "mtermvectors",
                  "percolate",
                  "query",
                  "scroll",
                  "search_shards",
                  "source",
                  "suggest",
                  "template",
                  "termvectors",
                  "update",
                  "search", ]

  if allowed_names.include?(name)
    name
  else
    "Unknown"
  end
rescue
  "Unknown"
end

#perform_request(*args, &block) ⇒ Object



88
89
90
91
92
93
94
# File 'lib/scout_apm/instruments/elasticsearch.rb', line 88

def perform_request(*args, &block)
  name = _sanitize_name(args[1])

  self.class.instrument("Elasticsearch", name, :ignore_children => true) do
    super(*args, &block)
  end
end