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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user