mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: fix parse typo for network telemetry (#13971)
This commit is contained in:
@@ -272,16 +272,16 @@ func requireOrgID[T Auditable](ctx context.Context, id uuid.UUID, log slog.Logge
|
||||
// entry.
|
||||
func InitRequestWithCancel[T Auditable](w http.ResponseWriter, p *RequestParams) (*Request[T], func(commit bool)) {
|
||||
req, commitF := InitRequest[T](w, p)
|
||||
cancelled := false
|
||||
canceled := false
|
||||
return req, func(commit bool) {
|
||||
// Once 'commit=false' is called, block
|
||||
// any future commit attempts.
|
||||
if !commit {
|
||||
cancelled = true
|
||||
canceled = true
|
||||
return
|
||||
}
|
||||
// If it was ever cancelled, block any commits
|
||||
if !cancelled {
|
||||
// If it was ever canceled, block any commits
|
||||
if !canceled {
|
||||
commitF()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1269,7 +1269,7 @@ func NetworkEventFromProto(proto *tailnetproto.TelemetryEvent) (NetworkEvent, er
|
||||
if proto == nil {
|
||||
return NetworkEvent{}, xerrors.New("nil event")
|
||||
}
|
||||
id, err := uuid.ParseBytes(proto.Id)
|
||||
id, err := uuid.FromBytes(proto.Id)
|
||||
if err != nil {
|
||||
return NetworkEvent{}, xerrors.Errorf("parse id %q: %w", proto.Id, err)
|
||||
}
|
||||
|
||||
@@ -168,10 +168,17 @@ func (api *API) workspaceAgentRPC(rw http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func (api *API) handleNetworkTelemetry(batch []*tailnetproto.TelemetryEvent) {
|
||||
telemetryEvents := make([]telemetry.NetworkEvent, 0, len(batch))
|
||||
var (
|
||||
telemetryEvents = make([]telemetry.NetworkEvent, 0, len(batch))
|
||||
didLogErr = false
|
||||
)
|
||||
for _, pEvent := range batch {
|
||||
tEvent, err := telemetry.NetworkEventFromProto(pEvent)
|
||||
if err != nil {
|
||||
if !didLogErr {
|
||||
api.Logger.Warn(api.ctx, "error converting network telemetry event", slog.Error(err))
|
||||
didLogErr = true
|
||||
}
|
||||
// Events that fail to be converted get discarded for now.
|
||||
continue
|
||||
}
|
||||
|
||||
+1
-3
@@ -775,11 +775,9 @@ func (c *Conn) sendPingTelemetry(pr *ipnstate.PingResult) {
|
||||
|
||||
// The returned telemetry event will not have it's status set.
|
||||
func (c *Conn) newTelemetryEvent() *proto.TelemetryEvent {
|
||||
// Infallible
|
||||
id, _ := c.id.MarshalBinary()
|
||||
event := c.telemetryStore.newEvent()
|
||||
event.ClientType = c.clientType
|
||||
event.Id = id
|
||||
event.Id = c.id[:]
|
||||
event.ConnectionAge = durationpb.New(time.Since(c.createdAt))
|
||||
return event
|
||||
}
|
||||
|
||||
@@ -261,6 +261,9 @@ func NewNetworkTelemetryBatcher(clk quartz.Clock, frequency time.Duration, maxSi
|
||||
closed: make(chan struct{}),
|
||||
done: make(chan struct{}),
|
||||
}
|
||||
if b.batchFn == nil {
|
||||
b.batchFn = func(batch []*proto.TelemetryEvent) {}
|
||||
}
|
||||
b.start()
|
||||
return b
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user