Skip to content
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

Invalid warning Variable substitution using $VAR will be deprecated in favor of ${VAR} and ${env:VAR}, please update $$ #10356

Closed
arielvalentin opened this issue Jun 5, 2024 · 9 comments · Fixed by #10392
Labels
area:confmap bug Something isn't working

Comments

@arielvalentin
Copy link

arielvalentin commented Jun 5, 2024

Component(s)

No response

What happened?

Description

When using ottl transform processor with a capture group, the following warning is emitted in the logs:

{
"level":"warn",
"ts":1717553616.784837,
"caller":"[email protected]/expand.go:73",
"msg":"Variable substitution using $VAR will be deprecated in favor of ${VAR} and ${env:VAR}, please update $$",
"variable":"$"
}

Steps to Reproduce

Create a transform processor that uses replace pattern with a capture group substitution like this:

error_mode: ignore
trace_statements:
  - context: span
    statements:
      - |-
        replace_pattern(attributes["baz"], "^(foo|bar)-.*", "$$1")

Expected Result

No warnings are printed

Actual Result

{
"level":"warn",
"ts":1717553616.784837,
"caller":"[email protected]/expand.go:73",
"msg":"Variable substitution using $VAR will be deprecated in favor of ${VAR} and ${env:VAR}, please update $$",
"variable":"$"
}

Collector version

v0.101.0

Environment information

Environment

OS: (e.g., "Ubuntu 20.04")
Compiler(if manually compiled): (e.g., "go 14.2")

OpenTelemetry Collector configuration

No response

Log output

No response

Additional context

No response

@arielvalentin arielvalentin added the bug Something isn't working label Jun 5, 2024
@crobert-1
Copy link
Member

This is a warning that you need to update your configuration to use the the alternate format, as the configuration you're using for environment variables, $$1 in your case, is going to be deprecated.

For your config, $$1 should be ${$1}, I believe.

@crobert-1 crobert-1 added question Further information is requested and removed bug Something isn't working labels Jun 5, 2024
@arielvalentin
Copy link
Author

@crobert-1
Copy link
Member

It looks like the update wasn't included in the release notes.

PR: #9162
Relevant issue: #9162

You're correct though, that documentation is definitely out of date now. Thanks for linking!

Copy link
Contributor

github-actions bot commented Jun 5, 2024

Pinging code owners for pkg/ottl: @TylerHelmuth @kentquirk @bogdandrutu @evan-bradley. See Adding Labels via Comments if you do not have permissions to add labels yourself.

@crobert-1
Copy link
Member

Actually, I may be wrong here, it may be an incorrect warning. I forgot about the special casing around $$1 here. I'll defer to the OTTL code owners to decide if this is a bug in confmap or out of date documentation here 👍

@evan-bradley
Copy link
Contributor

evan-bradley commented Jun 5, 2024

This is a legitimate issue. It's possible confmap is being too aggressive with checks and ignoring $$, but it could also be that now OTTL can move toward not requiring $$. I need to double-check the handling before I can say for sure.

@TylerHelmuth
Copy link
Member

This is happening bc of

msg := fmt.Sprintf("Variable substitution using $VAR will be deprecated in favor of ${VAR} and ${env:VAR}, please update $%s", str)
, which now has a valid logger.

That check needs a better regex - right now it is checking for a string starting with a $, not if it is also a valid env var name.

@crobert-1
Copy link
Member

@TylerHelmuth and @evan-bradley - Should this issue be moved to core then to fix the expand converter logic? (Since this isn't an OTTL issue, or any contrib component)

@TylerHelmuth
Copy link
Member

Ya

@evan-bradley evan-bradley transferred this issue from open-telemetry/opentelemetry-collector-contrib Jun 6, 2024
@evan-bradley evan-bradley added bug Something isn't working area:confmap and removed question Further information is requested labels Jun 6, 2024
mx-psi pushed a commit that referenced this issue Jun 12, 2024
…pens (#10392)

#### Description
Fix a bug where we printed a warning log when we were not expanding a
value

#### Link to tracking issue
Fixes
#10356

#### Testing
Tested manually
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:confmap bug Something isn't working
Projects
None yet
4 participants