Module: OneApm::Agent::Datastore::MetricHelper
- Defined in:
- lib/one_apm/agent/datastore/metric_helper.rb
Constant Summary collapse
- OA_ROLLUP_METRIC =
"Datastore/all".freeze
- OA_WEB_ROLLUP_METRIC =
"Datastore/allWeb".freeze
- OA_OTHER_ROLLUP_METRIC =
"Datastore/allOther".freeze
- OA_DEFAULT_PRODUCT_NAME =
"ActiveRecord".freeze
- OA_OTHER =
"Other".freeze
- OA_ALL =
"all".freeze
- OA_ALL_WEB =
"allWeb".freeze
- OA_ALL_OTHER =
"allOther".freeze
Class Method Summary collapse
- .all_suffix ⇒ Object
- .metrics_for(product, operation, collection = nil) ⇒ Object
- .metrics_from_sql(product, sql) ⇒ Object
- .operation_metric_for(product, operation) ⇒ Object
-
.overridden_operation_and_collection ⇒ Object
Allow Transaction#with_database_metric_name to override our collection and operation.
- .product_rollup(product) ⇒ Object
- .product_suffixed_rollup(product, suffix) ⇒ Object
- .statement_metric_for(product, collection, operation) ⇒ Object
- .suffixed_rollup(suffix) ⇒ Object
Class Method Details
.all_suffix ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/one_apm/agent/datastore/metric_helper.rb', line 37 def self.all_suffix if OneApm::Transaction.recording_web_transaction? OA_ALL_WEB else OA_ALL_OTHER end end |
.metrics_for(product, operation, collection = nil) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/one_apm/agent/datastore/metric_helper.rb', line 45 def self.metrics_for(product, operation, collection = nil) if overrides = overridden_operation_and_collection operation, collection = overrides 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), OA_ROLLUP_METRIC ] metrics.unshift statement_metric_for(product, collection, operation) if collection metrics end |
.metrics_from_sql(product, sql) ⇒ Object
67 68 69 70 |
# File 'lib/one_apm/agent/datastore/metric_helper.rb', line 67 def self.metrics_from_sql(product, sql) operation = OneApm::Agent::Database.parse_operation_from_query(sql) || OA_OTHER metrics_for(product, operation) end |
.operation_metric_for(product, operation) ⇒ Object
21 22 23 |
# File 'lib/one_apm/agent/datastore/metric_helper.rb', line 21 def self.operation_metric_for(product, operation) "Datastore/operation/#{product}/#{operation}" end |
.overridden_operation_and_collection ⇒ Object
Allow Transaction#with_database_metric_name to override our collection and operation
74 75 76 77 78 |
# File 'lib/one_apm/agent/datastore/metric_helper.rb', line 74 def self.overridden_operation_and_collection state = OneApm::TransactionState.tl_get txn = state.current_transaction txn ? txn.instrumentation_state[:datastore_override] : nil end |
.product_rollup(product) ⇒ Object
29 30 31 |
# File 'lib/one_apm/agent/datastore/metric_helper.rb', line 29 def self.product_rollup(product) "Datastore/#{product}/all" end |
.product_suffixed_rollup(product, suffix) ⇒ Object
25 26 27 |
# File 'lib/one_apm/agent/datastore/metric_helper.rb', line 25 def self.product_suffixed_rollup(product, suffix) "Datastore/#{product}/#{suffix}" end |
.statement_metric_for(product, collection, operation) ⇒ Object
17 18 19 |
# File 'lib/one_apm/agent/datastore/metric_helper.rb', line 17 def self.statement_metric_for(product, collection, operation) "Datastore/statement/#{product}/#{collection}/#{operation}" end |
.suffixed_rollup(suffix) ⇒ Object
33 34 35 |
# File 'lib/one_apm/agent/datastore/metric_helper.rb', line 33 def self.suffixed_rollup(suffix) "Datastore/#{suffix}" end |