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

NLog GoogleStackDriverTarget skip reflection on Stream-objects #5230

Merged
merged 1 commit into from
Aug 4, 2020

Conversation

snakefoot
Copy link
Contributor

Stream-objects properties often throw exceptions, and it is difficult to get useful information by reflection.

@snakefoot snakefoot requested a review from a team as a code owner August 3, 2020 19:16
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Aug 3, 2020
@amanda-tarafa amanda-tarafa self-assigned this Aug 4, 2020
Copy link
Contributor

@amanda-tarafa amanda-tarafa left a comment

Choose a reason for hiding this comment

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

@chrisdunelm @jskeet If you can take a look, since you are more familiar with this code than I am.

@@ -141,11 +141,12 @@ protected override void InitializeTarget()
jsonSettings.Converters.Add(new ToStringJsonConverter(typeof(MemberInfo)));
jsonSettings.Converters.Add(new ToStringJsonConverter(typeof(Assembly)));
jsonSettings.Converters.Add(new ToStringJsonConverter(typeof(Module)));
jsonSettings.Converters.Add(new ToStringJsonConverter(typeof(System.IO.Stream)));
Copy link
Contributor

Choose a reason for hiding this comment

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

This is probably fine...


jsonSettings.Error = (sender, args) =>
{
// Serialization of properties that throws exceptions should not break everything
InternalLogger.Warn(args.ErrorContext.Error, "GoogleStackdriver(Name={0}): Error serializing exception property: {1}", Name, args.ErrorContext.Member);
InternalLogger.Debug(args.ErrorContext.Error, "GoogleStackdriver(Name={0}): Error serializing exception property: {1}", Name, args.ErrorContext.Member);
Copy link
Contributor

Choose a reason for hiding this comment

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

... but we might not want to change the level of logging serialization errors at this point.

@chrisdunelm
Copy link
Contributor

Thanks @snakefoot for the PR.
I agree with @amanda-tarafa - adding a converter for System.IO.Stream is fine, but probably best to revert the InternalLogger.Warn change.

@snakefoot
Copy link
Contributor Author

snakefoot commented Aug 4, 2020 via email

@chrisdunelm
Copy link
Contributor

Thanks for the explanation of why the change is sensible.
Yes, this seems like a reasonable thing to do.

Copy link
Contributor

@chrisdunelm chrisdunelm left a comment

Choose a reason for hiding this comment

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

LGTM

@chrisdunelm chrisdunelm merged commit 02e2ddc into googleapis:master Aug 4, 2020
jskeet added a commit to jskeet/google-cloud-dotnet that referenced this pull request Nov 19, 2020
Changes in this release:

- [Commit cbaa00a](googleapis@cbaa00a): Renormalize line endings
- [Commit 02e2ddc](googleapis@02e2ddc): NLog GoogleStackDriverTarget skip reflection on Stream-objects ([issue 5230](googleapis#5230))
- [Commit 0e6d135](googleapis@0e6d135): NLog GoogleStackdriverTarget improve handling of System.Reflection (MemberInfo is better than MethodInfo)
jskeet added a commit that referenced this pull request Nov 19, 2020
Changes in this release:

- [Commit cbaa00a](cbaa00a): Renormalize line endings
- [Commit 02e2ddc](02e2ddc): NLog GoogleStackDriverTarget skip reflection on Stream-objects ([issue 5230](#5230))
- [Commit 0e6d135](0e6d135): NLog GoogleStackdriverTarget improve handling of System.Reflection (MemberInfo is better than MethodInfo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants