mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-13 15:14:08 +00:00
Merge pull request #4903 from cmaf/tracing-defer-rootSpan-end
runtime: tracing: End root span at end of trace
This commit is contained in:
commit
6d6edb0bb3
@ -97,9 +97,10 @@ func create(ctx context.Context, s *service, r *taskAPI.CreateTaskRequest) (*con
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create root span
|
// create root span
|
||||||
|
// rootSpan will be ended when the entire trace is ended
|
||||||
rootSpan, newCtx := katatrace.Trace(s.ctx, shimLog, "rootSpan", shimTracingTags)
|
rootSpan, newCtx := katatrace.Trace(s.ctx, shimLog, "rootSpan", shimTracingTags)
|
||||||
s.rootCtx = newCtx
|
s.rootCtx = newCtx
|
||||||
defer rootSpan.End()
|
s.rootSpan = rootSpan
|
||||||
|
|
||||||
// create span
|
// create span
|
||||||
span, newCtx := katatrace.Trace(s.rootCtx, shimLog, "create", shimTracingTags)
|
span, newCtx := katatrace.Trace(s.rootCtx, shimLog, "create", shimTracingTags)
|
||||||
|
@ -28,6 +28,7 @@ import (
|
|||||||
"github.com/opencontainers/runtime-spec/specs-go"
|
"github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
otelTrace "go.opentelemetry.io/otel/trace"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
|
||||||
"github.com/kata-containers/kata-containers/src/runtime/pkg/katautils"
|
"github.com/kata-containers/kata-containers/src/runtime/pkg/katautils"
|
||||||
@ -122,8 +123,9 @@ type exit struct {
|
|||||||
type service struct {
|
type service struct {
|
||||||
sandbox vc.VCSandbox
|
sandbox vc.VCSandbox
|
||||||
|
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
rootCtx context.Context // root context for tracing
|
rootCtx context.Context // root context for tracing
|
||||||
|
rootSpan otelTrace.Span
|
||||||
|
|
||||||
containers map[string]*container
|
containers map[string]*container
|
||||||
|
|
||||||
@ -946,6 +948,7 @@ func (s *service) Shutdown(ctx context.Context, r *taskAPI.ShutdownRequest) (_ *
|
|||||||
s.mu.Unlock()
|
s.mu.Unlock()
|
||||||
|
|
||||||
span.End()
|
span.End()
|
||||||
|
s.rootSpan.End()
|
||||||
katatrace.StopTracing(s.rootCtx)
|
katatrace.StopTracing(s.rootCtx)
|
||||||
|
|
||||||
return empty, nil
|
return empty, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user