tracing: Add sandbox and container ID to trace spans

Add sandbox, container, and hypervisor IDs to trace spans. Note that
some spans in sandbox.go are created with a trace() call from api.go.
These spans have additional attributes set after span creation to
overwrite the api attributes.

Fixes #1878

Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com>
This commit is contained in:
Chelsea Mafrica
2021-06-01 13:42:00 -07:00
parent 1673110ee9
commit 8ca0207281
7 changed files with 11 additions and 8 deletions

View File

@@ -360,7 +360,7 @@ func (c *Container) trace(parent context.Context, name string) (otelTrace.Span,
}
tracer := otel.Tracer("kata")
ctx, span := tracer.Start(parent, name, otelTrace.WithAttributes(otelLabel.String("source", "runtime"), otelLabel.String("package", "virtcontainers"), otelLabel.String("subsystem", "container")))
ctx, span := tracer.Start(parent, name, otelTrace.WithAttributes(otelLabel.String("source", "runtime"), otelLabel.String("package", "virtcontainers"), otelLabel.String("subsystem", "container"), otelLabel.String("container_id", c.id)))
return span, ctx
}