opentelemetry-operator icon indicating copy to clipboard operation
opentelemetry-operator copied to clipboard

Set environment variables only not work

Open Frapschen opened this issue 2 years ago • 5 comments

I want Set environment variables without injection sdk, I use config below as a Instrumentation:

apiVersion: opentelemetry.io/v1alpha1
kind: Instrumentation
metadata:
  name: opentelemetry-autoinstrumentation
spec:
  java:
    image: ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-java
  nodejs:
    image: ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-nodejs
  python:
    image: ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-python
  dotnet:
    image: ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-dotnet
  env:
    - name: OTEL_SERVICE_NAME
      value: my-app
  sampler:
    type: always_on

the deployment with annotation:

      annotations:
        instrumentation.opentelemetry.io/inject-sdk: 'true'

after the Pod restart, I don't find the expect env in container object, is there some wrong in my config? By the way, I don't find any log about inject env in manager's container

Frapschen avatar Aug 09 '22 04:08 Frapschen

The annotation instrumentation.opentelemetry.io/inject-sdk: 'true' has to be put in the pod spec inside deployment not in the deployment annotations. To verify could you please paste here full deployment spec?

pavolloffay avatar Aug 09 '22 11:08 pavolloffay

cc) @Frapschen

pavolloffay avatar Aug 10 '22 12:08 pavolloffay

Confirmed: I just upgrade to 0.56.0 to test the inject-sdk feature. When I use inject-sdk: 'namespace/my-inst' no variables are injected, but when I changed sdk to java it works, so the annotation is in the right spot, and the manager is working.

edude03 avatar Aug 10 '22 16:08 edude03

Scratch that, it works, it's just not released yet 😆 0.56.0 only has commits from 16 days ago, but the inject-sdk went in 14 days ago. Weird that it's mentioned in the docs already, but anyway - if you need it today, you can use ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator@sha256:2bab7a2dd5f7aee9dabdf85cd040d3bcd3fc29a4175260bd385d8bd5bc75963a in the manifests

edude03 avatar Aug 10 '22 16:08 edude03

ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator@sha256:2bab7a2dd5f7aee9dabdf85cd040d3bcd3fc29a4175260bd385d8bd5bc75963a

thx, It works!

JaredTan95 avatar Aug 11 '22 01:08 JaredTan95

Closing, please re-open if there will be still the issue in 0.57.x

pavolloffay avatar Aug 11 '22 08:08 pavolloffay