Skip to content

Commit

Permalink
feat: trace each resource
Browse files Browse the repository at this point in the history
Co-authored-by: Kim Tore Jensen <kimtjen@gmail.com>
  • Loading branch information
Kyrremann and kimtore committed Sep 10, 2024
1 parent 878e19f commit 6ba5367
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/deployd/deployd/deployd.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func Run(op *operation.Operation, client kubeclient.Interface) {
op.Logger.Infof("Starting deployment")

ctx := telemetry.WithTraceParent(op.Context, op.Request.TraceParent)
ctx, span := telemetry.Tracer().Start(ctx, "Deploy to Kubernetes")
ctx, rootSpan := telemetry.Tracer().Start(ctx, "Deploy to Kubernetes")

failure := func(err error) {
op.Cancel()
Expand All @@ -42,14 +42,14 @@ func Run(op *operation.Operation, client kubeclient.Interface) {
err := ctx.Err()
if err != nil {
failure(err)
span.End()
rootSpan.End()
return
}

resources, err := op.ExtractResources()
if err != nil {
failure(err)
span.End()
rootSpan.End()
return
}

Expand Down Expand Up @@ -84,6 +84,7 @@ func Run(op *operation.Operation, client kubeclient.Interface) {
wait.Add(1)

go func(logger *log.Entry, resource unstructured.Unstructured) {
_, resourceSpan := telemetry.Tracer().Start(ctx, fmt.Sprintf("%s/%s", identifier.Kind, identifier.Name))
deadline, _ := ctx.Deadline()
op.Logger.Debugf("Monitoring rollout status of '%s/%s' in namespace '%s', deadline %s", identifier.GroupVersionKind, identifier.Name, identifier.Namespace, deadline)
strat := strategy.NewWatchStrategy(identifier.GroupVersionKind, client)
Expand All @@ -101,6 +102,7 @@ func Run(op *operation.Operation, client kubeclient.Interface) {

op.Logger.Debugf("Finished monitoring rollout status of '%s/%s' in namespace '%s'", identifier.GroupVersionKind, identifier.Name, identifier.Namespace)
wait.Done()
resourceSpan.End()
}(logger, resource)
}

Expand All @@ -121,6 +123,6 @@ func Run(op *operation.Operation, client kubeclient.Interface) {
op.StatusChan <- pb.NewSuccessStatus(op.Request)
}

span.End()
rootSpan.End()
}()
}

0 comments on commit 6ba5367

Please sign in to comment.