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

PeriodicBatching moving away from inheritance based API #111

Closed
ChadyG opened this issue Apr 6, 2023 · 8 comments
Closed

PeriodicBatching moving away from inheritance based API #111

ChadyG opened this issue Apr 6, 2023 · 8 comments

Comments

@ChadyG
Copy link

ChadyG commented Apr 6, 2023

See:
serilog/serilog-sinks-periodicbatching#56

Some other dependencies are now pointing to the 3.0.0 release of this, which breaks any code inheriting directly from PeriodicBatchingSink. There is a 3.1.0 release that returns the inheritance, but as the old API is obsoleted any code inheriting from this needs to be updated to avoid conflicts in the future.

@wparad
Copy link
Collaborator

wparad commented Apr 6, 2023

Can you please provide more context as to what exactly the problem is so we can reproduce it. Please include:

  • dotnet core version
  • list of dependencies and their versions
  • What your recommended fix is for the problem

Thanks,
Warren

@ChadyG
Copy link
Author

ChadyG commented Apr 6, 2023

Sure, I'll provide what I can.

I'm not sure which dotnet version exactly, as I wasn't the one building. I was told something recent if not current.
The issue as we came across it was from including the following:

  • Serilog.Sinks.AWSCloudWatch >= 4.0.171
  • Serilog.Sinks.Datadog.Logs = 0.5.2
  • Serilog.Sinks.PeriodicBatching >= 3.0.0

The Datadog package specified the 3.0.0 version of PeriodicBatching, and in doing so gave the error below.

{"Could not load type 'Serilog.Sinks.AwsCloudWatch.CloudWatchLogSink' from assembly 'Serilog.Sinks.AwsCloudWatch, Version=4.0.171.0, Culture=neutral, PublicKeyToken=23b095b16108dcf5' because the parent type is sealed.":"Serilog.Sinks.AwsCloudWatch.CloudWatchLogSink"}

From what I've gathered, this is from the 3.0.0 version of PeriodicBatching sealing the PeriodicBatchingSink class, and therefore preventing loading of the AWSCloudWatch library.

To solve, in the short term we can simply require Serilog.Sinks.PeriodicBatching = 3.1.0. But it sounds like eventually the AWSCloudWatch codebase needs to update to implementing IBatchedLogEventSink instead of PeriodicBatchingSink.
https://github.com/serilog/serilog-sinks-periodicbatching#getting-started

@genoher
Copy link

genoher commented Apr 17, 2023

Hello @ChadyG.
I have not carried out tests yet, but I have implemented a new version by updating the packages / libraries.
If you like to test...
Serilog.Sinks.AwsCloudWatch.5.0.0.zip

The source code is in this fork. https://github.com/genoher/serilog-sinks-awscloudwatch

@wparad
Copy link
Collaborator

wparad commented Apr 17, 2023

I think the easiest thing here is to just copy the PeriodicBatchingSink into this library, and release a new version by removing the dependency. A PR would be welcome on this.

@genoher
Copy link

genoher commented Apr 18, 2023

I have never made a pull request.
I will make a pull request after testing/validating the changes I have made to the code.
There is a constructor that I had to change and I don't know if I did it right...
They have to provide me with an amazon cloud watch user to be able to test it.
I suppose that tomorrow I will have it, and I will be able to do some test.

Some of the changes I have made are the following:

  • Change netstandard2.0 to net6.0
  • Update package reference 'Serilog.Sinks.PeriodicBatching' from '2.*' to '3.1.0'
  • Update file appveyor.yml property version from '4.0' to '5.0'
  • Update file Global.json property sdk version from '2.1.401' to '6.0.311"'
  • Change implementation of CloudWatchLogSink. Modify PeriodicBatchingSink inheritance by interfaces IBatchedLogEventSink and ILogEventSink.

After testing it and confirming that it works correctly, I will make a pull request.

PD: Sorry if my English is not correct, I have used the google translator.

@wparad
Copy link
Collaborator

wparad commented Apr 18, 2023

I have never made a pull request. I will make a pull request after testing/validating the changes I have made to the code. There is a constructor that I had to change and I don't know if I did it right... They have to provide me with an amazon cloud watch user to be able to test it. I suppose that tomorrow I will have it, and I will be able to do some test.

Some of the changes I have made are the following:

  • Change netstandard2.0 to net6.0
  • Update package reference 'Serilog.Sinks.PeriodicBatching' from '2.*' to '3.1.0'
  • Update file appveyor.yml property version from '4.0' to '5.0'
  • Update file Global.json property sdk version from '2.1.401' to '6.0.311"'
  • Change implementation of CloudWatchLogSink. Modify PeriodicBatchingSink inheritance by interfaces IBatchedLogEventSink and ILogEventSink.

After testing it and confirming that it works correctly, I will make a pull request.

PD: Sorry if my English is not correct, I have used the google translator.

Please don't do any of those things. Instead just copy the whole version 2.0 of the Serilog.Sinks.PeriodicBatching library into this library and remove the dependency.

@jackfrosty908
Copy link

Would like to add to this I also have encountered the same issue. At the moment we are removing the Datadog sink and instead using the Datadog Forwarder to get CloudWatch logs into Datadog.

@wparad
Copy link
Collaborator

wparad commented Aug 21, 2023

This is being fixed in #115

@thoean thoean closed this as completed in 3563111 Sep 19, 2023
thoean added a commit that referenced this issue Sep 19, 2023
Allow flexible versions of serilog so that it works works for everyone. fix #111
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

No branches or pull requests

4 participants