Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 658f6f9

Browse files
committed
fix: set network telemetry client version on server
1 parent d9f4193 commit 658f6f9

File tree

4 files changed

+140
-151
lines changed

4 files changed

+140
-151
lines changed

coderd/telemetry/telemetry.go

+24-25
Original file line numberDiff line numberDiff line change
@@ -1230,19 +1230,18 @@ func netcheckFromProto(proto *tailnetproto.Netcheck) Netcheck {
12301230

12311231
// NetworkEvent and all related structs come from tailnet.proto.
12321232
type NetworkEvent struct {
1233-
ID uuid.UUID `json:"id"`
1234-
Time time.Time `json:"time"`
1235-
Application string `json:"application"`
1236-
Status string `json:"status"` // connected, disconnected
1237-
DisconnectionReason string `json:"disconnection_reason"`
1238-
ClientType string `json:"client_type"` // cli, agent, coderd, wsproxy
1239-
ClientVersion string `json:"client_version"`
1240-
NodeIDSelf uint64 `json:"node_id_self"`
1241-
NodeIDRemote uint64 `json:"node_id_remote"`
1242-
P2PEndpoint NetworkEventP2PEndpoint `json:"p2p_endpoint"`
1243-
HomeDERP int `json:"home_derp"`
1244-
DERPMap DERPMap `json:"derp_map"`
1245-
LatestNetcheck Netcheck `json:"latest_netcheck"`
1233+
ID uuid.UUID `json:"id"`
1234+
Time time.Time `json:"time"`
1235+
Application string `json:"application"`
1236+
Status string `json:"status"` // connected, disconnected
1237+
ClientType string `json:"client_type"` // cli, agent, coderd, wsproxy
1238+
ClientVersion string `json:"client_version"`
1239+
NodeIDSelf uint64 `json:"node_id_self"`
1240+
NodeIDRemote uint64 `json:"node_id_remote"`
1241+
P2PEndpoint NetworkEventP2PEndpoint `json:"p2p_endpoint"`
1242+
HomeDERP int `json:"home_derp"`
1243+
DERPMap DERPMap `json:"derp_map"`
1244+
LatestNetcheck Netcheck `json:"latest_netcheck"`
12461245

12471246
ConnectionAge *time.Duration `json:"connection_age"`
12481247
ConnectionSetup *time.Duration `json:"connection_setup"`
@@ -1277,18 +1276,18 @@ func NetworkEventFromProto(proto *tailnetproto.TelemetryEvent) (NetworkEvent, er
12771276
}
12781277

12791278
return NetworkEvent{
1280-
ID: id,
1281-
Time: proto.Time.AsTime(),
1282-
Application: proto.Application,
1283-
Status: strings.ToLower(proto.Status.String()),
1284-
DisconnectionReason: proto.DisconnectionReason,
1285-
ClientType: strings.ToLower(proto.ClientType.String()),
1286-
NodeIDSelf: proto.NodeIdSelf,
1287-
NodeIDRemote: proto.NodeIdRemote,
1288-
P2PEndpoint: p2pEndpointFromProto(proto.P2PEndpoint),
1289-
HomeDERP: int(proto.HomeDerp),
1290-
DERPMap: derpMapFromProto(proto.DerpMap),
1291-
LatestNetcheck: netcheckFromProto(proto.LatestNetcheck),
1279+
ID: id,
1280+
Time: proto.Time.AsTime(),
1281+
Application: proto.Application,
1282+
Status: strings.ToLower(proto.Status.String()),
1283+
ClientType: strings.ToLower(proto.ClientType.String()),
1284+
ClientVersion: proto.ClientVersion,
1285+
NodeIDSelf: proto.NodeIdSelf,
1286+
NodeIDRemote: proto.NodeIdRemote,
1287+
P2PEndpoint: p2pEndpointFromProto(proto.P2PEndpoint),
1288+
HomeDERP: int(proto.HomeDerp),
1289+
DERPMap: derpMapFromProto(proto.DerpMap),
1290+
LatestNetcheck: netcheckFromProto(proto.LatestNetcheck),
12921291

12931292
ConnectionAge: protoDurationNil(proto.ConnectionAge),
12941293
ConnectionSetup: protoDurationNil(proto.ConnectionSetup),

tailnet/conn.go

+1
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,7 @@ func (c *Conn) SendConnectedTelemetry(ip netip.Addr, application string) {
733733
c.telemetryStore.markConnected(&ip, application)
734734
e := c.newTelemetryEvent()
735735
e.Status = proto.TelemetryEvent_CONNECTED
736+
e.ConnectionSetup = durationpb.New(time.Since(c.createdAt))
736737
c.sendTelemetryBackground(e)
737738
}
738739

0 commit comments

Comments
 (0)