From 2bd869b2a728786224ccfe41fc555e362f39b08c Mon Sep 17 00:00:00 2001 From: Douglas Camata <159076+douglascamata@users.noreply.github.com> Date: Wed, 10 Jan 2024 20:40:51 +0100 Subject: [PATCH] Set span tags to help debug Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> --- pkg/receive/handler.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/receive/handler.go b/pkg/receive/handler.go index ec95df69b9..76b53aa91f 100644 --- a/pkg/receive/handler.go +++ b/pkg/receive/handler.go @@ -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, @@ -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 { @@ -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()