MCPcopy Create free account
hub / github.com/JordanCoin/codemap / appendMetrics

Function appendMetrics

handoff/storage.go:108–142  ·  view source on GitHub ↗
(root string, artifact *Artifact)

Source from the content-addressed store, hash-verified

106}
107
108func appendMetrics(root string, artifact *Artifact) error {
109 entry := struct {
110 GeneratedAt string `json:"generated_at"`
111 Branch string `json:"branch"`
112 BaseRef string `json:"base_ref"`
113 PrefixHash string `json:"prefix_hash"`
114 DeltaHash string `json:"delta_hash"`
115 CombinedHash string `json:"combined_hash"`
116 Metrics CacheMetrics `json:"metrics"`
117 }{
118 GeneratedAt: artifact.GeneratedAt.Format("2006-01-02T15:04:05Z07:00"),
119 Branch: artifact.Branch,
120 BaseRef: artifact.BaseRef,
121 PrefixHash: artifact.PrefixHash,
122 DeltaHash: artifact.DeltaHash,
123 CombinedHash: artifact.CombinedHash,
124 Metrics: artifact.Metrics,
125 }
126
127 data, err := json.Marshal(entry)
128 if err != nil {
129 return err
130 }
131
132 f, err := os.OpenFile(MetricsPath(root), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
133 if err != nil {
134 return err
135 }
136 defer f.Close()
137
138 if _, err := f.Write(append(data, '\n')); err != nil {
139 return err
140 }
141 return capMetricsLog(root, maxMetricsLines)
142}
143
144func normalizeArtifact(artifact *Artifact) {
145 ensureSchemaVersion(artifact)

Callers 2

WriteLatestFunction · 0.85
TestMetricsLogCappedFunction · 0.85

Calls 4

MetricsPathFunction · 0.85
capMetricsLogFunction · 0.85
CloseMethod · 0.80
WriteMethod · 0.80

Tested by 1

TestMetricsLogCappedFunction · 0.68