Skip to content

cri/tracing: introduce Phase 1 lifecycle tracing MVP - #12226

Closed
Cindia-blue wants to merge 1 commit into
containerd:mainfrom
Cindia-blue:tracing-poc
Closed

Cindia-blue wants to merge 1 commit into
containerd:mainfrom
Cindia-blue:tracing-poc

Conversation

@Cindia-blue

Copy link
Copy Markdown
Contributor

This commit proposes a standardized tracing API for containerd CRI
entry points to improve observability of container lifecycle operations.

Highlights:

  • Centralized tracing interfaces under pkg/tracing
  • Configurable sampling and exporter support (otlp, zipkin, file)
  • Standard CRI span names and attribute constants
  • Initial instrumentation for container, sandbox, image, and
    internal operations (CNI, snapshotter, runtime tasks, mounts)
  • File exporter implementation for local debugging

Phase 1 focuses on CRI operations with low overhead and clean
abstractions, providing a foundation for future extensions (CNI,
image service, runtime).

@k8s-ci-robot

Copy link
Copy Markdown

Hi @Cindia-blue. Thanks for your PR.

I'm waiting for a containerd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@dosubot dosubot Bot added area/cri Container Runtime Interface (CRI) kind/feature labels Aug 21, 2025
@Cindia-blue
Cindia-blue force-pushed the tracing-poc branch 21 times, most recently from 9732623 to 1814d20 Compare August 27, 2025 05:27
Comment thread internal/cri/config/config.go Resolved
Comment thread internal/cri/config/tracing.go Resolved
Comment thread client/pull.go Resolved
Comment thread client/pull.go Resolved
Comment thread client/task.go Resolved
Comment thread pkg/tracing/tracing.go Resolved
Comment thread internal/cri/server/service.go Resolved
Comment thread pkg/tracing/manager/manager.go Resolved

@fuweid fuweid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a new feature, but it includes some refactoring changes that aren’t necessary for this update. I’ve left several comments about this — please remove the unnecessary refactoring changes.

For new exporters, please add unit tests for them.

Comment thread client/pull.go Outdated
}

defer func() {
if unpacker == nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in order to keep it as simple as possible in first patch, we can handle this in that follow-up.

Comment thread client/task.go
}
return
}
c <- ExitStatus{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like it's not relevant. please revert it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

recovered

Comment thread client/task.go Outdated
ctx, span := tracing.StartSpan(ctx, tracing.Name("client.task", "Start"),
tracing.WithAttribute("task.id", t.ID()))
defer span.End()
if ns, err := namespaces.NamespaceRequired(ctx); err == nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this for CRI. CRI are using that fixed namespace - k8s.io - in containerd.

Comment thread client/pull.go Outdated

span.SetAttributes(
tracing.Attribute("image.ref", ref),
tracing.Attribute(tracing.AttrImageRef, ref),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can skip this refactor in your change, as there are many attribute names that currently don’t have corresponding constant variables.

Comment thread client/pull.go Outdated
return nil, fmt.Errorf("unable to resolve snapshotter: %w", err)
}
span.SetAttributes(tracing.Attribute("snapshotter.name", snapshotterName))
span.SetAttributes(tracing.Attribute(tracing.AttrSnapshotter, snapshotterName))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep that name as it is: using snapshotter.name

Comment thread internal/cri/server/service.go Outdated
return nil
}

log.L.Infof("Initializing tracing with config: Enabled=%v, SamplingRate=%f",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
log.L.Infof("Initializing tracing with config: Enabled=%v, SamplingRate=%f",
log.L.Infof("Initializing tracing with config: SamplingRate=%f",

It's already enabled.

Comment thread pkg/tracing/tracing.go Outdated
}

// GetSandboxIDResolverForExport returns the resolver for use by exporters.
func GetSandboxIDResolverForExport() func(map[string]interface{}) (string, bool) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this function used in somewhere ?

Comment thread internal/cri/server/sandbox_run.go Outdated
// Add sandbox attributes to span
span.SetAttributes(
tracing.Attribute("sandbox.id", id),
tracing.Attribute(tracing.AttrSandboxID, id),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep it as it's: using sandbox.id

return "", false
}

tracing.SetSandboxIDResolver(resolver)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this function?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we do need it here to ensure trace context completeness when it’s missing.

Comment thread pkg/tracing/enhanced/tracer.go Outdated
}
}
if len(errs) > 0 {
return fmt.Errorf("multiple errors during shutdown: %v", errs)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return fmt.Errorf("multiple errors during shutdown: %v", errs)
return fmt.Errorf("multiple errors during shutdown: %w", errors.Join(errs))

Comment thread client/pull.go Resolved
@fuweid

fuweid commented Nov 6, 2025

Copy link
Copy Markdown
Member

@Cindia-blue could you please use rebase instead of merge? and also, please squash into few commits. thanks!

@Cindia-blue

Cindia-blue commented Nov 8, 2025 via email

Copy link
Copy Markdown
Contributor Author

@Cindia-blue

Copy link
Copy Markdown
Contributor Author

@Cindia-blue could you please use rebase instead of merge? and also, please squash into few commits. thanks!

done

@k8s-ci-robot

Copy link
Copy Markdown

PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open 90 days with no activity. This PR will be closed in 7 days unless new comments are made or the stale label is removed.

@samuelkarp

Copy link
Copy Markdown
Member

@Cindia-blue Are you still intending to contribute here? Looks like this PR needs to be rebased if so.

@Cindia-blue

Cindia-blue commented Mar 11, 2026 via email

Copy link
Copy Markdown
Contributor Author

@samuelkarp

Copy link
Copy Markdown
Member

Looks like this still needs a rebase.

@Cindia-blue

Copy link
Copy Markdown
Contributor Author

Closing the loop on this older proposal: the focused tracing changes were split out and merged in #12628, #12737, and #13959. I am retiring this broad PR rather than rebasing the remaining custom tracing manager/exporter/configuration framework. This PR itself has not been merged, and those three smaller PRs do not imply acceptance of the full framework. Thank you @fuweid, @estesp, and @samuelkarp for the review and guidance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants