github.com/lulzWill/go-agent@v2.1.2+incompatible/internal/metric_names.go (about)

     1  package internal
     2  
     3  const (
     4  	apdexRollup = "Apdex"
     5  	apdexPrefix = "Apdex/"
     6  
     7  	webRollup        = "WebTransaction"
     8  	backgroundRollup = "OtherTransaction/all"
     9  
    10  	errorsPrefix = "Errors/"
    11  
    12  	// "HttpDispatcher" metric is used for the overview graph, and
    13  	// therefore should only be made for web transactions.
    14  	dispatcherMetric = "HttpDispatcher"
    15  
    16  	queueMetric = "WebFrontend/QueueTime"
    17  
    18  	webMetricPrefix        = "WebTransaction/Go"
    19  	backgroundMetricPrefix = "OtherTransaction/Go"
    20  
    21  	instanceReporting = "Instance/Reporting"
    22  
    23  	// https://newrelic.atlassian.net/wiki/display/eng/Custom+Events+in+New+Relic+Agents
    24  	customEventsSeen = "Supportability/Events/Customer/Seen"
    25  	customEventsSent = "Supportability/Events/Customer/Sent"
    26  
    27  	// https://source.datanerd.us/agents/agent-specs/blob/master/Transaction-Events-PORTED.md
    28  	txnEventsSeen = "Supportability/AnalyticsEvents/TotalEventsSeen"
    29  	txnEventsSent = "Supportability/AnalyticsEvents/TotalEventsSent"
    30  
    31  	// https://source.datanerd.us/agents/agent-specs/blob/master/Error-Events.md
    32  	errorEventsSeen = "Supportability/Events/TransactionError/Seen"
    33  	errorEventsSent = "Supportability/Events/TransactionError/Sent"
    34  
    35  	supportabilityDropped = "Supportability/MetricsDropped"
    36  
    37  	// Runtime/System Metrics
    38  	memoryPhysical       = "Memory/Physical"
    39  	heapObjectsAllocated = "Memory/Heap/AllocatedObjects"
    40  	cpuUserUtilization   = "CPU/User/Utilization"
    41  	cpuSystemUtilization = "CPU/System/Utilization"
    42  	cpuUserTime          = "CPU/User Time"
    43  	cpuSystemTime        = "CPU/System Time"
    44  	runGoroutine         = "Go/Runtime/Goroutines"
    45  	gcPauseFraction      = "GC/System/Pause Fraction"
    46  	gcPauses             = "GC/System/Pauses"
    47  )
    48  
    49  type rollupMetric struct {
    50  	all      string
    51  	allWeb   string
    52  	allOther string
    53  }
    54  
    55  func newRollupMetric(s string) rollupMetric {
    56  	return rollupMetric{
    57  		all:      s + "all",
    58  		allWeb:   s + "allWeb",
    59  		allOther: s + "allOther",
    60  	}
    61  }
    62  
    63  func (r rollupMetric) webOrOther(isWeb bool) string {
    64  	if isWeb {
    65  		return r.allWeb
    66  	}
    67  	return r.allOther
    68  }
    69  
    70  var (
    71  	errorsRollupMetric = newRollupMetric("Errors/")
    72  
    73  	// source.datanerd.us/agents/agent-specs/blob/master/APIs/external_segment.md
    74  	// source.datanerd.us/agents/agent-specs/blob/master/APIs/external_cat.md
    75  	// source.datanerd.us/agents/agent-specs/blob/master/Cross-Application-Tracing-PORTED.md
    76  	externalRollupMetric = newRollupMetric("External/")
    77  
    78  	// source.datanerd.us/agents/agent-specs/blob/master/Datastore-Metrics-PORTED.md
    79  	datastoreRollupMetric = newRollupMetric("Datastore/")
    80  
    81  	datastoreProductMetricsCache = map[string]rollupMetric{
    82  		"Cassandra":     newRollupMetric("Datastore/Cassandra/"),
    83  		"Derby":         newRollupMetric("Datastore/Derby/"),
    84  		"Elasticsearch": newRollupMetric("Datastore/Elasticsearch/"),
    85  		"Firebird":      newRollupMetric("Datastore/Firebird/"),
    86  		"IBMDB2":        newRollupMetric("Datastore/IBMDB2/"),
    87  		"Informix":      newRollupMetric("Datastore/Informix/"),
    88  		"Memcached":     newRollupMetric("Datastore/Memcached/"),
    89  		"MongoDB":       newRollupMetric("Datastore/MongoDB/"),
    90  		"MySQL":         newRollupMetric("Datastore/MySQL/"),
    91  		"MSSQL":         newRollupMetric("Datastore/MSSQL/"),
    92  		"Oracle":        newRollupMetric("Datastore/Oracle/"),
    93  		"Postgres":      newRollupMetric("Datastore/Postgres/"),
    94  		"Redis":         newRollupMetric("Datastore/Redis/"),
    95  		"Solr":          newRollupMetric("Datastore/Solr/"),
    96  		"SQLite":        newRollupMetric("Datastore/SQLite/"),
    97  		"CouchDB":       newRollupMetric("Datastore/CouchDB/"),
    98  		"Riak":          newRollupMetric("Datastore/Riak/"),
    99  		"VoltDB":        newRollupMetric("Datastore/VoltDB/"),
   100  	}
   101  )
   102  
   103  func customSegmentMetric(s string) string {
   104  	return "Custom/" + s
   105  }
   106  
   107  // customMetric is used to construct custom metrics from the input given to
   108  // Application.RecordCustomMetric.  Note that the "Custom/" prefix helps prevent
   109  // collision with other agent metrics, but does not eliminate the possibility
   110  // since "Custom/" is also used for segments.
   111  func customMetric(customerInput string) string {
   112  	return "Custom/" + customerInput
   113  }
   114  
   115  // DatastoreMetricKey contains the fields by which datastore metrics are
   116  // aggregated.
   117  type DatastoreMetricKey struct {
   118  	Product      string
   119  	Collection   string
   120  	Operation    string
   121  	Host         string
   122  	PortPathOrID string
   123  }
   124  
   125  type externalMetricKey struct {
   126  	Host                    string
   127  	ExternalCrossProcessID  string
   128  	ExternalTransactionName string
   129  }
   130  
   131  func datastoreScopedMetric(key DatastoreMetricKey) string {
   132  	if "" != key.Collection {
   133  		return datastoreStatementMetric(key)
   134  	}
   135  	return datastoreOperationMetric(key)
   136  }
   137  
   138  // Datastore/{datastore}/*
   139  func datastoreProductMetric(key DatastoreMetricKey) rollupMetric {
   140  	d, ok := datastoreProductMetricsCache[key.Product]
   141  	if ok {
   142  		return d
   143  	}
   144  	return newRollupMetric("Datastore/" + key.Product + "/")
   145  }
   146  
   147  // Datastore/operation/{datastore}/{operation}
   148  func datastoreOperationMetric(key DatastoreMetricKey) string {
   149  	return "Datastore/operation/" + key.Product +
   150  		"/" + key.Operation
   151  }
   152  
   153  // Datastore/statement/{datastore}/{table}/{operation}
   154  func datastoreStatementMetric(key DatastoreMetricKey) string {
   155  	return "Datastore/statement/" + key.Product +
   156  		"/" + key.Collection +
   157  		"/" + key.Operation
   158  }
   159  
   160  // Datastore/instance/{datastore}/{host}/{port_path_or_id}
   161  func datastoreInstanceMetric(key DatastoreMetricKey) string {
   162  	return "Datastore/instance/" + key.Product +
   163  		"/" + key.Host +
   164  		"/" + key.PortPathOrID
   165  }
   166  
   167  // External/{host}/all
   168  func externalHostMetric(key externalMetricKey) string {
   169  	return "External/" + key.Host + "/all"
   170  }
   171  
   172  // ExternalApp/{host}/{external_id}/all
   173  func externalAppMetric(key externalMetricKey) string {
   174  	return "ExternalApp/" + key.Host +
   175  		"/" + key.ExternalCrossProcessID + "/all"
   176  }
   177  
   178  // ExternalTransaction/{host}/{external_id}/{external_txnname}
   179  func externalTransactionMetric(key externalMetricKey) string {
   180  	return "ExternalTransaction/" + key.Host +
   181  		"/" + key.ExternalCrossProcessID +
   182  		"/" + key.ExternalTransactionName
   183  }