-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Conversation
c3d12d5
to
f751b52
Compare
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
f751b52
to
261801b
Compare
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]>
261801b
to
b3fc76c
Compare
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 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). |
There was a problem hiding this 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.
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]