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

replace_all_patterns function for attribute keys doesn not expand regex #22094

Closed
vainiusd opened this issue May 19, 2023 · 2 comments · Fixed by #22708
Closed

replace_all_patterns function for attribute keys doesn not expand regex #22094

vainiusd opened this issue May 19, 2023 · 2 comments · Fixed by #22708
Assignees
Labels

Comments

@vainiusd
Copy link

Component(s)

processor/transform

What happened?

Description

replace_all_patterns function does not support regex expand replacement for attribute keys

Steps to Reproduce

processors:
  transform:
    error_mode: ignore
    metric_statements:
      - context: datapoint
        statements:
          - replace_all_patterns(attributes, "key", "^dimension_(.+)", "$$1")

Expected Result

Attributes:
     -> dimension_A: Str() ==> This should change attr key to A from dimension_A 
     -> dimension_B: Str() ==> This should change attr key to B from dimension_B

Actual Result

Attributes:
     -> key_1: Str()

Collector version

v0.77.0

Environment information

Environment

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

OpenTelemetry Collector configuration

processors:
  transform:
    error_mode: ignore
    metric_statements:
      - context: datapoint
        statements:
          - replace_all_patterns(attributes, "key", "^dimension_(.+)", "$$1")

Log output

no response

Additional context

Function implementation differs for attribute keys and values. Is there a specific reason for that?

Values: ReplaceAllString
Keys: ReplaceAllLiteralString

Use case: bulk rename of attributes.

@vainiusd vainiusd added bug Something isn't working needs triage New item requiring triage labels May 19, 2023
@github-actions github-actions bot added the processor/transform Transform processor label May 19, 2023
@github-actions
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@JaredTan95 JaredTan95 removed the needs triage New item requiring triage label May 19, 2023
@evan-bradley
Copy link
Contributor

Thanks for reporting this. It looks like switching to ReplaceAllString was missed when implementing this. I'll have a fix out shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants