open-telemetry / opentelemetry-specification

Specifications for OpenTelemetry
https://opentelemetry.io
Apache License 2.0
3.76k stars 890 forks source link

[configuration] Force type when doing environment variable substitution #4281

Open flyfire2002 opened 3 weeks ago

flyfire2002 commented 3 weeks ago

What are you trying to achieve?

When substituting env variables like "00001" (as a string) (e.g. into an attribute), the type of the produced value is automatically Int. I want to be able to force it to type Str at substitution. Note, currently with attribute: convert it is done after the value is already substituted as an Int, so in this case it will be doing Int(1) => Str(1), which is still not the same as Str(00001).

Context/Example

With config

  resource/common_labels:
    attributes:
    - key: some_id
      value: "${id}"
      action: upsert

When the env var id = "00001", the value of the attribute "some_id" will be Int(1). If we do a

    - key: some_id
      action: convert
      converted_type: string

afterwards, the value is Str(1) which is still different from "00001" / Str(00001).

jack-berg commented 3 weeks ago

Seems like this should be transferred to opentelemetry-collector-contrib.

flyfire2002 commented 3 weeks ago

Filed https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/36183 though I feel like this is not a one-processor-specific problem.

trask commented 2 weeks ago

hi @flyfire2002, we don't think this is a spec issue since the spec doesn't say anything about collector processors