mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 20:56:42 +00:00
fix issue where span status wasn't properly passed to parents
This commit is contained in:
parent
70eda41f39
commit
c50d3e6cea
1 changed files with 9 additions and 1 deletions
|
|
@ -32,6 +32,7 @@ import (
|
|||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
sdktrace "go.opentelemetry.io/otel/sdk/trace"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.24.0"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
|
@ -614,11 +615,18 @@ func (h *handler) startSpan(ctx context.Context, msg *jsonrpcMessage, spanName s
|
|||
|
||||
// Define the function to end the span and handle error recording
|
||||
spanEnd := func(err *error) {
|
||||
ro, _ := span.(sdktrace.ReadOnlySpan)
|
||||
if *err != nil {
|
||||
// Error occurred, record it and set status on span and parent
|
||||
span.RecordError(*err)
|
||||
span.SetStatus(codes.Error, (*err).Error())
|
||||
parentSpan.SetStatus(codes.Error, (*err).Error())
|
||||
} else {
|
||||
} else if ro.Status().Code == codes.Error {
|
||||
// Span's child had an error, propagate it to parent
|
||||
// Note: Span's status was already set in the child
|
||||
parentSpan.SetStatus(codes.Error, ro.Status().Description)
|
||||
} else if ro.Status().Code == codes.Unset {
|
||||
// No error and no status set, mark as success
|
||||
span.SetStatus(codes.Ok, "")
|
||||
}
|
||||
span.End()
|
||||
|
|
|
|||
Loading…
Reference in a new issue