summaryrefslogtreecommitdiff
path: root/internal/metrics/metrics.go
blob: 6174bca62ba9b38dfd1a4c8502c3f7f6d5975e41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package metrics

import (
	"github.com/prometheus/client_golang/prometheus"
	"github.com/prometheus/client_golang/prometheus/promauto"
)

const (
	namespace     = "gitlab_shell"
	sshdSubsystem = "sshd"
	httpSubsystem = "http"
)

var (
	SshdConnectionDuration = promauto.NewHistogram(
		prometheus.HistogramOpts{
			Namespace: namespace,
			Subsystem: sshdSubsystem,
			Name:      "connection_duration_seconds",
			Help:      "A histogram of latencies for connections to gitlab-shell sshd.",
			Buckets: []float64{
				0.005, /* 5ms */
				0.025, /* 25ms */
				0.1,   /* 100ms */
				0.5,   /* 500ms */
				1.0,   /* 1s */
				10.0,  /* 10s */
				30.0,  /* 30s */
				60.0,  /* 1m */
				300.0, /* 5m */
			},
		},
	)

	SshdHitMaxSessions = promauto.NewCounter(
		prometheus.CounterOpts{
			Namespace: namespace,
			Subsystem: sshdSubsystem,
			Name:      "concurrent_limited_sessions_total",
			Help:      "The number of times the concurrent sessions limit was hit in gitlab-shell sshd.",
		},
	)

	HttpRequestDuration = promauto.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: namespace,
			Subsystem: httpSubsystem,
			Name:      "request_seconds",
			Help:      "A histogram of latencies for gitlab-shell http requests",
			Buckets: []float64{
				0.01, /* 10ms */
				0.05, /* 50ms */
				0.1,  /* 100ms */
				0.25, /* 250ms */
				0.5,  /* 500ms */
				1.0,  /* 1s */
				5.0,  /* 5s */
				10.0, /* 10s */
			},
		},
		[]string{"code", "method"},
	)
)