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

Remove support to set map and array to attribute value #2039

Merged
merged 1 commit into from
Nov 3, 2020

Conversation

bogdandrutu
Copy link
Member

This makes things consistent with other generated code where we do not allow
to set non immutable fields.

User can get access to the Map/Array and change that in-place.

Signed-off-by: Bogdan Drutu [email protected]

@codecov
Copy link

codecov bot commented Oct 30, 2020

Codecov Report

Merging #2039 into master will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2039      +/-   ##
==========================================
+ Coverage   91.94%   91.96%   +0.02%     
==========================================
  Files         282      282              
  Lines       16804    16786      -18     
==========================================
- Hits        15450    15438      -12     
+ Misses        928      926       -2     
+ Partials      426      422       -4     
Impacted Files Coverage Δ
consumer/pdata/common.go 98.31% <100.00%> (+1.80%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 99ea2df...b3fc76c. Read the comment docs.

This makes things consistent with other generated code where we do not allow
to set non immutable fields.

User can get access to the Map/Array and change that in-place.

Signed-off-by: Bogdan Drutu <[email protected]>
@tigrannajaryan
Copy link
Member

This makes things consistent with other generated code where we do not allow
to set non immutable fields.

I don't understand why we need this change. The current code looks consistent to me. We do allow setting fields to a value of any supported type, including arrays and maps. Why shouldn't we?

@bogdandrutu
Copy link
Member Author

bogdandrutu commented Oct 30, 2020

I don't understand why we need this change. The current code looks consistent to me. We do allow setting fields to a value of any supported type, including arrays and maps. Why shouldn't we?

The maps and arrays are not immutable and requires deep copy. We want users to get the MapValue() -> AttributeMap and change that.

A similar example is in Resource https://github.com/open-telemetry/opentelemetry-collector/blob/master/consumer/pdata/generated_resource.go#L65 where we give access to the AttributeMap that can be mutated, similar in Span for attributes, etc.

We do let user "set" only immutable fields like string, but things that are mutable we give access to the mutable field which gives access to set immutable fields.

Another prof of misuse is the file that I changed exporter/loggingexporter/logging_exporter_test.go, see how I was able to reduce some unnecessary allocations (point taken that it is in test, but will happen in code as well).

Copy link
Member

@tigrannajaryan tigrannajaryan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed offline, not needed now, we can add later if needed.

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

Successfully merging this pull request may close these issues.

2 participants