Skip to content

chore: fix parse typo for network telemetry #13971

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions coderd/audit/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down
2 changes: 1 addition & 1 deletion coderd/telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
9 changes: 8 additions & 1 deletion coderd/workspaceagentsrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 1 addition & 3 deletions tailnet/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
3 changes: 3 additions & 0 deletions tailnet/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Loading