module Mmtrix::Agent::Datastores::MetricHelper
Constants
- ALL
- ALL_OTHER
- ALL_WEB
- DEFAULT_PRODUCT_NAME
- OTHER
- OTHER_ROLLUP_METRIC
- ROLLUP_METRIC
- WEB_ROLLUP_METRIC
Public Class Methods
all_suffix()
click to toggle source
# File lib/mmtrix/agent/datastores/metric_helper.rb, line 39 def self.all_suffix if Mmtrix::Agent::Transaction.recording_web_transaction? ALL_WEB else ALL_OTHER end end
metrics_for(product, operation, collection = nil, generic_product = nil)
click to toggle source
# File lib/mmtrix/agent/datastores/metric_helper.rb, line 47 def self.metrics_for(product, operation, collection = nil, generic_product = nil) if overrides = overridden_operation_and_collection if should_override?(overrides, product, generic_product) operation = overrides[0] || operation collection = overrides[1] || collection end end suffix = all_suffix # Order of these metrics matters--the first metric in the list will # be treated as the scoped metric in a bunch of different cases. metrics = [ operation_metric_for(product, operation), product_suffixed_rollup(product, suffix), product_rollup(product), suffixed_rollup(suffix), ROLLUP_METRIC ] metrics.unshift statement_metric_for(product, collection, operation) if collection metrics end
metrics_from_sql(product, sql)
click to toggle source
# File lib/mmtrix/agent/datastores/metric_helper.rb, line 72 def self.metrics_from_sql(product, sql) operation = Mmtrix::Agent::Database.parse_operation_from_query(sql) || OTHER metrics_for(product, operation) end
operation_metric_for(product, operation)
click to toggle source
# File lib/mmtrix/agent/datastores/metric_helper.rb, line 23 def self.operation_metric_for(product, operation) "Datastore/operation/#{product}/#{operation}" end
overridden_operation_and_collection()
click to toggle source
Allow Transaction#with_database_metric_name
to override our collection and operation
# File lib/mmtrix/agent/datastores/metric_helper.rb, line 79 def self.overridden_operation_and_collection #THREAD_LOCAL_ACCESS state = Mmtrix::Agent::TransactionState.tl_get txn = state.current_transaction txn ? txn.instrumentation_state[:datastore_override] : nil end
product_rollup(product)
click to toggle source
# File lib/mmtrix/agent/datastores/metric_helper.rb, line 31 def self.product_rollup(product) "Datastore/#{product}/all" end
product_suffixed_rollup(product, suffix)
click to toggle source
# File lib/mmtrix/agent/datastores/metric_helper.rb, line 27 def self.product_suffixed_rollup(product, suffix) "Datastore/#{product}/#{suffix}" end
should_override?(overrides, product, generic_product)
click to toggle source
If the override declared a product affiliation, abide by that ActiveRecord has database-specific product names, so we recognize it by the generic_product it passes.
# File lib/mmtrix/agent/datastores/metric_helper.rb, line 88 def self.should_override?(overrides, product, generic_product) override_product = overrides[2] override_product.nil? || override_product == product || override_product == generic_product end
statement_metric_for(product, collection, operation)
click to toggle source
# File lib/mmtrix/agent/datastores/metric_helper.rb, line 19 def self.statement_metric_for(product, collection, operation) "Datastore/statement/#{product}/#{collection}/#{operation}" end
suffixed_rollup(suffix)
click to toggle source
# File lib/mmtrix/agent/datastores/metric_helper.rb, line 35 def self.suffixed_rollup(suffix) "Datastore/#{suffix}" end