extractMetricFromCall attempts to extract a Metric from a function call expression. It returns the metric and true if successful, or an empty metric and false if the call is not a metric registration. Supported patterns: - prometheus.NewDesc() calls - prometheus.New*() and prometheus.New*Vec() with
(call *ast.CallExpr, decls declarations)
| 683 | // - prometheus.New*() and prometheus.New*Vec() with *Opts{} |
| 684 | // - promauto.With(reg).New*() and factory.New*() patterns |
| 685 | func extractMetricFromCall(call *ast.CallExpr, decls declarations) (Metric, bool) { |
| 686 | // Check for prometheus.NewDesc() pattern. |
| 687 | if metric, ok := extractNewDescMetric(call, decls); ok { |
| 688 | return metric, true |
| 689 | } |
| 690 | |
| 691 | // Check for prometheus.New*() and prometheus.New*Vec() patterns. |
| 692 | if metric, ok := extractOptsMetric(call, decls); ok { |
| 693 | return metric, true |
| 694 | } |
| 695 | |
| 696 | // Check for promauto.With(reg).New*() pattern. |
| 697 | if metric, ok := extractPromautoMetric(call, decls); ok { |
| 698 | return metric, true |
| 699 | } |
| 700 | |
| 701 | return Metric{}, false |
| 702 | } |
| 703 | |
| 704 | // String returns the metric in Prometheus text exposition format. |
| 705 | // Label values are empty strings and metric values are 0 since only |
no test coverage detected