Skip to content

Commit 51891c3

Browse files
authored
Set dedup and pushback labels on all add metrics (transparency-dev#598)
1 parent 8463536 commit 51891c3

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

append_lifecycle.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -334,22 +334,24 @@ func (i *integrationStats) statsDecorator(delegate AddFn) AddFn {
334334
idx, err := f()
335335
attr := []attribute.KeyValue{}
336336
if err != nil {
337-
if err == ErrPushback {
338-
attr = append(attr, attribute.Bool("tessera.pushback", true))
339-
} else {
337+
if err != ErrPushback {
340338
// Just flag that it's an errored request to avoid high cardinality of attribute values.
341339
// TODO(al): We might want to bucket errors into OTel status codes in the future, though.
342340
attr = append(attr, attribute.String("tessera.error.type", "_OTHER"))
343341
}
344342
}
345-
if idx.IsDup {
346-
attr = append(attr, attribute.Bool("tessera.duplicate", true))
347-
} else {
348-
i.sample(idx.Index)
349-
}
343+
344+
attr = append(attr, attribute.Bool("tessera.pushback", err == ErrPushback))
345+
attr = append(attr, attribute.Bool("tessera.duplicate", idx.IsDup))
346+
350347
appenderAddsTotal.Add(ctx, 1, metric.WithAttributes(attr...))
351348
d := time.Since(start)
352349
appenderAddHistogram.Record(ctx, d.Milliseconds(), metric.WithAttributes(attr...))
350+
351+
if !idx.IsDup {
352+
i.sample(idx.Index)
353+
}
354+
353355
return idx, err
354356
}
355357
}

0 commit comments

Comments
 (0)