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_all(product) ⇒ Object
Datastore/operation/NoSqlType.
-
.operation_metric_for(product, operation) ⇒ Object
Datastore/operation/NoSqlType:10.128.6.240:27017/update.
-
.operation_product_rollup(product) ⇒ Object
Datastore/operation/NoSqlType:10.128.6.240:27017/all.
-
.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_action_metric_for(product, operation) ⇒ Object
Datastore/statement/NoSqlType:10.128.6.240:27017/insert.
-
.statement_all(product) ⇒ Object
Datastore/statement/NoSqlType.
-
.statement_all_metric_for(product) ⇒ Object
Datastore/statement/NoSqlType:10.128.6.240:27017/all.
-
.statement_metric_for(product, collection, operation) ⇒ Object
Datastore/statement/NoSqlType:10.128.6.240:27017/book/insert.
- .suffixed_rollup(suffix) ⇒ Object
Class Method Details
.all_suffix ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/one_apm/agent/datastore/metric_helper.rb', line 64 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
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/one_apm/agent/datastore/metric_helper.rb', line 72 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 = Array.new unless collection metrics.push( operation_metric_for(product, operation), operation_product_rollup(product), operation_all(product) ) else metrics.push( statement_metric_for(product, collection, operation), statement_action_metric_for(product,operation), statement_all_metric_for(product), statement_all(product) ) end metrics.push( product_suffixed_rollup(product, suffix), product_rollup(product), suffixed_rollup(suffix), OA_ROLLUP_METRIC ) metrics end |
.metrics_from_sql(product, sql) ⇒ Object
105 106 107 108 |
# File 'lib/one_apm/agent/datastore/metric_helper.rb', line 105 def self.metrics_from_sql(product, sql) operation = OneApm::Agent::Database.parse_operation_from_query(sql) || OA_OTHER metrics_for(product, operation) end |
.operation_all(product) ⇒ Object
Datastore/operation/NoSqlType
28 29 30 |
# File 'lib/one_apm/agent/datastore/metric_helper.rb', line 28 def self.operation_all(product) "Datastore/operation/#{product.split(':')[0]}" end |
.operation_metric_for(product, operation) ⇒ Object
Datastore/operation/NoSqlType:10.128.6.240:27017/update
18 19 20 |
# File 'lib/one_apm/agent/datastore/metric_helper.rb', line 18 def self.operation_metric_for(product, operation) "Datastore/operation/#{product}/#{operation}" end |
.operation_product_rollup(product) ⇒ Object
Datastore/operation/NoSqlType:10.128.6.240:27017/all
23 24 25 |
# File 'lib/one_apm/agent/datastore/metric_helper.rb', line 23 def self.operation_product_rollup(product) "Datastore/operation/#{product}/all" end |
.overridden_operation_and_collection ⇒ Object
Allow Transaction#with_database_metric_name to override our collection and operation
112 113 114 115 116 |
# File 'lib/one_apm/agent/datastore/metric_helper.rb', line 112 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
36 37 38 |
# File 'lib/one_apm/agent/datastore/metric_helper.rb', line 36 def self.product_rollup(product) "Datastore/#{product}/all" end |
.product_suffixed_rollup(product, suffix) ⇒ Object
32 33 34 |
# File 'lib/one_apm/agent/datastore/metric_helper.rb', line 32 def self.product_suffixed_rollup(product, suffix) "Datastore/#{product}/#{suffix}" end |
.statement_action_metric_for(product, operation) ⇒ Object
Datastore/statement/NoSqlType:10.128.6.240:27017/insert
50 51 52 |
# File 'lib/one_apm/agent/datastore/metric_helper.rb', line 50 def self.statement_action_metric_for(product, operation) "Datastore/statement/#{product}/#{operation}" end |
.statement_all(product) ⇒ Object
Datastore/statement/NoSqlType
60 61 62 |
# File 'lib/one_apm/agent/datastore/metric_helper.rb', line 60 def self.statement_all(product) "Datastore/statement/#{product.split(':')[0]}" end |
.statement_all_metric_for(product) ⇒ Object
Datastore/statement/NoSqlType:10.128.6.240:27017/all
55 56 57 |
# File 'lib/one_apm/agent/datastore/metric_helper.rb', line 55 def self.statement_all_metric_for(product) "Datastore/statement/#{product}/all" end |
.statement_metric_for(product, collection, operation) ⇒ Object
Datastore/statement/NoSqlType:10.128.6.240:27017/book/insert
45 46 47 |
# File 'lib/one_apm/agent/datastore/metric_helper.rb', line 45 def self.statement_metric_for(product, collection, operation) "Datastore/statement/#{product}/#{collection}/#{operation}" end |
.suffixed_rollup(suffix) ⇒ Object
40 41 42 |
# File 'lib/one_apm/agent/datastore/metric_helper.rb', line 40 def self.suffixed_rollup(suffix) "Datastore/#{suffix}" end |