buildMetricName constructs the full metric name from namespace, subsystem, and name.
(namespace, subsystem, name string)
| 511 | |
| 512 | // buildMetricName constructs the full metric name from namespace, subsystem, and name. |
| 513 | func buildMetricName(namespace, subsystem, name string) string { |
| 514 | metricNameParts := make([]string, 0, 3) |
| 515 | if namespace != "" { |
| 516 | metricNameParts = append(metricNameParts, namespace) |
| 517 | } |
| 518 | if subsystem != "" { |
| 519 | metricNameParts = append(metricNameParts, subsystem) |
| 520 | } |
| 521 | if name != "" { |
| 522 | metricNameParts = append(metricNameParts, name) |
| 523 | } |
| 524 | // Join non-empty parts with "_" to handle optional namespace/subsystem. |
| 525 | // e.g., ("coderd", "", "agents_up"): "coderd_agents_up" |
| 526 | return strings.Join(metricNameParts, "_") |
| 527 | } |
| 528 | |
| 529 | // extractOptsMetric extracts a metric from prometheus.New*() or prometheus.New*Vec() calls. |
| 530 | // Supported patterns: |
no outgoing calls
no test coverage detected