MCPcopy
hub / github.com/dgraph-io/dgraph / periodicallyPostTelemetry

Method periodicallyPostTelemetry

dgraph/cmd/zero/zero.go:101–140  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

99}
100
101func (s *Server) periodicallyPostTelemetry() {
102 const scarfBaseUrlFmt = "https://events.dgraph.io/dgraph-deployments/%v/%v/%v/%v/%v"
103
104 // sleep so that a leader is elected by this time
105 time.Sleep(time.Minute)
106
107 glog.Infof("Starting telemetry data collection for zero...")
108
109 ticker := time.Tick(6 * time.Hour)
110
111 var lastPostedAt time.Time
112 for range ticker {
113 if !s.Node.AmLeader() {
114 continue
115 }
116
117 if time.Since(lastPostedAt) < time.Hour*24 {
118 continue
119 }
120
121 ms := s.membershipState()
122 var numAlphas, numTablets int
123 for _, g := range ms.GetGroups() {
124 numAlphas += len(g.GetMembers())
125 numTablets += len(g.GetTablets())
126 }
127
128 url := fmt.Sprintf(scarfBaseUrlFmt, x.Version(),
129 runtime.GOOS, numAlphas, len(ms.GetZeros()), numTablets)
130 glog.Infof("Posting Telemetry data to [%v]", url)
131
132 resp, err := http.Get(url)
133 if err != nil {
134 glog.Infof("Telemetry couldn't be posted. Error: %v", err)
135 continue
136 }
137 _ = resp.Body.Close()
138 lastPostedAt = time.Now()
139 }
140}
141
142func (s *Server) triggerLeaderChange() {
143 s.Lock()

Callers 1

runFunction · 0.80

Calls 10

membershipStateMethod · 0.95
VersionFunction · 0.92
InfofMethod · 0.80
GetGroupsMethod · 0.80
GetMembersMethod · 0.80
GetZerosMethod · 0.80
GetMethod · 0.65
CloseMethod · 0.65
AmLeaderMethod · 0.45
GetTabletsMethod · 0.45

Tested by

no test coverage detected