-
Notifications
You must be signed in to change notification settings - Fork 2k
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
"OTEL_RESOURCE_ATTRIBUTES" in .env is ignored when using docker compose #4958
Comments
any chance? |
Hiya @mrasu, sorry for the delay in replying – Indeed, we started setting In the meantime, for your purposes, you could set your .env such as MY_CUSTOM_ENV_VAR="service.namespace=opentelemetry-demo" and your compose file such as services:
something:
image: ubuntu
command: tail -f /dev/null
environment:
OTEL_RESOURCE_ATTRIBUTES: ${MY_CUSTOM_ENV_VAR} |
Hm.. right, so;
Wondering if this one should either detect if it’s already set, or prepend the env-var instead of appending it; cli/cli-plugins/manager/cobra.go Lines 136 to 148 in b6c5522
I guess the overall issue to look for is;
|
Thanks, Docker Compose! See docker/cli#4958 (comment)
Thanks, Docker Compose! See docker/cli#4958 (comment)
Thanks, Docker Compose! See docker/cli#4958 (comment)
Thanks, Docker Compose! See docker/cli#4958 (comment)
Thanks, Docker Compose! See docker/cli#4958 (comment)
Thanks, Docker Compose! See docker/cli#4958 (comment)
Hi there from 2025! 👋 So I am facing this issue when running the opentelemetry-demo docker-compose setup. It declares the This environment variable is meant to be multi-value (hence is's called ATTRIBUTES, in plural). It allows comma-separating multiple attributes. The demo example here does it too. So it looks like the way to go forward in @thaJeztah's analysis above is to merge configs. If you only add |
Just experienced this issue myself. I agree with suggestions that result in the end user being able to just set the |
I'm going to be looking at this. If I remember the intention correctly, that environment variable was supposed to be merged with an existing one but maybe it's just messed up? That was the reason we originally piggy-backed off this environment variable. |
There are two similar issues that are impacting usage of this environment variable. The first is that we aren't merging an existing variable with one set in the environment. This is pretty easy to fix and I already have some code ready for this, but it doesn't fix this problem. The other issue is that environment variables clobber anything in the environment file for compose. The issue in this one isn't that we aren't merging an existing environment variable with the injected one. The injected one is creating an We can't really merge these ones without changing the behavior or creating special code to detect this specific environment variable. Some solutions we can pursue.
We can technically get away with just doing 1 and 2 but I think it might be good to just not use this environment variable for this purpose altogether. If we want a simpler but less backwards compatible alternative, we can also just stop populating |
Description
When using docker compose, value of "OTEL_RESOURCE_ATTRIBUTES" specifyied at
.env
file is ignored and the value becomesdocker.cli.cobra.command_path=docker%20compose
instead.It seems #4875 changes behahavior to override OTEL_RESOURCE_ATTRIBUTES.
use-case
opentelemetry-demo
uses.env
to specifyservice.namespace
for otel's namespace.But it is not working now.
You can see code here
Reproduce
.env
file specifing OTEL_RESOURCE_ATTRIBUTESdocker.cli.cobra.command_path=docker%20compose
instead ofservice.namespace=opentelemetry-demo
Expected behavior
Keep the value of "OTEL_RESOURCE_ATTRIBUTES" in
.env
.I believe adding
docker.cli.cobra.command_path
attribute is fine but the original value should be keptdocker version
Client: Docker Engine - Community Cloud integration: v1.0.24 Version: 26.0.0 API version: 1.45 Go version: go1.21.8 Git commit: 2ae903e Built: Wed Mar 20 15:17:48 2024 OS/Arch: linux/amd64 Context: default Server: Docker Engine - Community Engine: Version: 26.0.0 API version: 1.45 (minimum version 1.24) Go version: go1.21.8 Git commit: 8b79278 Built: Wed Mar 20 15:17:48 2024 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.6.28 GitCommit: ae07eda36dd25f8a1b98dfbf587313b99c0190bb runc: Version: 1.1.12 GitCommit: v1.1.12-0-g51d5e94 docker-init: Version: 0.19.0 GitCommit: de40ad0
docker info
Additional Info
No response
The text was updated successfully, but these errors were encountered: