MCPcopy Create free account
hub / github.com/cronitorio/cronitor-cli / parseMetrics

Function parseMetrics

cmd/ping.go:123–143  ·  view source on GitHub ↗

parseMetrics parses metric strings like "count:processed=100,error_count:failed=2"

(metricStr string)

Source from the content-addressed store, hash-verified

121
122// parseMetrics parses metric strings like "count:processed=100,error_count:failed=2"
123func parseMetrics(metricStr string) map[string]int {
124 metrics := make(map[string]int)
125 parts := strings.Split(metricStr, ",")
126 for _, part := range parts {
127 part = strings.TrimSpace(part)
128 if part == "" {
129 continue
130 }
131 // Format: type:name=value (e.g., count:processed=100)
132 eqIdx := strings.LastIndex(part, "=")
133 if eqIdx == -1 {
134 continue
135 }
136 key := strings.TrimSpace(part[:eqIdx])
137 valStr := strings.TrimSpace(part[eqIdx+1:])
138 if val, err := strconv.Atoi(valStr); err == nil {
139 metrics[key] = val
140 }
141 }
142 return metrics
143}
144
145func init() {
146 RootCmd.AddCommand(pingCmd)

Callers 1

ping.goFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected