Skip to content

Commit 90b351d

Browse files
committed
Remove callbacks
1 parent 7d4ccce commit 90b351d

File tree

3 files changed

+7
-41
lines changed

3 files changed

+7
-41
lines changed

agent/agentssh/agentssh.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,19 +122,16 @@ func NewServer(ctx context.Context, logger slog.Logger, prometheusRegistry *prom
122122
s.logger.Debug(ctx, "local port forward",
123123
slog.F("destination-host", destinationHost),
124124
slog.F("destination-port", destinationPort))
125-
metrics.localPortForwardingCallback.Add(1)
126125
return true
127126
},
128127
PtyCallback: func(ctx ssh.Context, pty ssh.Pty) bool {
129-
metrics.ptyCallback.Add(1)
130128
return true
131129
},
132130
ReversePortForwardingCallback: func(ctx ssh.Context, bindHost string, bindPort uint32) bool {
133131
// Allow reverse port forwarding all!
134132
s.logger.Debug(ctx, "local port forward",
135133
slog.F("bind-host", bindHost),
136134
slog.F("bind-port", bindPort))
137-
metrics.reversePortForwardingCallback.Add(1)
138135
return true
139136
},
140137
RequestHandlers: map[string]ssh.RequestHandler{

agent/agentssh/metrics.go

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,7 @@ import (
77
)
88

99
type sshServerMetrics struct {
10-
// SSH callbacks
11-
connectionFailedCallback prometheus.Counter
12-
localPortForwardingCallback prometheus.Counter
13-
ptyCallback prometheus.Counter
14-
reversePortForwardingCallback prometheus.Counter
15-
x11Callback prometheus.Counter
10+
connectionFailedCallback prometheus.Counter
1611

1712
// SFTP
1813
sftpHandler prometheus.Counter
@@ -57,26 +52,6 @@ func newSSHServerMetrics(registerer prometheus.Registerer) *sshServerMetrics {
5752
})
5853
registerer.MustRegister(connectionFailedCallback)
5954

60-
localPortForwardingCallback := prometheus.NewCounter(prometheus.CounterOpts{
61-
Namespace: "agent", Subsystem: "ssh_server", Name: "local_port_forwarding_callback",
62-
})
63-
registerer.MustRegister(localPortForwardingCallback)
64-
65-
ptyCallback := prometheus.NewCounter(prometheus.CounterOpts{
66-
Namespace: "agent", Subsystem: "ssh_server", Name: "pty_callback",
67-
})
68-
registerer.MustRegister(ptyCallback)
69-
70-
reversePortForwardingCallback := prometheus.NewCounter(prometheus.CounterOpts{
71-
Namespace: "agent", Subsystem: "ssh_server", Name: "reverse_port_forwarding_callback",
72-
})
73-
registerer.MustRegister(reversePortForwardingCallback)
74-
75-
x11Callback := prometheus.NewCounter(prometheus.CounterOpts{
76-
Namespace: "agent", Subsystem: "ssh_server", Name: "x11_callback",
77-
})
78-
registerer.MustRegister(x11Callback)
79-
8055
sftpHandler := prometheus.NewCounter(prometheus.CounterOpts{
8156
Namespace: "agent", Subsystem: "ssh_server", Name: "sftp_handler",
8257
})
@@ -105,16 +80,12 @@ func newSSHServerMetrics(registerer prometheus.Registerer) *sshServerMetrics {
10580
sessions := newSessionMetrics(registerer)
10681

10782
return &sshServerMetrics{
108-
connectionFailedCallback: connectionFailedCallback,
109-
localPortForwardingCallback: localPortForwardingCallback,
110-
ptyCallback: ptyCallback,
111-
reversePortForwardingCallback: reversePortForwardingCallback,
112-
x11Callback: x11Callback,
113-
sftpHandler: sftpHandler,
114-
sftpServerError: sftpServerError,
115-
x11HostnameError: x11HostnameError,
116-
x11SocketDirError: x11SocketDirError,
117-
x11XauthorityError: x11XauthorityError,
83+
connectionFailedCallback: connectionFailedCallback,
84+
sftpHandler: sftpHandler,
85+
sftpServerError: sftpServerError,
86+
x11HostnameError: x11HostnameError,
87+
x11SocketDirError: x11SocketDirError,
88+
x11XauthorityError: x11XauthorityError,
11889

11990
sessions: sessions,
12091
}

agent/agentssh/x11.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ import (
2424
// x11Callback is called when the client requests X11 forwarding.
2525
// It adds an Xauthority entry to the Xauthority file.
2626
func (s *Server) x11Callback(ctx ssh.Context, x11 ssh.X11) bool {
27-
s.metrics.x11Callback.Add(1)
28-
2927
hostname, err := os.Hostname()
3028
if err != nil {
3129
s.logger.Warn(ctx, "failed to get hostname", slog.Error(err))

0 commit comments

Comments
 (0)