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

[processor/transform] The set function cannot set a field to nil #12193

Closed
TylerHelmuth opened this issue Jul 8, 2022 · 6 comments
Closed

[processor/transform] The set function cannot set a field to nil #12193

TylerHelmuth opened this issue Jul 8, 2022 · 6 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers priority:p2 Medium processor/transform Transform processor

Comments

@TylerHelmuth
Copy link
Member

Describe the bug
The Telemetry Query Language has the concept of nil, but the set function doesn't understand it. You cannot do set(attribute["test"], nil). This is because of the nil check in the set function and also because of the setAttr function in each signal's context (traces for example) doesn't know how to handle nil.

The TQL/processor need updated to better support setting nil.

@TylerHelmuth TylerHelmuth added bug Something isn't working help wanted Extra attention is needed good first issue Good for newcomers processor/transform Transform processor labels Jul 8, 2022
@TylerHelmuth TylerHelmuth added the priority:p2 Medium label Jul 8, 2022
@evan-bradley
Copy link
Contributor

Could this be assigned to me?

@TylerHelmuth
Copy link
Member Author

@evan-bradley its yours.

One thing to think about is that the current implementation allows set(attributes["test"], resource.attributes["test"]) to not update attributes["test"] if resource.attributes["test"] does not exist. This saves the need for a where clause but is kind of an obscure outcome.

To do this change you'll probably have to change the set function so that the above scenario sets attributes["test"] to nil if resource.attributes["test"] does not exist. Do have the same outcome as before users will need to use a where clause: set(attributes["test"], resource.attributes["test"]) where resource.attributes["test"] != nil

I think overall thats an improvement for the language, but should be properly documented as this can be seen as a breaking change for the set function.

@TylerHelmuth TylerHelmuth removed the help wanted Extra attention is needed label Jul 13, 2022
evan-bradley pushed a commit to evan-bradley/opentelemetry-collector-contrib that referenced this issue Jul 19, 2022
evan-bradley added a commit to evan-bradley/opentelemetry-collector-contrib that referenced this issue Jul 19, 2022
evan-bradley added a commit to evan-bradley/opentelemetry-collector-contrib that referenced this issue Jul 19, 2022
evan-bradley added a commit to evan-bradley/opentelemetry-collector-contrib that referenced this issue Jul 19, 2022
evan-bradley added a commit to evan-bradley/opentelemetry-collector-contrib that referenced this issue Jul 19, 2022
evan-bradley added a commit to evan-bradley/opentelemetry-collector-contrib that referenced this issue Jul 19, 2022
@evan-bradley
Copy link
Contributor

Looking for some guidance here: the specification for attributes says that it is undefined behavior to set an attribute value to null, and most language SDKs implement it as a no-op, similar to how the set function currently works. I don't see any obvious fields accessible to the transform processor where nil would be a valid value. How do we want to proceed?

@TylerHelmuth
Copy link
Member Author

TylerHelmuth commented Jul 20, 2022

Good find. For attributes then it should continue to do nothing.

It does bring up the question of whether or not issue is really valid. Should we let users set anything to nil ? I can't really think of a field in traces, metrics, or logs, where nil is a valid value.

We might be able to close this issue without doing anything.

@evan-bradley
Copy link
Contributor

I agree, I don't think there are any code changes necessary. One follow-up could be to document the motivation for this behavior.

@TylerHelmuth
Copy link
Member Author

Ya good idea. Can you update the set function entry to explain setting anything to nil is no-op

evan-bradley added a commit to evan-bradley/opentelemetry-collector-contrib that referenced this issue Jul 21, 2022
Fixes open-telemetry#12193

Add tests for ensuring that setting attributes to `nil` is a no-op, and
document motiviation for setting to `nil`
being a no-op in the `set` function.
evan-bradley added a commit to evan-bradley/opentelemetry-collector-contrib that referenced this issue Jul 21, 2022
Fixes open-telemetry#12193

Add tests for ensuring that setting attributes to `nil` is a no-op, and
document motivation for why calling `set` with a `nil` value is a
no-op.
@mx-psi mx-psi closed this as completed in 36153b6 Jul 22, 2022
ag-ramachandran referenced this issue in ag-ramachandran/opentelemetry-collector-contrib Sep 15, 2022
Fixes #12193

Add tests for ensuring that setting attributes to `nil` is a no-op, and
document motivation for why calling `set` with a `nil` value is a
no-op.

Co-authored-by: Evan Bradley <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers priority:p2 Medium processor/transform Transform processor
Projects
None yet
Development

No branches or pull requests

2 participants