Skip to content

migrate containerd/pkg/tracing - #24

Open
thaJeztah wants to merge 11 commits into
containerd:mainfrom
thaJeztah:integrate_tracing
Open

migrate containerd/pkg/tracing#24
thaJeztah wants to merge 11 commits into
containerd:mainfrom
thaJeztah:integrate_tracing

Conversation

@thaJeztah

@thaJeztah thaJeztah commented Aug 23, 2026

Copy link
Copy Markdown
Member

migrate containerd/pkg/tracing

This migrates the log-related code from github.com/containerd/containerd/v2/pkg/tracing

Code was taken at this commit https://github.com/containerd/containerd/commits/e6618451086f9656872427ee17f49433436e2a40/pkg/tracing

Strategy taken:

# install filter-repo (https://github.com/newren/git-filter-repo/blob/main/INSTALL.md)
brew install git-filter-repo

cd ~/projects

# create a temporary clone of docker
git clone https://github.com/containerd/containerd.git tmp_tracing
cd tmp_tracing

git rev-parse HEAD
e6618451086f9656872427ee17f49433436e2a40

# remove all code, except for pkg/tracing, and rename to /otel
git filter-repo \
    --path tracing/helpers.go \
    --path tracing/log.go \
    --path tracing/log_test.go \
    --path pkg/tracing/helpers.go \
    --path pkg/tracing/helpers_test.go \
    --path pkg/tracing/log.go \
    --path pkg/tracing/log_test.go \
    --path-rename tracing/:otel/ \
    --path-rename pkg/tracing/:otel/ \
    --prune-empty always \
    --prune-degenerate always

# go to the target github.com/containerd/log repository
cd ~/projects/log

# create a branch to work with
git checkout -b integrate_tracing

# add the temporary repository as an upstream and make sure it's up-to-date
git remote add tmp_tracing ~/projects/tmp_tracing
git fetch --no-tags tmp_tracing main

# merge the upstream code
git merge --allow-unrelated-histories --signoff -S tmp_tracing/main

otel: fix imports, remove testify, add go.mod

Make the otel package a separate module, so that containerd/log
does not inherit the otel dependencies.

cpuguy83 and others added 9 commits September 21, 2021 21:19
This adds valuable logging data to the open telemetry traces.

When the trace is not recording we don't bother doing anything as it is
relatively expensive to convert logrus data to otel just due to the
nature of how logrus works.

The way this works is that we now set a context on the logrus.Entry that
gets passed around which the hook then uses to determine if there is an
active span to forward the logs to.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This fixes the issue with the usage of the deprecated attribute.Any
function that original caused build issues.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Signed-off-by: Swagat Bora <sbora@amazon.com>
Signed-off-by: Swagat Bora <sbora@amazon.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
While the hook is intended to be used with logrus, we don't need to have
the direct import; use the aliases provided by the containerd/log module
instead.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Check span.IsRecording first, as it's a more lightweight check than
span.SpanContext().IsValid()

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Introduce functional options to NewLogrusHook to allow optional Trace ID
injection into log fields. This enables log-trace correlation via the
[debug] config without breaking existing external consumers of
pkg/tracing.

Signed-off-by: Hasan Siddiqui <hasiddiqui@google.com>
Log fields which contain an error currently fall through to JSON
marshaling, which may produce an unhelpful value such as "{}" instead
of the error message.

Handle error values explicitly and use fmt.Sprint when formatting error
and fmt.Stringer values. Besides preserving their textual
representation, fmt handles typed-nil implementations without
propagating a panic from their Error or String method.

Also simplify the final fmt.Sprintf("%v", v) fallback to fmt.Sprint(v).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah

This comment was marked as resolved.

This migrates the log-related code from github.com/containerd/containerd/v2/pkg/tracing

Code was taken at this commit https://github.com/containerd/containerd/commits/e6618451086f9656872427ee17f49433436e2a40/pkg/tracing

Strategy taken:

    # install filter-repo (https://github.com/newren/git-filter-repo/blob/main/INSTALL.md)
    brew install git-filter-repo

    cd ~/projects

    # create a temporary clone of docker
    git clone https://github.com/containerd/containerd.git tmp_tracing
    cd tmp_tracing

    git rev-parse HEAD
    e6618451086f9656872427ee17f49433436e2a40

    # remove all code, except for pkg/tracing, and rename to /otel
    git filter-repo \
        --path tracing/helpers.go \
        --path tracing/log.go \
        --path tracing/log_test.go \
        --path pkg/tracing/helpers.go \
        --path pkg/tracing/helpers_test.go \
        --path pkg/tracing/log.go \
        --path pkg/tracing/log_test.go \
        --path-rename tracing/:otel/ \
        --path-rename pkg/tracing/:otel/ \
        --prune-empty always \
        --prune-degenerate always

    # go to the target github.com/containerd/log repository
    cd ~/projects/log

    # create a branch to work with
    git checkout -b integrate_tracing

    # add the temporary repository as an upstream and make sure it's up-to-date
    git remote add tmp_tracing ~/projects/tmp_tracing
    git fetch --no-tags tmp_tracing main

    # merge the upstream code
    git merge --allow-unrelated-histories --signoff -S tmp_tracing/main

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Make the otel package a separate module, so that containerd/log
does not inherit the otel dependencies.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah

Copy link
Copy Markdown
Member Author

@dmcgowan @cpuguy83 ptal - if this looks good, I can make deprecated the ones in containerd itself, and make them wrappers;

@dmcgowan
dmcgowan requested a review from cpuguy83 August 27, 2026 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants