Skip to content

daemon: containerCreate, containerStart: add filtered labels to OTel span#49789

Merged
vvoland merged 2 commits intomoby:masterfrom
akerouanton:trace-containerCreate-labels
Apr 11, 2025
Merged

daemon: containerCreate, containerStart: add filtered labels to OTel span#49789
vvoland merged 2 commits intomoby:masterfrom
akerouanton:trace-containerCreate-labels

Conversation

@akerouanton
Copy link
Copy Markdown
Member

@akerouanton akerouanton commented Apr 10, 2025

- What I did

First commit adds an OTel span to (*Daemon).containerCreate() with a list of filtered container labels set as OTel attributes.

Second commit adds the list of filtered container labels to the existing OTel span.

Labels are filtered based on the newly introduced env var DOCKER_OTEL_INCLUDE_CONTAINER_LABEL_ATTRS . As the code states, this env var could be dropped unceremoniously at any point in time if we figure out a better way to support that feature, or if we realize it's not needed anymore.

This is a nice-to-have to ease some internal work on Docker Desktop, but could be useful for other use cases too.

@akerouanton akerouanton added status/2-code-review kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. area/daemon Core Engine area/metrics/otel labels Apr 10, 2025
@akerouanton akerouanton self-assigned this Apr 10, 2025
@akerouanton akerouanton force-pushed the trace-containerCreate-labels branch from 1a7e867 to ab02fc6 Compare April 10, 2025 16:37
Comment thread daemon/create.go Outdated
//
// Note that, this is an experimental env var that might be removed
// unceremoniously at any point in time.
filters := strings.Split(os.Getenv("OTEL_FILTER_CONTAINER_LABELS_ATTRS"), ",")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would "DOCKER_OTEL_INCLUDE_CONTAINER_LABEL_ATTRS" be a better name? (It's a Docker variable, not generic-OTEL - and "include" is less ambiguous than "filter" which could mean "include filtered", or "filter out")?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done.

Comment thread daemon/create.go Outdated
This commit adds a new OTel span to `(*Daemon).containerCreate()` and
puts filtered container labels in the span attributes.

The filter is based on a comma-separated list of labels provided through
the `DOCKER_OTEL_INCLUDE_CONTAINER_LABEL_ATTRS` environment variable.
This label might be removed at any point in time if we figure out a
better way to filter labels, or if that span becomes unecessary.

Signed-off-by: Albin Kerouanton <[email protected]>
Like for containerCreate, filter the list of container labels based on
`DOCKER_OTEL_INCLUDE_CONTAINER_LABEL_ATTRS` and put that list in the
OTel span.

Signed-off-by: Albin Kerouanton <[email protected]>
@akerouanton akerouanton force-pushed the trace-containerCreate-labels branch from ab02fc6 to 099d3ee Compare April 10, 2025 17:12
@akerouanton akerouanton requested a review from robmry April 10, 2025 17:16
Copy link
Copy Markdown
Contributor

@robmry robmry left a comment

Choose a reason for hiding this comment

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

A "SOMETHING_FILTER" might still be an allow or deny list, but ok! Thank you for the changes. (The PR description needs a matching update though.)

@vvoland vvoland added this to the 28.1.0 milestone Apr 11, 2025
@vvoland vvoland merged commit cdad178 into moby:master Apr 11, 2025
150 checks passed
@akerouanton akerouanton deleted the trace-containerCreate-labels branch April 11, 2025 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/daemon Core Engine area/metrics/otel kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants