tracing: Make runtime span attributes more consistent

Span attributes (tags) are not consistent in runtime tracing, so
designate and use core attributes such source, package, subsystem, and
type as span metadata for more understandable output.

Use WithAttributes() during span creation to reduce calls to
SetAttributes().

Modify Trace() in katautils to accept slice of attributes so multiple
functions using different attributes can use it.

Fixes #1852

Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com>
This commit is contained in:
Chelsea Mafrica
2021-05-14 14:39:21 -07:00
parent 35f297ad50
commit 05a46fede0
15 changed files with 21 additions and 41 deletions

View File

@@ -30,11 +30,7 @@ var virtLog = logrus.WithField("source", "virtcontainers")
// context.
func trace(parent context.Context, name string) (otelTrace.Span, context.Context) {
tracer := otel.Tracer("kata")
ctx, span := tracer.Start(parent, name)
span.SetAttributes([]label.KeyValue{
label.Key("source").String("virtcontainers"),
label.Key("component").String("virtcontainers"),
label.Key("subsystem").String("api")}...)
ctx, span := tracer.Start(parent, name, otelTrace.WithAttributes(label.String("source", "runtime"), label.String("packages", "virtcontainers"), label.String("subsystem", "api")))
return span, ctx
}