MCPcopy Create free account
hub / github.com/facebook/time / FetchStats

Method FetchStats

fbclock/daemon/datafetcher_http.go:55–76  ·  view source on GitHub ↗

FetchStats fetches GMs via http

(cfg *Config)

Source from the content-addressed store, hash-verified

53}
54
55// FetchStats fetches GMs via http
56func (hf *HTTPFetcher) FetchStats(cfg *Config) (*DataPoint, error) {
57 url := fmt.Sprintf("http://%s/", cfg.PTPClientAddress)
58 sm, err := stats.FetchStats(url)
59 if err != nil {
60 return nil, err
61 }
62 log.Debugf("TIME_STATUS_NP: %+v", sm)
63
64 for _, s := range sm {
65 if s.Selected {
66 accuracyNS := s.ClockQuality.ClockAccuracy.Duration().Nanoseconds()
67 return &DataPoint{
68 IngressTimeNS: s.IngressTime,
69 MasterOffsetNS: s.Offset,
70 PathDelayNS: s.MeanPathDelay,
71 ClockAccuracyNS: float64(int64(s.GMPresent) * accuracyNS),
72 ServoState: s.ServoState,
73 }, nil
74 }
75 }
76 return nil, fmt.Errorf("no selected grandmaster out of %d reported by sptp: [%s]", len(sm), describeGMs(sm))
77}
78
79// describeGMs prints what bmca rejects a grandmaster on: an error, a negative correction field, or its clock quality.

Callers 6

TestFetchStatsFunction · 0.95
TestFetchStatsHTTPErrorFunction · 0.95

Calls 3

FetchStatsFunction · 0.92
NanosecondsMethod · 0.45
DurationMethod · 0.45

Tested by 6

TestFetchStatsFunction · 0.76
TestFetchStatsHTTPErrorFunction · 0.76