As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects
Commit fa5bf866 authored by Ash McKenzie's avatar Ash McKenzie
Browse files

Merge branch 'id-fix-connections-duration-metrics' into 'main'

Fix connections duration metrics

See merge request gitlab-org/gitlab-shell!588
parents 40b070ef 8e1d69b1
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -13,7 +13,6 @@ import (
)
type connection struct {
begin time.Time
concurrentSessions *semaphore.Weighted
remoteAddr string
}
Loading
Loading
@@ -22,7 +21,6 @@ type channelHandler func(context.Context, ssh.Channel, <-chan *ssh.Request)
func newConnection(maxSessions int64, remoteAddr string) *connection {
return &connection{
begin: time.Now(),
concurrentSessions: semaphore.NewWeighted(maxSessions),
remoteAddr: remoteAddr,
}
Loading
Loading
@@ -32,9 +30,11 @@ func (c *connection) handle(ctx context.Context, chans <-chan ssh.NewChannel, ha
ctxlog := log.WithContextFields(ctx, log.Fields{"remote_addr": c.remoteAddr})
metrics.SshdConnectionsInFlight.Inc()
defer metrics.SshdConnectionsInFlight.Dec()
defer metrics.SshdConnectionDuration.Observe(time.Since(c.begin).Seconds())
defer func(started time.Time) {
metrics.SshdConnectionsInFlight.Dec()
metrics.SshdConnectionDuration.Observe(time.Since(started).Seconds())
}(time.Now())
for newChannel := range chans {
ctxlog.WithField("channel_type", newChannel.ChannelType()).Info("connection: handle: new channel requested")
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment