Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new compactor_objects_combined metric and test #339

Merged
merged 7 commits into from
Nov 13, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## master / unreleased

* [ENHANCEMENT] Add compaction_traces_combined_total metric. [#339](https://github.com/grafana/tempo/pull/339)
mdisibio marked this conversation as resolved.
Show resolved Hide resolved
* [BUGFIX] Frequent errors logged by compactor regarding meta not found [#327](https://github.com/grafana/tempo/pull/327)

## v0.3.0
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ require (
github.com/opentracing/opentracing-go v1.2.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.7.1
github.com/prometheus/client_model v0.2.0
github.com/prometheus/common v0.11.1
github.com/prometheus/prometheus v1.8.2-0.20200722151933-4a8531a64b32
github.com/sirupsen/logrus v1.6.0
Expand Down
6 changes: 6 additions & 0 deletions tempodb/compactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ var (
Name: "compaction_errors_total",
Help: "Total number of errors occurring during compaction.",
})
metricCompactionTracesCombined = promauto.NewCounter(prometheus.CounterOpts{
mdisibio marked this conversation as resolved.
Show resolved Hide resolved
Namespace: "tempodb",
Name: "compaction_traces_combined_total",
Help: "Total number of traces combined during compaction.",
})
)

const (
Expand Down Expand Up @@ -154,6 +159,7 @@ func (rw *readerWriter) compact(blockMetas []*encoding.BlockMeta, tenantID strin
if bytes.Equal(currentID, lowestID) {
lowestObject = rw.compactorSharder.Combine(currentObject, lowestObject)
b.clear()
metricCompactionTracesCombined.Inc()
} else if len(lowestID) == 0 || bytes.Compare(currentID, lowestID) == -1 {
lowestID = currentID
lowestObject = currentObject
Expand Down
19 changes: 19 additions & 0 deletions tempodb/compactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import (
"github.com/grafana/tempo/tempodb/encoding"
"github.com/grafana/tempo/tempodb/pool"
"github.com/grafana/tempo/tempodb/wal"
"github.com/prometheus/client_golang/prometheus"

dto "github.com/prometheus/client_model/go"
)

type mockSharder struct {
Expand Down Expand Up @@ -219,6 +222,9 @@ func TestSameIDCompaction(t *testing.T) {

rw := r.(*readerWriter)

tracesCombinedStart, err := GetCounterValue(metricCompactionTracesCombined)
assert.NoError(t, err)

// poll
checkBlocklists(t, uuid.Nil, blockCount, 0, rw)

Expand All @@ -239,6 +245,19 @@ func TestSameIDCompaction(t *testing.T) {
records += meta.TotalObjects
}
assert.Equal(t, blockCount-blocksPerCompaction, records)

tracesCombinedFinish, err := GetCounterValue(metricCompactionTracesCombined)
assert.NoError(t, err)
assert.Equal(t, float64(1), tracesCombinedFinish-tracesCombinedStart)
}

func GetCounterValue(metric prometheus.Counter) (float64, error) {
var m = &dto.Metric{}
err := metric.Write(m)
if err != nil {
return 0, err
}
return m.Counter.GetValue(), nil
}

func TestCompactionUpdatesBlocklist(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,7 @@ github.com/prometheus/client_golang/prometheus/promauto
github.com/prometheus/client_golang/prometheus/promhttp
github.com/prometheus/client_golang/prometheus/push
# github.com/prometheus/client_model v0.2.0
## explicit
mdisibio marked this conversation as resolved.
Show resolved Hide resolved
github.com/prometheus/client_model/go
# github.com/prometheus/common v0.11.1
## explicit
Expand Down