Skip to content

Commit 2e21f5c

Browse files
Merge pull request #1841 from cybozu/tempo-ingester-cut-to-wal-metrics
tempo: add metrics to measure duration to cut traces to wal in ingesters
2 parents 93790cd + f6e1ead commit 2e21f5c

File tree

4 files changed

+63
-4
lines changed

4 files changed

+63
-4
lines changed

tempo/.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
*
2+
!*.patch

tempo/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ ARG TEMPO_SRCREPO=grafana/tempo
77
ARG TEMPO_VERSION=2.9.0
88

99
WORKDIR /work
10-
RUN git clone --depth=1 -b v${TEMPO_VERSION} https://github.com/${TEMPO_SRCREPO}.git tempo && \
11-
cd tempo && \
12-
make tempo
10+
RUN git clone --depth=1 -b v${TEMPO_VERSION} https://github.com/${TEMPO_SRCREPO}.git tempo
11+
COPY *.patch /work
12+
RUN cd tempo && patch -p1 < ../ingester-cut-to-wal-metrics.patch
13+
RUN cd tempo && make tempo
1314

1415
# Stage2: setup runtime containers
1516
FROM ghcr.io/cybozu/ubuntu:24.04

tempo/TAG

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.9.0.1
1+
2.9.0.2
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
diff --git a/modules/ingester/flush.go b/modules/ingester/flush.go
2+
index 6db7fc8fc..8315332d4 100644
3+
--- a/modules/ingester/flush.go
4+
+++ b/modules/ingester/flush.go
5+
@@ -178,6 +178,12 @@ func (i *Ingester) cutAllInstancesToWal() {
6+
}
7+
8+
func (i *Ingester) cutOneInstanceToWal(instance *instance, immediate bool) {
9+
+ startTime := time.Now()
10+
+ defer func() {
11+
+ duration := time.Since(startTime).Seconds()
12+
+ instance.cutToWalDuration.WithLabelValues(strconv.FormatBool(immediate)).Observe(duration)
13+
+ }()
14+
+
15+
// cut traces internally
16+
err := instance.CutCompleteTraces(i.cfg.MaxTraceIdle, i.cfg.MaxTraceLive, immediate)
17+
if err != nil {
18+
diff --git a/modules/ingester/instance.go b/modules/ingester/instance.go
19+
index c324b88e6..a9478be29 100644
20+
--- a/modules/ingester/instance.go
21+
+++ b/modules/ingester/instance.go
22+
@@ -74,6 +74,19 @@ var (
23+
Name: "ingester_replay_errors_total",
24+
Help: "The total number of replay errors received per tenant.",
25+
}, []string{"tenant"})
26+
+ metricCutToWalDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{
27+
+ Namespace: "tempo",
28+
+ Name: "ingester_cut_traces_to_wal_duration_seconds",
29+
+ Help: "Time spent cutting traces to wal",
30+
+ // These buckets are configured to keep the duration shorter than 30s (flush_check_period).
31+
+ Buckets: []float64{
32+
+ 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5,
33+
+ 5.0, 6.0, 7.0, 8.0, 9.0,
34+
+ 10.0, 11.0, 12.0, 13.0, 14.0, 15.0,
35+
+ 16.0, 18.0, 20.0, 22.0, 24.0, 26.0, 28.0,
36+
+ 30.0, 35.0, 40.0, 45.0, 50.0, 55.0, 60.0,
37+
+ },
38+
+ }, []string{"tenant", "immediate"})
39+
)
40+
41+
type instance struct {
42+
@@ -94,6 +107,7 @@ type instance struct {
43+
instanceID string
44+
tracesCreatedTotal prometheus.Counter
45+
bytesReceivedTotal *prometheus.CounterVec
46+
+ cutToWalDuration prometheus.ObserverVec
47+
limiter Limiter
48+
writer tempodb.Writer
49+
50+
@@ -117,6 +131,7 @@ func newInstance(instanceID string, limiter Limiter, overrides ingesterOverrides
51+
instanceID: instanceID,
52+
tracesCreatedTotal: metricTracesCreatedTotal.WithLabelValues(instanceID),
53+
bytesReceivedTotal: metricBytesReceivedTotal,
54+
+ cutToWalDuration: metricCutToWalDuration.MustCurryWith(prometheus.Labels{"tenant": instanceID}),
55+
limiter: limiter,
56+
writer: writer,
57+

0 commit comments

Comments
 (0)