parseMetricFuncName parses a prometheus function name and returns the metric type and whether it's a Vec type. Returns empty string if not a recognized metric function.
(funcName string)
| 445 | // parseMetricFuncName parses a prometheus function name and returns the metric type |
| 446 | // and whether it's a Vec type. Returns empty string if not a recognized metric function. |
| 447 | func parseMetricFuncName(funcName string) (MetricType, bool) { |
| 448 | isVec := strings.HasSuffix(funcName, "Vec") |
| 449 | baseName := strings.TrimSuffix(funcName, "Vec") |
| 450 | |
| 451 | switch baseName { |
| 452 | case "NewGauge": |
| 453 | return MetricTypeGauge, isVec |
| 454 | case "NewCounter": |
| 455 | return MetricTypeCounter, isVec |
| 456 | case "NewHistogram": |
| 457 | return MetricTypeHistogram, isVec |
| 458 | case "NewSummary": |
| 459 | return MetricTypeSummary, isVec |
| 460 | } |
| 461 | return "", false |
| 462 | } |
| 463 | |
| 464 | // extractOpts extracts fields from a prometheus.*Opts composite literal. |
| 465 | func extractOpts(expr ast.Expr, decls declarations) (metricOpts, bool) { |
no outgoing calls
no test coverage detected