Skip to content

Commit

Permalink
pkge/receive: trace TSDB ingestion (#2384)
Browse files Browse the repository at this point in the history
This commit adds a tracing span around the writing of remote-write
requests into TSDB. This will help us differentiate between the
latencies in the forwarding of requests around the hashring and the
latencies of appending to the database.

This commit also removes the `thanos_` prefix from the forwarding span
to better align with the span naming in the rest of the project.

Signed-off-by: Lucas Servén Marín <[email protected]>
  • Loading branch information
squat authored Apr 6, 2020
1 parent cc6c5b5 commit e75979f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/receive/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,11 @@ func (h *Handler) parallelizeRequests(ctx context.Context, tenant string, replic
if h.writer == nil {
err = errors.New("storage is not ready")
} else {
err = h.writer.Write(wreqs[endpoint])
// Create a span to track writing the request into TSDB.
tracing.DoInSpan(ctx, "receive_tsdb_write", func(ctx context.Context) {

err = h.writer.Write(wreqs[endpoint])
})
// When a MultiError is added to another MultiError, the error slices are concatenated, not nested.
// To avoid breaking the counting logic, we need to flatten the error.
if errs, ok := err.(terrors.MultiError); ok {
Expand Down Expand Up @@ -402,7 +406,7 @@ func (h *Handler) parallelizeRequests(ctx context.Context, tenant string, replic
return
}
// Create a span to track the request made to another receive node.
tracing.DoInSpan(ctx, "thanos_receive_forward", func(ctx context.Context) {
tracing.DoInSpan(ctx, "receive_forward", func(ctx context.Context) {
// Actually make the request against the endpoint
// we determined should handle these time series.
_, err = cl.RemoteWrite(ctx, &storepb.WriteRequest{
Expand Down
1 change: 1 addition & 0 deletions pkg/receive/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/storage"
terrors "github.com/prometheus/prometheus/tsdb/errors"

"github.com/thanos-io/thanos/pkg/store/storepb/prompb"
)

Expand Down

0 comments on commit e75979f

Please sign in to comment.