-
Notifications
You must be signed in to change notification settings - Fork 532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pusher failed to consume trace data due to "context canceled" #3957
Comments
Thank you for the very detailed issue. Please don't switch to Jaeger ;).
100%. I think this is a great idea and would love a PR.
Yes. I have mostly recently felt this pain the frontend/read path.
Thank you for digging so deep. This is impressive research and a great contribution to the project.
I don't have a good answer for this either. Perhaps we can log the cancel cause (added in go 1.20): I don't think much uses this yet but we could slowly add causes in our code. Also presumably go will also add causes to the framework. Perhaps this will grow in value over time? |
…ns causing issues. ```yaml distributor: config: log_discarded_spans: enabled: true log_received_spans: # ... ``` Relates to grafana#3957. Signed-off-by: Daniel Strobusch <[email protected]>
…ns causing issues. ```yaml distributor: config: log_discarded_spans: enabled: true log_received_spans: # ... ``` Relates to grafana#3957. Signed-off-by: Daniel Strobusch <[email protected]>
…ns causing issues. ```yaml distributor: config: log_discarded_spans: enabled: true log_received_spans: # ... ``` Relates to grafana#3957. Signed-off-by: Daniel Strobusch <[email protected]>
…ns causing issues. ```yaml distributor: config: log_discarded_spans: enabled: true log_received_spans: # ... ``` Relates to grafana#3957. Signed-off-by: Daniel Strobusch <[email protected]>
…ns causing issues. ```yaml distributor: config: log_discarded_spans: enabled: true log_received_spans: # ... ``` Relates to grafana#3957. Signed-off-by: Daniel Strobusch <[email protected]>
@joe-elliott, thanks for your feedback.
See #3964 – it took a few days to get it right (hopefully).
True, but for the particular case I encountered, we would need to convince the google.golang.org/grpc team to add this. Nevertheless, I'd second adding a cause to all Tempo internal context cancellations in some cases. |
…ns causing issues. ```yaml distributor: config: log_discarded_spans: enabled: true log_received_spans: # ... ``` Relates to grafana#3957. Signed-off-by: Daniel Strobusch <[email protected]>
The grpc team is considering to add the cancel cause, see grpc/grpc-go#7541 (comment). |
…ns causing issues. ```yaml distributor: config: log_discarded_spans: enabled: true log_received_spans: # ... ``` Relates to grafana#3957. Signed-off-by: Daniel Strobusch <[email protected]>
…ns causing issues. ```yaml distributor: config: log_discarded_spans: enabled: true log_received_spans: # ... ``` Relates to grafana#3957. Signed-off-by: Daniel Strobusch <[email protected]>
…ns causing issues. ```yaml distributor: config: log_discarded_spans: enabled: true log_received_spans: # ... ``` Relates to grafana#3957. Signed-off-by: Daniel Strobusch <[email protected]>
…ns causing issues. ```yaml distributor: config: log_discarded_spans: enabled: true log_received_spans: # ... ``` Relates to grafana#3957. Signed-off-by: Daniel Strobusch <[email protected]>
…ns causing issues. ```yaml distributor: config: log_discarded_spans: enabled: true log_received_spans: # ... ``` Relates to grafana#3957. Signed-off-by: Daniel Strobusch <[email protected]>
Found another issue, which would need to be fixed to get the cancel cause reported. batch.go would need bo the changed: case <-ctx.Done():
- return ctx.Err()
+ return context.Cause(ctx)
} When I find time, I might open an issue/PR to https://github.com/grafana/dskit. |
…ns causing issues. (#3964) ```yaml distributor: config: log_discarded_spans: enabled: true log_received_spans: # ... ``` Relates to #3957. Signed-off-by: Daniel Strobusch <[email protected]>
@joe-elliott I created grafana/dskit#576 and grafana/dskit#577 in dskit. But I am not sure if there is a process to encourage someone to look at it. |
This issue has been automatically marked as stale because it has not had any activity in the past 60 days. |
remove stale. Open tasks:
|
It looks like the gRPC team is not convinced by the use of context cancel causes. If you or someone from the Tempo team wishes, you might want to step into the discussion at grpc/grpc-go#7541. I personally will probably not be able to invest much more time, as I see the proposal as not very likely to be accepted. I personally think that adding cancel causes everywhere would be a nice non-breaking improvement for gRPC, Tempo, and other packages. I would love to see cancel causes in the Tempo codebase as well in the future. It was a pleasure to contribute to Grafana Tempo on this topic, and I value the open and constructive culture of the Tempo team very much. |
Thx for the kind words @dastrobu. We appreciate your contributions to Tempo and the wider go and OSS community. Reviewing the linked thread, you've made some great arguments and I doubt I have anything to add. Agree 100% that cancel cause is a great addition to go and we should use it as much as possible. Thank you for all your work! |
Is your feature request related to a problem? Please describe.
We encountered the log message
msg="pusher failed to consume trace data" err="context canceled"
and had significant difficulty identifying the cause. The root cause was not related to the reasons documented in the troubleshooting guide.The metric
tempo_discarded_spans_total
indicated that spans were being discarded, but the logs did not clarify the reason.We ended up patching Grafana Tempo and even the Go SDK to gather more information about the discarded spans. I would like to propose improvements to observability in this area.
Here is what we did:
Additional Logging in Distributor
We added extra logging to distributor.go to identify which spans were causing issues:
I propose adding a
LogDiscardedSpansConfig
in addition toLogReceivedSpansConfig
to log discarded spans that are causing issues. I can open a PR for this if you think it is a good idea.Context Cancellation Debugging
It was extremely challenging to determine why the
Context
was canceled. This is a weak spot in Go, in my opinion. We had to patch the Go SDK to get more information about context cancellation.We added stack traces to context.go:
This led to the following logs:
As you can see, the context was closed due to an RST frame sent by the client. See
handleRSTStream
andcloseStream
.Therefore, Grafana Tempo is behaving correctly, but it was extremely difficult to determine why the context was canceled.
Confusing Metric Labels
The discarded spans are added to the
tempo_discarded_spans_total
metric with the reasonreasonInternalError
: distributor.go#L440, which was also confusing.Describe the solution you'd like
I propose two improvements:
LogDiscardedSpansConfig
to the distributor to log discarded spans causing issues.tempo_discarded_spans_total
to indicate when the client's fault causes traces to be discarded. I am unsure how to implement this, though.Describe alternatives you've considered
Switching to Jaeger 😉.
Additional context
Grafana was deployed using the tempo-distributed Helm chart.
The text was updated successfully, but these errors were encountered: