func (p *pstoreHandlerType) Visit( theStore *store.Store, endpointId interface{}) error { hostName := endpointId.(*collector.Endpoint).HostName() port := endpointId.(*collector.Endpoint).Port() appName := p.appList.ByPort(port).Name() iterator, timeLeft := p.namedIterator(theStore, endpointId) if p.maybeNilCoord != nil { // aMetricStore from the consumer exposes the same filtering that // the consumer does internally. aMetricStore := p.ConsumerMetricsStore() // Even though the consumer filters out the records it can't write, // we have to do the same filtering here so that we get an accurate // count of skipped records with timestamps coming before the start // of our lease. iterator = store.NamedIteratorFilter(iterator, aMetricStore) // RemoveFromRecordCount removes skipped records from the total // count of records to write. iterator = store.NamedIteratorCoordinate( iterator, p.maybeNilCoord, kLeaseSpan, aMetricStore.RemoveFromRecordCount) } p.consumer.Write(iterator, hostName, appName) p.visitorMetricsStore.MaybeIncreaseTimeLeft( duration.FromFloat(timeLeft)) return nil }
// FromFloat converts a float64 to a value according to this type // FromFloat panics if this type doesn't support conversion from float64 func (t Type) FromFloat(value float64) interface{} { switch t { case Int8: return int8(round(value)) case Int16: return int16(round(value)) case Int32: return int32(round(value)) case Int64: return int64(round(value)) case Uint8: return uint8(round(value)) case Uint16: return uint16(round(value)) case Uint32: return uint32(round(value)) case Uint64: return uint64(round(value)) case Float32: return float32(value) case Float64: return value case GoTime: return duration.FloatToTime(value) case GoDuration: return duration.FromFloat(value) default: panic("Type doesn't support converstion from a float") } }
func (p *pstoreHandlerType) EndVisit(theStore *store.Store) { p.consumer.Flush() p.visitorMetricsStore.SetTimeLeft( duration.FromFloat(theStore.TimeLeft(p.iteratorName()))) totalTime := time.Now().Sub(p.startTime) p.totalTimeSpentDist.Add(totalTime) }