Skip to content

Commit c0684bb

Browse files
committed
application field
1 parent b9cfa52 commit c0684bb

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

codersdk/workspacesdk/agentconn.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ func (c *AgentConn) SSH(ctx context.Context) (*gonet.TCPConn, error) {
149149
return nil, xerrors.Errorf("workspace agent not reachable in time: %v", ctx.Err())
150150
}
151151

152+
c.Conn.SendConnectedTelemetry(c.agentAddress(), tailnet.TelemetryApplicationSSH)
152153
return c.Conn.DialContextTCP(ctx, netip.AddrPortFrom(c.agentAddress(), AgentSSHPort))
153154
}
154155

@@ -185,6 +186,7 @@ func (c *AgentConn) Speedtest(ctx context.Context, direction speedtest.Direction
185186
return nil, xerrors.Errorf("workspace agent not reachable in time: %v", ctx.Err())
186187
}
187188

189+
c.Conn.SendConnectedTelemetry(c.agentAddress(), tailnet.TelemetryApplicationSpeedtest)
188190
speedConn, err := c.Conn.DialContextTCP(ctx, netip.AddrPortFrom(c.agentAddress(), AgentSpeedtestPort))
189191
if err != nil {
190192
return nil, xerrors.Errorf("dial speedtest: %w", err)

codersdk/workspacesdk/workspacesdk.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"cdr.dev/slog"
2222
"github.com/coder/coder/v2/codersdk"
2323
"github.com/coder/coder/v2/tailnet"
24+
"github.com/coder/coder/v2/tailnet/proto"
2425
)
2526

2627
// AgentIP is a static IPv6 address with the Tailscale prefix that is used to route
@@ -256,6 +257,7 @@ func (c *Client) DialAgent(dialCtx context.Context, agentID uuid.UUID, options *
256257
Logger: options.Logger,
257258
BlockEndpoints: c.client.DisableDirectConnections || options.BlockEndpoints,
258259
CaptureHook: options.CaptureHook,
260+
ClientType: proto.TelemetryEvent_CLI,
259261
TelemetrySink: telemetrySink,
260262
})
261263
if err != nil {

tailnet/conn.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -521,9 +521,6 @@ func (c *Conn) AwaitReachable(ctx context.Context, ip netip.Addr) bool {
521521
for {
522522
select {
523523
case <-completedCtx.Done():
524-
// TODO(ethanndickson): For now, I'm interpreting 'connected' as when the
525-
// agent is reachable.
526-
c.sendConnectedTelemetry(ip)
527524
return true
528525
case <-t.C:
529526
// Pings can take a while, so we can run multiple
@@ -713,12 +710,13 @@ func (c *Conn) MagicsockServeHTTPDebug(w http.ResponseWriter, r *http.Request) {
713710
c.magicConn.ServeHTTPDebug(w, r)
714711
}
715712

716-
func (c *Conn) sendConnectedTelemetry(ip netip.Addr) {
713+
func (c *Conn) SendConnectedTelemetry(ip netip.Addr, application string) {
717714
if c.telemetrySink == nil {
718715
return
719716
}
720717
e := c.newTelemetryEvent()
721718
e.Status = proto.TelemetryEvent_CONNECTED
719+
e.Application = application
722720
pip, ok := c.wireguardEngine.PeerForIP(ip)
723721
if ok {
724722
e.NodeIdRemote = uint64(pip.Node.ID)

tailnet/telemetry.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ import (
1717
"github.com/coder/coder/v2/tailnet/proto"
1818
)
1919

20+
// TODO(ethanndickson): How useful is the 'application' field?
21+
const (
22+
TelemetryApplicationSSH string = "ssh"
23+
TelemetryApplicationSpeedtest string = "speedtest"
24+
)
25+
2026
// Responsible for storing and anonymizing networking telemetry state.
2127
type TelemetryStore struct {
2228
mu sync.Mutex
@@ -50,7 +56,6 @@ func (b *TelemetryStore) newEvent() *proto.TelemetryEvent {
5056
LatestNetcheck: b.cleanNetCheck,
5157

5258
// TODO(ethanndickson):
53-
Application: "",
5459
ConnectionAge: &durationpb.Duration{},
5560
ConnectionSetup: &durationpb.Duration{},
5661
P2PSetup: &durationpb.Duration{},

0 commit comments

Comments
 (0)