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

Make some fields in LogRecord mutable for consistency with Activity. #2877

Closed
Yun-Ting opened this issue Feb 8, 2022 · 2 comments · Fixed by #3217
Closed

Make some fields in LogRecord mutable for consistency with Activity. #2877

Yun-Ting opened this issue Feb 8, 2022 · 2 comments · Fixed by #3217
Labels
enhancement New feature or request

Comments

@Yun-Ting
Copy link
Contributor

Yun-Ting commented Feb 8, 2022

Feature Request

Currently, in Activity, there are methods that allowed users to modify the fields. For example: public Activity SetTag(string key, object? value).

I'm proposing to introduce methods that allow some fields in LogRecord to be mutable - for better consistency with Activity. Also, with this, use cases like redaction or fault-injection in Processor or Exporter could be achieved.

Describe the solution you'd like:

Introduce setter methods to FormattedMessage, State, and StateValues.

OpenTelemetry.Logs.LogRecord.SetFormattedMessage(string formattedMessage) -> void
OpenTelemetry.Logs.LogRecord.SetState(object state) -> void
OpenTelemetry.Logs.LogRecord.SetStateValues(System.Collections.Generic.IReadOnlyList<System.Collections.Generic.KeyValuePair<string, object>> stateValues) -> void

Describe alternatives you've considered.

Making the constructor public to provide users the ability to copy/update fields of their liking.
I think the public setters solution above has better encapsulation based on the OOP principles.
And for use cases like redaction or fault-injection, initialization is not mandatory for modifying a LogRecord.

@dpk83
Copy link

dpk83 commented Feb 9, 2022

+1 to this ask. We have a similar requirement where we are able to perform redaction for traces because Activity supports mutability but same isn't possible with logs.

@noblejacob-kubra
Copy link

+1 to this ask.
Similar to this we have a requirement to do custom scrubbing in logs to mask or remove sensitive information.
But was not able to implement because of having no provision to update the State/ StateValues/ FormattedMessage.
Can we add this feature so that it will be consistent with Activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants