Skip to content

feat(otel): add context propogation from containerd to the shim #827

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 30, 2025

Conversation

Mossaka
Copy link
Member

@Mossaka Mossaka commented Jan 30, 2025

this PR converts the TtrpcContext.metadata to the opentelemetry::Context and use it to propogate the parent span information to each TTRPC handler. The result of this change is that we will be able to preserve the context from containerd Task service:

image

This PR also marks all the utility functions as "Debug" level tracing instead of "Info". The functions that have "Info" tracing are listed below:

  1. Module: crates/containerd-shim-wasm/src/sandbox/cli.rs

    • shim_main_inner
  2. Module: crates/containerd-shim-wasm/src/sandbox/instance.rs

    • wait
  3. Module: crates/containerd-shim-wasm/src/sandbox/shim/cli.rs

    • new
    • start_shim
    • wait
    • create_task_service
    • delete_shim
  4. Module: crates/containerd-shim-wasm/src/sandbox/shim/local.rs

    • create
    • start
    • kill
    • delete
    • wait
    • connect
    • state
    • shutdown
    • stats
  5. Module: crates/containerd-shim-wasm/src/sys/unix/container/instance.rs

    • new
    • start
    • kill
    • delete
    • wait_timeout

jprendes
jprendes previously approved these changes Jan 30, 2025
Copy link
Collaborator

@jprendes jprendes left a comment

Choose a reason for hiding this comment

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

LGTM


#[cfg(feature = "opentelemetry")]
tracing::Span::current().set_parent(extract_context(&ctx.metadata));

Ok(self.task_create(req)?)
}

#[cfg_attr(feature = "tracing", tracing::instrument(parent = tracing::Span::current(), skip_all, level = "Info"))]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does it need parent=.. here?
Same for the other methods.

Copy link
Member Author

Choose a reason for hiding this comment

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

what do you mean by parent=...?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The parent = tracing::Span::current() inside the tracing::instrument macro.

Copy link
Member Author

Choose a reason for hiding this comment

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

okay you got a point. I will clean them up

Copy link
Collaborator

Choose a reason for hiding this comment

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

on a new PR though ^^

jprendes and others added 2 commits January 30, 2025 15:01
Signed-off-by: Jorge Prendes <[email protected]>
this is because we made all the task_{create,...} to be Debug level instead of Info

Signed-off-by: Jiaxiao (mossaka) Zhou <[email protected]>
@github-actions github-actions bot added the T-CI label Jan 30, 2025
@jprendes jprendes merged commit 56ea23f into containerd:main Jan 30, 2025
74 checks passed
@Mossaka Mossaka deleted the ctx-propogation-from-containerd branch January 30, 2025 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants