Skip to content

Commit 9b0e31a

Browse files
committed
Address PR comments
1 parent c004c04 commit 9b0e31a

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

agent/agentssh/agentssh_internal_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ func Test_sessionStart_orphan(t *testing.T) {
5858
done := make(chan struct{})
5959
go func() {
6060
defer close(done)
61+
62+
m := metricsForSession(s.metrics.sessions, "ssh")
6163
// we don't really care what the error is here. In the larger scenario,
6264
// the client has disconnected, so we can't return any error information
6365
// to them.
64-
m := metricsForSession(s.metrics.sessions, "ssh")
6566
_ = s.startPTYSession(sess, m, cmd, ptyInfo, windowSize)
6667
}()
6768

agent/agentssh/metrics.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type sshServerMetrics struct {
2020

2121
// X11
2222
x11SocketDirError prometheus.Counter
23+
x11HostnameError prometheus.Counter
2324
x11XauthorityError prometheus.Counter
2425

2526
sessions sessionMetrics
@@ -86,6 +87,11 @@ func newSSHServerMetrics(registerer prometheus.Registerer) *sshServerMetrics {
8687
})
8788
registerer.MustRegister(sftpServerError)
8889

90+
x11HostnameError := prometheus.NewCounter(prometheus.CounterOpts{
91+
Namespace: "agent", Subsystem: "ssh_server", Name: "x11_hostname_error",
92+
})
93+
registerer.MustRegister(x11HostnameError)
94+
8995
x11SocketDirError := prometheus.NewCounter(prometheus.CounterOpts{
9096
Namespace: "agent", Subsystem: "ssh_server", Name: "x11_socket_dir_error",
9197
})
@@ -106,6 +112,7 @@ func newSSHServerMetrics(registerer prometheus.Registerer) *sshServerMetrics {
106112
x11Callback: x11Callback,
107113
sftpHandler: sftpHandler,
108114
sftpServerError: sftpServerError,
115+
x11HostnameError: x11HostnameError,
109116
x11SocketDirError: x11SocketDirError,
110117
x11XauthorityError: x11XauthorityError,
111118

cli/agent.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,11 +387,10 @@ func urlPort(u string) (int, error) {
387387
}
388388

389389
func prometheusMetricsHandler(prometheusRegistry *prometheus.Registry, logger slog.Logger) http.Handler {
390-
// We don't have any other internal metrics so far, so it's safe to expose metrics this way.
391-
// Based on: https://github.com/tailscale/tailscale/blob/280255acae604796a1113861f5a84e6fa2dc6121/ipn/localapi/localapi.go#L489
392390
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
393391
w.Header().Set("Content-Type", "text/plain")
394392

393+
// Based on: https://github.com/tailscale/tailscale/blob/280255acae604796a1113861f5a84e6fa2dc6121/ipn/localapi/localapi.go#L489
395394
clientmetric.WritePrometheusExpositionFormat(w)
396395

397396
metricFamilies, err := prometheusRegistry.Gather()

0 commit comments

Comments
 (0)