Skip to content

Commit 6e0ec17

Browse files
committed
better connectionage
1 parent 6ee3bfa commit 6e0ec17

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

tailnet/conn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,9 +727,9 @@ func (c *Conn) SendConnectedTelemetry(ip netip.Addr, application string) {
727727
if c.telemetrySink == nil {
728728
return
729729
}
730+
c.telemetryStore.markConnected(time.Since(c.createdAt))
730731
e := c.newTelemetryEvent()
731732
e.Status = proto.TelemetryEvent_CONNECTED
732-
e.ConnectionSetup = durationpb.New(time.Since(c.createdAt))
733733
e.Application = application
734734
pip, ok := c.wireguardEngine.PeerForIP(ip)
735735
if ok {

tailnet/telemetry.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ type TelemetryStore struct {
3333
cleanNetCheck *proto.Netcheck
3434
nodeID uint64
3535
homeDerp int32
36+
37+
connSetupTime time.Duration
3638
}
3739

3840
func newTelemetryStore() (*TelemetryStore, error) {
@@ -52,17 +54,25 @@ func (b *TelemetryStore) newEvent() *proto.TelemetryEvent {
5254
defer b.mu.Unlock()
5355

5456
return &proto.TelemetryEvent{
55-
Time: timestamppb.Now(),
56-
DerpMap: DERPMapToProto(b.cleanDerpMap),
57-
LatestNetcheck: b.cleanNetCheck,
58-
NodeIdSelf: b.nodeID,
59-
HomeDerp: b.homeDerp,
57+
Time: timestamppb.Now(),
58+
DerpMap: DERPMapToProto(b.cleanDerpMap),
59+
LatestNetcheck: b.cleanNetCheck,
60+
NodeIdSelf: b.nodeID,
61+
HomeDerp: b.homeDerp,
62+
ConnectionSetup: durationpb.New(b.connSetupTime),
6063

6164
// TODO(ethanndickson):
6265
P2PSetup: &durationpb.Duration{},
6366
}
6467
}
6568

69+
func (b *TelemetryStore) markConnected(connSetupTime time.Duration) {
70+
b.mu.Lock()
71+
defer b.mu.Unlock()
72+
73+
b.connSetupTime = connSetupTime
74+
}
75+
6676
// Given a DERPMap, anonymise all IPs and hostnames.
6777
// Keep track of seen hostnames/cert names to anonymize them from future logs.
6878
// b.mu must NOT be held.

0 commit comments

Comments
 (0)