MCPcopy Create free account
hub / github.com/coder/coder / parseMetricFuncName

Function parseMetricFuncName

scripts/metricsdocgen/scanner/scanner.go:447–462  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
447func 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.
465func extractOpts(expr ast.Expr, decls declarations) (metricOpts, bool) {

Callers 2

extractOptsMetricFunction · 0.85
extractPromautoMetricFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected