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

Akka.Event: restore missing log data #7256

Merged
merged 16 commits into from
Jun 14, 2024

Conversation

Aaronontheweb
Copy link
Member

@Aaronontheweb Aaronontheweb commented Jun 14, 2024

Changes

Fixes #7255

Checklist

For significant changes, please ensure that the following have been completed (delete if not relevant):

Copy link
Member Author

@Aaronontheweb Aaronontheweb left a comment

Choose a reason for hiding this comment

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

Detailed my reproduction steps

@@ -55,7 +55,7 @@ let runIncrementally = hasBuildParam "incremental"
let incrementalistReport = output @@ "incrementalist.txt"

// Configuration values for tests
let testNetFrameworkVersion = "net471"
let testNetFrameworkVersion = "net48"
Copy link
Member Author

Choose a reason for hiding this comment

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

Upgraded to .NET 4.8 so we could use newer versions of Verify, which had DateTime scrubbing. I ended up not needing it but I don't think it hurts anything given that this only affects the test suite.

@@ -18,8 +18,8 @@
<LangVersion>11.0</LangVersion>
</PropertyGroup>
<PropertyGroup>
<XunitVersion>2.5.3</XunitVersion>
<XunitRunnerVersion>2.5.3</XunitRunnerVersion>
<XunitVersion>2.8.1</XunitVersion>
Copy link
Member Author

Choose a reason for hiding this comment

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

Redundant - we already use these newer versions on dev but I had to capture what the logs originally should have looked like on v1.5.20, where we had not yet performed these upgrades. Verify.Xunit required the newer versions.

@@ -28,7 +28,6 @@

namespace Akka.API.Tests
{
[UsesVerify]
Copy link
Member Author

Choose a reason for hiding this comment

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

Obsolete in the latest version of Verify

Sys.EventStream.Subscribe(probe.Ref, typeof(LogEvent));

// act
using (new OutputRedirector(filePath))
Copy link
Member Author

Choose a reason for hiding this comment

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

The error in #7255 was caused not by the formatter on the message changing, but by the fact that we started calling .ToString on the wrong thing in v1.5.21. This test is designed to capture STDOUT and verify against that, so either type of mistake will be caught in the future should it occur again.

var text = File.ReadAllText(filePath);

// need to sanitize the thread id
text = SanitizeDateTime(text);
Copy link
Member Author

Choose a reason for hiding this comment

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

Scrub thread ids and datetimes, since these are unstable run-per-run even if everything is working normally.

@@ -14,6 +14,7 @@ public static class ModuleInit
[ModuleInitializer]
public static void Init()
{
VerifyDiffPlex.Initialize();
Copy link
Member Author

Choose a reason for hiding this comment

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

Force DiffPlex to start once at boot.

[DEBUG][DateTime][Thread 0001][ActorSystem(test)] This is a test 1 cheese
[INFO][DateTime][Thread 0001][ActorSystem(test)] This is a test 1
[WARNING][DateTime][Thread 0001][ActorSystem(test)] This is a test 1
[ERROR][DateTime][Thread 0001][ActorSystem(test)] This is a test 1
Copy link
Member Author

Choose a reason for hiding this comment

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

No idea why the stack trace logs don't show up on .NET Framework, but they do on .NET 8

Copy link
Member Author

@Aaronontheweb Aaronontheweb left a comment

Choose a reason for hiding this comment

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

Introduced the fix and detailed my changes - worried a bit about the .NET Framework 4.7.1 -> 4.8 movement breaking some stuff on the build server but we'll see.

TargetFolder: '$(Build.ArtifactStagingDirectory)/verify'
displayName: 'Copy .received. files to artifact staging directory'

- task: PublishBuildArtifacts@1
Copy link
Member Author

Choose a reason for hiding this comment

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

Add .received files from Verify as a build output whenever we have a test failure.

@@ -191,7 +191,7 @@ public virtual bool ShouldTryKeepMessage(LogEvent evt, out string expandedLogMes
else
{
// allocate the message just once
var nullCheck = evt.Message.ToString();
Copy link
Member Author

Choose a reason for hiding this comment

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

These are the fixes here - we were only looking at the message, not the entire log string.

@@ -225,7 +225,7 @@ private EmptyLogFilterEvaluator() : base(Array.Empty<LogFilterBase>())

public override bool ShouldTryKeepMessage(LogEvent evt, out string expandedLogMessage)
{
expandedLogMessage = evt.Message.ToString()!;
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the fix for most use cases, when users don't have any log filtering enabled.

@Aaronontheweb Aaronontheweb marked this pull request as ready for review June 14, 2024 03:11
@Aaronontheweb Aaronontheweb changed the title [WIP] restore missing log data Akka.Event: restore missing log data Jun 14, 2024
@@ -16,6 +16,7 @@

namespace DocsExamples.Streams
{
#if NETCOREAPP
Copy link
Member Author

Choose a reason for hiding this comment

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

Caused a grumble on Linux, which caused DocFx validation to fail

@Aaronontheweb
Copy link
Member Author

Looks like my reproduction spec can be racy - going to take a look at it and see what I can do about that.

@Aaronontheweb
Copy link
Member Author

Akka.Remote.Tests.Transport.DotNettySslSupportSpec.If_EnableSsl_configuration_is_true_but_not_valid_certificate_is_provided_than_ArgumentNullException_should_be_thrown <- this spec appears to have been broken as a result of upgrading to .NET 4.8

@Aaronontheweb
Copy link
Member Author

VerifyException : Directory: D:\a\1\s\src\core\Akka.API.Tests\verify
NotEqual:
  - Received: DefaultLogFormatSpec.ShouldUseDefaultLogFormat.DotNet8_0.received.txt
    Verified: DefaultLogFormatSpec.ShouldUseDefaultLogFormat.DotNet.verified.txt

FileContent:

NotEqual:

Received: DefaultLogFormatSpec.ShouldUseDefaultLogFormat.DotNet8_0.received.txt
Verified: DefaultLogFormatSpec.ShouldUseDefaultLogFormat.DotNet.verified.txt
Compare Result:
- [DEBUG][DateTime][Thread 0001][ActorSystem(test)] This is a test 1 cheese
+ emptyString
- [INFO][DateTime][Thread 0001][ActorSystem(test)] This is a test 1
- [WARNING][DateTime][Thread 0001][ActorSystem(test)] This is a test 1
- [ERROR][DateTime][Thread 0001][ActorSystem(test)] This is a test 1
-

Output from Verfiy.received:

emptyString

I think what we have here is a race condition between the EventStream and the StandardOutLogger actually completing all of its processing. Might need to retool the system we're using to intercept the output.

Copy link
Contributor

@Arkatufus Arkatufus left a comment

Choose a reason for hiding this comment

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

LGTM

@Arkatufus Arkatufus enabled auto-merge (squash) June 14, 2024 17:20
@Aaronontheweb Aaronontheweb merged commit be4ed4d into akkadotnet:dev Jun 14, 2024
9 of 12 checks passed
@Aaronontheweb Aaronontheweb deleted the fix-7255-log-data branch June 14, 2024 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Akka.Logging: v1.5.21 appears to have truncated log source, timestamps, etc from all log messages
2 participants