Skip to content
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

Include pod UID and container name as optional trace labels #3483

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sfleen
Copy link
Collaborator

@sfleen sfleen commented Dec 20, 2024

It's useful to include these fields in the trace span attributes to help correlate traffic within a cluster.

This propagates these labels through the trace initialization, similar to how we handle the service name (and other labels that last for the entire pod lifetime).

See linkerd/linkerd2#13501 for the corresponding control plane change.

@sfleen sfleen requested a review from a team as a code owner December 20, 2024 16:45
@cratelyn
Copy link
Collaborator

you've been clippy'ed 📎 🙀

Error: error: this function has too many arguments (8/7)
  --> linkerd/app/src/trace_collector/otel_collector.rs:21:1
   |
21 | / pub(super) fn create_collector<S>(
22 | |     addr: ControlAddr,
23 | |     hostname: Option<String>,
24 | |     pod_uid: Option<String>,
...  |
29 | |     legacy_metrics: metrics::Registry,
30 | | ) -> EnabledCollector
   | |_____________________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments
   = note: `-D clippy::too-many-arguments` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(clippy::too_many_arguments)]`

Copy link
Collaborator

@cratelyn cratelyn left a comment

Choose a reason for hiding this comment

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

besides the note about clippy lints above, this looks like a good PR to me. this should be a nice improvement to our traces!

linkerd/app/src/env.rs Show resolved Hide resolved
Copy link

codecov bot commented Dec 20, 2024

Codecov Report

Attention: Patch coverage is 7.14286% with 26 lines in your changes missing coverage. Please review.

Project coverage is 66.71%. Comparing base (96124bc) to head (89d0203).
Report is 688 commits behind head on main.

Files with missing lines Patch % Lines
linkerd/app/src/trace_collector/otel_collector.rs 0.00% 14 Missing ⚠️
linkerd/app/src/trace_collector.rs 0.00% 8 Missing ⚠️
linkerd/app/src/env.rs 33.33% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3483      +/-   ##
==========================================
- Coverage   67.68%   66.71%   -0.97%     
==========================================
  Files         332      388      +56     
  Lines       15158    18172    +3014     
==========================================
+ Hits        10259    12123    +1864     
- Misses       4899     6049    +1150     
Files with missing lines Coverage Δ
linkerd/app/src/env.rs 52.71% <33.33%> (-6.68%) ⬇️
linkerd/app/src/trace_collector.rs 25.00% <0.00%> (ø)
linkerd/app/src/trace_collector/otel_collector.rs 0.00% <0.00%> (ø)

... and 175 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 387197e...89d0203. Read the comment docs.

It's useful to include these fields in the trace span attributes to help correlate traffic within a cluster.

This propagates these labels through the trace initialization, similar to how we handle the service name (and other labels that last for the entire pod lifetime).

See linkerd/linkerd2#13501 for the corresponding control plane change.

Signed-off-by: Scott Fleener <[email protected]>
Comment on lines +269 to +270
const ENV_POD_UID: &str = "_pod_uid";
const ENV_POD_CONTAINER_NAME: &str = "_pod_containerName";
Copy link
Member

Choose a reason for hiding this comment

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

We've generally been pretty adamant (and successful) about not leaking kubernetes concepts (pods, containers, uids, etc) into the proxy's codebase.

You may notice that we load a bunch of attributes from a file at starttime:

https://github.com/linkerd/linkerd2-proxy/pull/3483/files#diff-0ee25f0088036de1851c9f218f1abb2fd0c4abecefe846112c34c6533b2267ccR840-R845

is it possible to encode these attributes into this file so the proxy doesn't need special casing for them?

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.

3 participants