Skip to content

[27.x backport] otel: Avoid excessive memory allocations if not configured#49079

Merged
thaJeztah merged 3 commits intomoby:27.xfrom
vvoland:49078-27.x
Dec 12, 2024
Merged

[27.x backport] otel: Avoid excessive memory allocations if not configured#49079
thaJeztah merged 3 commits intomoby:27.xfrom
vvoland:49078-27.x

Conversation

@vvoland
Copy link
Copy Markdown
Contributor

@vvoland vvoland commented Dec 12, 2024

Use noop tracer provider if the OTEL exporter is not configured. This makes the OTEL tracing avoid doing unneeded memory allocations for spans which aren't going to be exported anywhere anyway.

- How to verify it

#!/bin/sh

docker run -d --rm -it --name leak alpine sh -c 'while true; do date; done'

for i in $(seq 0 4); do
    docker logs -f leak >/dev/null &
done


watch -d ps -C dockerd -o rss=

docker rm -f leak

wait

Before this patch, the RSS grows significantly over time, in proportion to the amount of running docker logs -f.
After the patch, the RSS stays around the same level.

- Description for the changelog

Fix excessive memory allocations when OTEL is not configured.

- A picture of a cute animal (not mandatory but encouraged)

Use noop tracer provider if the OTEL exporter is not configured.
This makes the OTEL tracing avoid doing unneeded memory allocations for
spans which aren't going to be exported anywhere anyway.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit 4847557)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit 899360b)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Needed for Buildkit history

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit d8358eb)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

@thaJeztah thaJeztah merged commit dfce875 into moby:27.x Dec 12, 2024
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