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

Func Concat doesn't accept output of Split #27821

Open
Pwalne opened this issue Oct 17, 2023 · 16 comments
Open

Func Concat doesn't accept output of Split #27821

Pwalne opened this issue Oct 17, 2023 · 16 comments
Labels
enhancement New feature or request pkg/ottl priority:p2 Medium

Comments

@Pwalne
Copy link

Pwalne commented Oct 17, 2023

Component(s)

processor/transform

What happened?

Description

The OTL func Concat complains that the output from a func Split is not StringLIkeGetter

Steps to Reproduce

Use transformprocessor to adjust attribute values (or a UUID)

Expected Result

Setting the value of attribute["a"] to the split and then rejoined string.

Actual Result

doesnt work; throws error if you try to pass a value from an attribute.

Collector version

0.87.0

Environment information

Environment

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

OpenTelemetry Collector configuration

processors:
  transform:
    trace_statements:
      -context: span
        statements:
          - set(attributes["a"], Concat(Split(attributes["a"],"-"),""))

Log output

error while parsing arguments for call to "set": invalid argument at position 1: error while parsing arguments for call to "Concat": invalid argument at position 0: must be a list of type StringLIkeGetter

Additional context

No response

@Pwalne Pwalne added bug Something isn't working needs triage New item requiring triage labels Oct 17, 2023
@github-actions
Copy link
Contributor

Pinging code owners:

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

@github-actions github-actions bot added the processor/transform Transform processor label Oct 17, 2023
@TylerHelmuth
Copy link
Member

Oh thats interesting. Since OTTL Converters don't have an associated Return Type yet, the grammar doesn't recognize that a Converter could be a valid input for the list it is expecting. In fact, the Concat currently needs a literal list, so you must supply [] in the statement, which means it wouldn't accept a list value from an attribute either.

I think we need to adjust the input type to be something like a ListGetter[T], where T is the type of the thing in the list. Probably needs touched up to handle the list type being a StringLikeGetter.

@TylerHelmuth TylerHelmuth added priority:p2 Medium pkg/ottl and removed processor/transform Transform processor needs triage New item requiring triage labels Oct 17, 2023
@TylerHelmuth
Copy link
Member

For your needs though, you probably want to do

processors:
  transform:
    trace_statements:
      -context: span
        statements:
          - replace_pattern(attributes["a"], "-", "")

@Pwalne
Copy link
Author

Pwalne commented Oct 17, 2023

For your needs though, you probably want to do

processors:
  transform:
    trace_statements:
      -context: span
        statements:
          - replace_pattern(attributes["a"], "-", "")

Yes, I ended up doing something like that. Although in our scenerio we have todo something such as:

processors:
  transform:
    trace_statements:
      -context: span
        statements:
          -set(attributes["a"], attributes["b"])
          - replace_pattern(attributes["a"], "-", "")
          - set(trace_id.string, attributes["a"])
          - delete(atributes, "a")

And this is only because most UUID libraries encode with - and the trace/spanId do not like it.

@TylerHelmuth
Copy link
Member

Have you tried doing set(trace_id.string, attributes["b"])? I thought it would handle the -.

@Pwalne
Copy link
Author

Pwalne commented Oct 17, 2023

Have you tried doing set(trace_id.string, attributes["b"])? I thought it would handle the -.

It doesn't as that was the first thing i tried. It complains its not 32 hex characters. But if I replace the - it works fine. This uuid generator module used is https://github.com/google/uuid

@TylerHelmuth
Copy link
Member

I experimented for a bit today on what it would take so that Concat could accept the output of Split and my conclusion is that it is doable, but complicated.

@TylerHelmuth TylerHelmuth added enhancement New feature or request and removed bug Something isn't working labels Oct 19, 2023
@TylerHelmuth
Copy link
Member

OTTL is working as expected right now tho - to allow this type of behavior would be a new feature.

@Pwalne
Copy link
Author

Pwalne commented Oct 19, 2023

Would it be easier to allow the traceId/spanId to parse - when used in transformation? Most uuid libraries encode the string value with it anyway

Copy link
Contributor

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

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

Copy link
Contributor

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

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

Copy link
Contributor

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

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

Copy link
Contributor

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

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

@github-actions github-actions bot added the Stale label Jun 24, 2024
@evan-bradley evan-bradley removed the Stale label Jul 1, 2024
Copy link
Contributor

github-actions bot commented Sep 2, 2024

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

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

@github-actions github-actions bot added the Stale label Sep 2, 2024
@obs-gh-enricogiorio
Copy link

I also have issues with Concat. I am trying to concat this array: https://github.com/kubernetes/api/blob/master/core/v1/types.go#L5510, which is essentially a []string in go.
And I get the following error:

error: invalid configuration: processors::transform/object: unable to parse OTTL statement "set(attributes[\"ipFamilies\"], Concat(body[\"spec\"][\"ipFamilies\"], \",\"))": error while parsing arguments for call to "set": invalid argument at position 1: error while parsing arguments for call to "Concat": invalid argument at position 0: must be a list of type StringLikeGetter[github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/ottllog.TransformContext]

@github-actions github-actions bot removed the Stale label Sep 3, 2024
Copy link
Contributor

github-actions bot commented Nov 4, 2024

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pkg/ottl priority:p2 Medium
Projects
None yet
Development

No branches or pull requests

4 participants