Compare commits

...

5 Commits

Author SHA1 Message Date
Ludovic Fernandez
da8451c637 Prepare release v2.2.0-rc4 2020-03-19 18:10:05 +01:00
Fernandez Ludovic
f54b8d8847 Merge branch v2.1 into v2.2 2020-03-19 17:53:34 +01:00
Ludovic Fernandez
f4fb758629 Prepare release v2.1.8 2020-03-19 15:46:04 +01:00
Julien Salleyron
b40fa61783 Fix memory leak in metrics
Co-authored-by: Ludovic Fernandez <ldez@users.noreply.github.com>
2020-03-19 13:48:04 +01:00
Maxime Veber
94cd9e5337 Doc: fix wrong name of config format 2020-03-19 00:32:03 +01:00
5 changed files with 29 additions and 32 deletions

View File

@@ -1,3 +1,18 @@
## [v2.2.0-rc4](https://github.com/containous/traefik/tree/v2.2.0-rc4) (2020-03-19)
[All Commits](https://github.com/containous/traefik/compare/v2.2.0-rc3...v2.2.0-rc4)
**Documentation:**
- **[acme]** Doc: fix wrong name of config format ([#6519](https://github.com/containous/traefik/pull/6519) by [Nek-](https://github.com/Nek-))
**Misc:**
- **[middleware]** Merge current v2.1 branch into v2.2 ([#6525](https://github.com/containous/traefik/pull/6525) by [ldez](https://github.com/ldez))
## [v2.1.8](https://github.com/containous/traefik/tree/v2.1.8) (2020-03-19)
[All Commits](https://github.com/containous/traefik/compare/v2.1.7...v2.1.8)
**Bug fixes:**
- **[middleware,metrics]** Fix memory leak in metrics ([#6522](https://github.com/containous/traefik/pull/6522) by [juliens](https://github.com/juliens))
## [v2.2.0-rc3](https://github.com/containous/traefik/tree/v2.2.0-rc3) (2020-03-18)
[All Commits](https://github.com/containous/traefik/compare/v2.2.0-rc2...v2.2.0-rc3)

View File

@@ -52,7 +52,7 @@ labels:
- traefik.http.routers.blog.tls.certresolver=myresolver
```
```toml tab="Single Domain"
```toml tab="File (TOML)"
## Dynamic configuration
[http.routers]
[http.routers.blog]

View File

@@ -213,36 +213,29 @@ func (r *standardRegistry) ServiceServerUpGauge() metrics.Gauge {
// used when producing observations without explicitly setting the observed value.
type ScalableHistogram interface {
With(labelValues ...string) ScalableHistogram
StartAt(t time.Time)
Observe(v float64)
ObserveDuration()
ObserveFromStart(start time.Time)
}
// HistogramWithScale is a histogram that will convert its observed value to the specified unit.
type HistogramWithScale struct {
histogram metrics.Histogram
unit time.Duration
start time.Time
}
// With implements ScalableHistogram.
func (s *HistogramWithScale) With(labelValues ...string) ScalableHistogram {
s.histogram = s.histogram.With(labelValues...)
return s
h, _ := NewHistogramWithScale(s.histogram.With(labelValues...), s.unit)
return h
}
// StartAt implements ScalableHistogram.
func (s *HistogramWithScale) StartAt(t time.Time) {
s.start = t
}
// ObserveDuration implements ScalableHistogram.
func (s *HistogramWithScale) ObserveDuration() {
// ObserveFromStart implements ScalableHistogram.
func (s *HistogramWithScale) ObserveFromStart(start time.Time) {
if s.unit <= 0 {
return
}
d := float64(time.Since(s.start).Nanoseconds()) / float64(s.unit)
d := float64(time.Since(start).Nanoseconds()) / float64(s.unit)
if d < 0 {
d = 0
}
@@ -273,17 +266,10 @@ func NewMultiHistogram(h ...ScalableHistogram) MultiHistogram {
return MultiHistogram(h)
}
// StartAt implements ScalableHistogram.
func (h MultiHistogram) StartAt(t time.Time) {
// ObserveFromStart implements ScalableHistogram.
func (h MultiHistogram) ObserveFromStart(start time.Time) {
for _, histogram := range h {
histogram.StartAt(t)
}
}
// ObserveDuration implements ScalableHistogram.
func (h MultiHistogram) ObserveDuration() {
for _, histogram := range h {
histogram.ObserveDuration()
histogram.ObserveFromStart(start)
}
}

View File

@@ -19,9 +19,9 @@ func TestScalableHistogram(t *testing.T) {
ticker := time.NewTicker(500 * time.Millisecond)
<-ticker.C
sh.StartAt(time.Now())
start := time.Now()
<-ticker.C
sh.ObserveDuration()
sh.ObserveFromStart(start)
var b bytes.Buffer
h.Print(&b)
@@ -99,9 +99,7 @@ func (c *histogramMock) With(labelValues ...string) ScalableHistogram {
func (c *histogramMock) Start() {}
func (c *histogramMock) StartAt(t time.Time) {}
func (c *histogramMock) ObserveDuration() {}
func (c *histogramMock) ObserveFromStart(t time.Time) {}
func (c *histogramMock) Observe(v float64) {
c.lastHistogramValue = v

View File

@@ -103,11 +103,9 @@ func (m *metricsMiddleware) ServeHTTP(rw http.ResponseWriter, req *http.Request)
labels = append(labels, "code", strconv.Itoa(recorder.getCode()))
histograms := m.reqDurationHistogram.With(labels...)
histograms.StartAt(start)
histograms.ObserveFromStart(start)
m.reqsCounter.With(labels...).Add(1)
histograms.ObserveDuration()
}
func getRequestProtocol(req *http.Request) string {