Skip to content

Commit a9c53cc

Browse files
authored
Merge pull request #1 from wbh1/master
Add metric for "newSessionRequestCount"
2 parents a0001ca + d91cad9 commit a9c53cc

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.idea/
2+
selenium_grid_exporter

selenium_grid_exporter.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@ var (
2828
type Exporter struct {
2929
URI string
3030
mutex sync.RWMutex
31-
up, slotsTotal, slotsFree prometheus.Gauge
31+
up, slotsTotal, slotsFree, newSessionRequestCount prometheus.Gauge
3232
}
3333

3434
type hubResponse struct {
3535
Success bool `json:"success"`
3636
Debug bool `json:"debug"`
3737
CleanUpCycle int `json:"cleanUpCycle"`
3838
Slots slotCounts `json:"slotCounts"`
39+
NewSession float64 `json:"newSessionRequestCount"`
3940
}
4041

4142
type slotCounts struct {
@@ -65,13 +66,20 @@ func NewExporter(uri string) *Exporter {
6566
Name: "slotsFree",
6667
Help: "number of free slots",
6768
}),
69+
newSessionRequestCount: prometheus.NewGauge(prometheus.GaugeOpts{
70+
Namespace: nameSpace,
71+
Subsystem: subSystem,
72+
Name: "sessions_backlog",
73+
Help: "number of sessions waiting for a slot",
74+
}),
6875
}
6976
}
7077

7178
func (e *Exporter) Describe(ch chan<- *prometheus.Desc) {
7279
e.up.Describe(ch)
7380
e.slotsTotal.Describe(ch)
7481
e.slotsFree.Describe(ch)
82+
e.newSessionRequestCount.Describe(ch)
7583
}
7684

7785
func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
@@ -84,6 +92,7 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
8492
ch <- e.up
8593
ch <- e.slotsTotal
8694
ch <- e.slotsFree
95+
ch <- e.newSessionRequestCount
8796

8897
return
8998
}
@@ -109,9 +118,10 @@ func (e *Exporter) scrape() {
109118
log.Errorf("Can't decode Selenium Grid response: %v", err)
110119
return
111120
}
112-
121+
113122
e.slotsTotal.Set(hResponse.Slots.Total)
114123
e.slotsFree.Set(hResponse.Slots.Free)
124+
e.newSessionRequestCount.Set(hResponse.NewSession)
115125

116126
}
117127

0 commit comments

Comments
 (0)