Open mrasu opened 7 months ago
any chance?
Hiya @mrasu, sorry for the delay in replying –
Indeed, we started setting OTEL_RESOURCE_ATTRIBUTES
which would break setups such as yours. This wasn't the intention, and I guess there's a few ways we could take to avoid collisions here: we could use a separate/custom env var for our instrumenting since we can make sure both ends look at the same place, or we could check for the env var on the CLI and append our attribute instead of just overwriting.
I'm open to opinions here (cc @milas @jsternberg @krissetto).
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;
.env
(again)docker
CLI (and docker
CLI doesn't use .env
, so wouldn't even be aware the user is about to set SOME_ENV_VAR
)OTEL_RESOURCE_ATTRIBUTES
is set already (in either case), and assume it's not set, therefore overwriting any user-set option for OTEL?Wondering if this one should either detect if it’s already set, or prepend the env-var instead of appending it; https://github.com/docker/cli/blob/b6c5522128372944aedf9b4bbdfad08369f77d1c/cli-plugins/manager/cobra.go#L136-L148
I guess the overall issue to look for is;
docker context
in use.
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 https://github.com/docker/cli/pull/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 addingdocker.cli.cobra.command_path
attribute is fine but the original value should be keptdocker version
docker info
Additional Info
No response