Add tracing spans in CRI image service and pull.go
Signed-off-by: Swagat Bora <sbora@amazon.com> Add spans around image unpack operations Use image.ref to denote image name and image.id for the image config digest Add top-level spand and record errors in the CRI instrumentation service
This commit is contained in:
@@ -20,6 +20,7 @@ import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
@@ -35,3 +36,19 @@ func StartSpan(ctx context.Context, opName string, opts ...trace.SpanStartOption
|
||||
func StopSpan(span trace.Span) {
|
||||
span.End()
|
||||
}
|
||||
|
||||
// CurrentSpan returns current span from context or noopSpan if no span exists.
|
||||
func CurrentSpan(ctx context.Context) trace.Span {
|
||||
return trace.SpanFromContext(ctx)
|
||||
}
|
||||
|
||||
// SetSpanStatus sets the status of the current span.
|
||||
// If an error is encountered, it records the error and sets span status to Error.
|
||||
func SetSpanStatus(span trace.Span, err error) {
|
||||
if err != nil {
|
||||
span.RecordError(err)
|
||||
span.SetStatus(codes.Error, err.Error())
|
||||
} else {
|
||||
span.SetStatus(codes.Ok, "")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user