// ToWire converts the state.MetricBatch into a type // that can be sent over the wire to the collector. func ToWire(mb *state.MetricBatch) *wireformat.MetricBatch { metrics := make([]wireformat.Metric, len(mb.Metrics())) for i, m := range mb.Metrics() { metrics[i] = wireformat.Metric{ Key: m.Key, Value: m.Value, Time: m.Time.UTC(), } } return &wireformat.MetricBatch{ UUID: mb.UUID(), ModelUUID: mb.ModelUUID(), UnitName: mb.Unit(), CharmUrl: mb.CharmURL(), Created: mb.Created().UTC(), Metrics: metrics, Credentials: mb.Credentials(), } }