Skip to content

Commit

Permalink
Set span tags to help debug
Browse files Browse the repository at this point in the history
Signed-off-by: Douglas Camata <[email protected]>
  • Loading branch information
douglascamata committed Jan 10, 2024
1 parent d389410 commit 2bd869b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/receive/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,8 @@ func (h *Handler) sendRemoteWrite(
}

span, spanCtx := tracing.StartSpan(ctx, "receive_forward")
span.SetTag("endpoint", endpointReplica.endpoint)
span.SetTag("replica", endpointReplica.replica+1)
// Actually make the request against the endpoint we determined should handle these time series.
_, err = cl.RemoteWrite(spanCtx, &storepb.WriteRequest{
Timeseries: trackedSeries.timeSeries,
Expand All @@ -867,8 +869,9 @@ func (h *Handler) sendRemoteWrite(
Replica: int64(endpointReplica.replica + 1),
})
level.Debug(h.logger).Log("msg", "wrote to remote tsdb", "origin", h.options.Endpoint, "endpoint", fmt.Sprintf("%v", endpointReplica), "err", err)
span.Finish()
if err != nil {
span.SetTag("error", true)
span.SetTag("error.msg", err.Error())
// Check if peer connection is unavailable, update the peer state to avoid spamming that peer.
if st, ok := status.FromError(err); ok {
if st.Code() == codes.Unavailable {
Expand All @@ -882,6 +885,7 @@ func (h *Handler) sendRemoteWrite(
responses <- newWriteResponse(trackedSeries.seriesIDs, err)
return
}
span.Finish()
h.forwardRequests.WithLabelValues(labelSuccess).Inc()
if !alreadyReplicated {
h.replications.WithLabelValues(labelSuccess).Inc()
Expand Down

0 comments on commit 2bd869b

Please sign in to comment.