module TingYun::Instrumentation::Support::MetricTranslator
Constants
- MONGODB
Public Class Methods
collection_in_selector?(payload)
click to toggle source
# File lib/ting_yun/instrumentation/support/metric_translator.rb, line 40 def self.collection_in_selector?(payload) payload[:collection] == '$cmd' end
collection_name_from_group_selector(payload)
click to toggle source
# File lib/ting_yun/instrumentation/support/metric_translator.rb, line 74 def self.collection_name_from_group_selector(payload) payload[:selector]["group"]["ns"] end
collection_name_from_index(payload)
click to toggle source
# File lib/ting_yun/instrumentation/support/metric_translator.rb, line 56 def self.collection_name_from_index(payload) if payload[:documents] if payload[:documents].is_a?(Array) # mongo gem versions pre 1.10.0 document = payload[:documents].first else # mongo gem versions 1.10.0 and later document = payload[:documents] end if document && document[:ns] return document[:ns].split('.').last end end 'system.indexes' end
collection_name_from_rename_selector(payload)
click to toggle source
# File lib/ting_yun/instrumentation/support/metric_translator.rb, line 78 def self.collection_name_from_rename_selector(payload) parts = payload[:selector][:renameCollection].split('.') parts.shift parts.join('.') end
create_index?(name, payload)
click to toggle source
# File lib/ting_yun/instrumentation/support/metric_translator.rb, line 44 def self.create_index?(name, payload) name == :insert && payload[:collection] == "system.indexes" end
group?(name, payload)
click to toggle source
# File lib/ting_yun/instrumentation/support/metric_translator.rb, line 48 def self.group?(name, payload) name == :group end
metrics_for(name, payload, host_port)
click to toggle source
# File lib/ting_yun/instrumentation/support/metric_translator.rb, line 13 def self.metrics_for(name, payload, host_port) payload ||= {} return nil if collection_in_selector?(payload) collection = payload[:collection] if create_index?(name, payload) collection = self.collection_name_from_index(payload) elsif group?(name, payload) collection = collection_name_from_group_selector(payload) elsif rename_collection?(name, payload) collection = collection_name_from_rename_selector(payload) end TingYun::Agent::Datastore::MetricHelper.metrics_for(MONGODB, TingYun::Agent::Datastore::Mongo.transform_operation(name), host_port[0], host_port[1], payload[:database], collection) rescue => e TingYun::Agent.logger.debug("Failure during Mongo metric generation", e) nil end
rename_collection?(name, payload)
click to toggle source
# File lib/ting_yun/instrumentation/support/metric_translator.rb, line 52 def self.rename_collection?(name, payload) name == :renameCollection end