Skip to content

[processor/transformprocessor] Unexpected behaviour when setting resource attributes #36360

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

Closed
tarokkk opened this issue Nov 13, 2024 · 2 comments
Labels
bug Something isn't working needs triage New item requiring triage processor/transform Transform processor

Comments

@tarokkk
Copy link
Contributor

tarokkk commented Nov 13, 2024

Component(s)

processor/transform

What happened?

Description

Only the last event record change will be persistent when modifying a resource attribute on a log record.

Steps to Reproduce

Set up a file log receiver and use a transport processor in the pipeline like this:

      transform/example:
        log_statements:
          - conditions: null
            context: log
            statements:
              - set(resource.attributes["vhost"],attributes["example"])

The file log receiver "sometimes" emits the logs in "batches" with the same resource "header"

Expected Result

log1 Resource{"vhost": "xxx"}, Log{"example": "xxx"}
log2 Resource{"vhost": "yyy"}, Log{"example": "yyy"}

Actual Result

log1 Resource{"vhost": "yyy"}, Log{"example": "xxx"}
log2 Resource{"vhost": "yyy"}, Log{"example": "yyy"}

I assume that the setter does not clone the resource & scope part on modification which makes the individual log records to overwrite each resource context.

Collector version

0.104.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

@tarokkk tarokkk added bug Something isn't working needs triage New item requiring triage labels Nov 13, 2024
@github-actions github-actions bot added the processor/transform Transform processor label Nov 13, 2024
Copy link
Contributor

Pinging code owners:

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

@TylerHelmuth
Copy link
Member

This looks like a duplicate of #32080. Check if https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/processor/transformprocessor/README.md#transformflattenlogs solves your issue. Please ping me if you think this is different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage New item requiring triage processor/transform Transform processor
Projects
None yet
Development

No branches or pull requests

2 participants