mirror of
https://github.com/foomo/shop.git
synced 2025-10-16 12:35:39 +00:00
Added metrics for session acquisition, switched from Clone to Copy for standard sessions, updated glide deps
This commit is contained in:
parent
b8855a3eda
commit
de2dfdb28c
48
glide.lock
generated
48
glide.lock
generated
@ -1,10 +1,22 @@
|
||||
hash: a0f08cf80d876deff8376f2c3dfee8b5d2df8117d06e5337b508329ac10dcef2
|
||||
updated: 2018-03-27T21:03:11.417994706+02:00
|
||||
updated: 2019-07-02T12:22:38.011604+02:00
|
||||
imports:
|
||||
- name: github.com/beorn7/perks
|
||||
version: 4b2b341e8d7715fae06375aa633dbb6e91b3fb46
|
||||
subpackages:
|
||||
- quantile
|
||||
- name: github.com/bwmarrin/snowflake
|
||||
version: 3107b1dd8c5258a02e5f63347dc1c30288c75af5
|
||||
- name: github.com/golang/protobuf
|
||||
version: 1643683e1b54a9e88ad26d98f81400c8c9d9f4f9
|
||||
subpackages:
|
||||
- proto
|
||||
- name: github.com/matttproud/golang_protobuf_extensions
|
||||
version: c12348ce28de40eed0136aa2b644d0ee0650e56c
|
||||
subpackages:
|
||||
- pbutil
|
||||
- name: github.com/mitchellh/mapstructure
|
||||
version: f3009df150dadf309fdee4a54ed65c124afad715
|
||||
version: 3536a929edddb9a5b34bd6861dc4a9647cb459fe
|
||||
- name: github.com/nbutton23/zxcvbn-go
|
||||
version: eafdab6b0663b4b528c35975c8b0e78be6e25261
|
||||
subpackages:
|
||||
@ -16,23 +28,39 @@ imports:
|
||||
- matching
|
||||
- scoring
|
||||
- utils/math
|
||||
- name: github.com/prometheus/client_golang
|
||||
version: c5b7fccd204277076155f10851dad72b76a49317
|
||||
subpackages:
|
||||
- prometheus
|
||||
- name: github.com/prometheus/client_model
|
||||
version: fa8ad6fec33561be4280a8f0514318c79d7f6cb6
|
||||
subpackages:
|
||||
- go
|
||||
- name: github.com/prometheus/common
|
||||
version: 0d5de9d6d8629cb8bee6d4674da4127cd8b615a3
|
||||
subpackages:
|
||||
- expfmt
|
||||
- internal/bitbucket.org/ww/goautoneg
|
||||
- model
|
||||
- name: github.com/prometheus/procfs
|
||||
version: abf152e5f3e97f2fafac028d2cc06c1feb87ffa5
|
||||
- name: github.com/sergi/go-diff
|
||||
version: 1744e2970ca51c86172c8190fadad617561ed6e7
|
||||
subpackages:
|
||||
- diffmatchpatch
|
||||
- name: github.com/skratchdot/open-golang
|
||||
version: 75fb7ed4208cf72d323d7d02fd1a5964a7a9073c
|
||||
version: 79abb63cd66e41cb1473e26d11ebdcd68b04c8e5
|
||||
subpackages:
|
||||
- open
|
||||
- name: github.com/ventu-io/go-shortid
|
||||
version: 6c56cef5189ca1b3d5ef01dc07f4d611dfc0bb33
|
||||
- name: golang.org/x/crypto
|
||||
version: c197bcf24cde29d3f73c7b4ac6fd41f4384e8af6
|
||||
version: 88737f569e3a9c7ab309cdc09a07fe7fc87233c3
|
||||
subpackages:
|
||||
- bcrypt
|
||||
- blowfish
|
||||
- name: gopkg.in/mgo.v2
|
||||
version: 3f83fa5005286a7fe593b055f0d7771a7dce4655
|
||||
version: 9856a29383ce1c59f308dd1cf0363a79b5bef6b5
|
||||
subpackages:
|
||||
- bson
|
||||
- internal/json
|
||||
@ -40,14 +68,18 @@ imports:
|
||||
- internal/scram
|
||||
testImports:
|
||||
- name: github.com/davecgh/go-spew
|
||||
version: 346938d642f2ec3594ed81d874461961cd0faa76
|
||||
version: 8991bc29aa16c548c550c7ff78260e27b9ab7c73
|
||||
subpackages:
|
||||
- spew
|
||||
- name: github.com/docker/docker
|
||||
version: f5ec1e2936dcbe7b5001c2b817188b095c700c27
|
||||
subpackages:
|
||||
- pkg/testutil/assert
|
||||
- name: github.com/pmezard/go-difflib
|
||||
version: d8ed2627bdf02c080bf22230dbb337003b7aba2d
|
||||
version: 792786c7400a136282c1664665ae0a8db921c6c2
|
||||
subpackages:
|
||||
- difflib
|
||||
- name: github.com/stretchr/testify
|
||||
version: 12b6f73e6084dad08a7c6e575284b177ecafbc71
|
||||
version: ffdc059bfe9ce6a4e144ba849dbedead332c6053
|
||||
subpackages:
|
||||
- assert
|
||||
|
||||
35
persistence/metrics.go
Normal file
35
persistence/metrics.go
Normal file
@ -0,0 +1,35 @@
|
||||
package persistence
|
||||
|
||||
import "github.com/prometheus/client_golang/prometheus"
|
||||
|
||||
const (
|
||||
labelDB = "db"
|
||||
labelCollection = "collection"
|
||||
|
||||
namespace = "foomo_shop"
|
||||
subsystemService = "persistor"
|
||||
)
|
||||
|
||||
var (
|
||||
getStandardSessionCounter = prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: subsystemService,
|
||||
Name: "get_standard_session_count",
|
||||
Help: "count of standard session acquirements",
|
||||
}, []string{labelDB, labelCollection},
|
||||
)
|
||||
getGlobalSessionCounter = prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: subsystemService,
|
||||
Name: "get_global_session_count",
|
||||
Help: "count of global session acquirements",
|
||||
}, []string{labelDB, labelCollection},
|
||||
)
|
||||
)
|
||||
|
||||
func init() {
|
||||
prometheus.MustRegister(getStandardSessionCounter)
|
||||
prometheus.MustRegister(getGlobalSessionCounter)
|
||||
}
|
||||
@ -100,8 +100,15 @@ func (p *Persistor) EnsureIndexes(indexes []mgo.Index) error {
|
||||
}
|
||||
|
||||
func (p *Persistor) GetCollection() (session *mgo.Session, collection *mgo.Collection) {
|
||||
session = p.session.Clone()
|
||||
|
||||
// From the documentation of session.Clone: ..., it also means that long operations may cause other goroutines using the original session to wait.
|
||||
// Lets try using Copy here and observe the impact
|
||||
session = p.session.Copy()
|
||||
collection = session.DB(p.db).C(p.collection)
|
||||
|
||||
// increment metrics for acquiring the STANDARD session
|
||||
getStandardSessionCounter.WithLabelValues(p.db, p.collection).Inc()
|
||||
|
||||
return session, collection
|
||||
}
|
||||
|
||||
@ -112,6 +119,10 @@ func (p *Persistor) GetGlobalSessionCollection() (collection *mgo.Collection) {
|
||||
if err := p.session.Ping(); err != nil {
|
||||
p.session.Refresh()
|
||||
}
|
||||
|
||||
// increment metrics for acquiring the GLOBAL session
|
||||
getGlobalSessionCounter.WithLabelValues(p.db, p.collection).Inc()
|
||||
|
||||
return p.session.DB(p.db).C(p.collection)
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user