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

Improve traceability of ITimerMsg #7262

Merged
merged 3 commits into from
Jun 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions src/core/Akka/Actor/Scheduler/TimerScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,36 +41,39 @@ public Timer(object key, object msg, bool repeat, int generation, ICancelable ta
}
}

public interface ITimerMsg
public interface ITimerMsg : IWrappedMessage, INoSerializationVerificationNeeded
Copy link
Member Author

Choose a reason for hiding this comment

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

IWrappedMessage is how we can get access to the contents of the timer and record it via Phobos metrics.

{
object Key { get; }
int Generation { get; }
TimerScheduler Owner { get; }
}

private class TimerMsg : ITimerMsg, INoSerializationVerificationNeeded
private class TimerMsg : ITimerMsg
{
public object Key { get; }
public int Generation { get; }
public TimerScheduler Owner { get; }

public TimerMsg(object key, int generation, TimerScheduler owner)
public TimerMsg(object key, int generation, TimerScheduler owner, object message)
{
this.Key = key;
this.Generation = generation;
this.Owner = owner;
Key = key;
Generation = generation;
Owner = owner;
Message = message;
Copy link
Member Author

Choose a reason for hiding this comment

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

We're not even going to access this value directly in the main timer use-case, so none of that code path is affected.

All of these messages types are internal so there's no public API impact.

}

public object Message { get; }

public override string ToString()
{
return $"TimerMsg(key={Key}, generation={Generation}, owner={Owner})";
return $"TimerMsg(key={Key}, generation={Generation}, owner={Owner}, message={Message})";
}
}

private class TimerMsgNotInfluenceReceiveTimeout : TimerMsg, INotInfluenceReceiveTimeout
{
public TimerMsgNotInfluenceReceiveTimeout(object key, int generation, TimerScheduler owner)
: base(key, generation, owner)
public TimerMsgNotInfluenceReceiveTimeout(object key, int generation, TimerScheduler owner, object message)
: base(key, generation, owner, message)
{
}
}
Expand Down Expand Up @@ -196,9 +199,9 @@ private void StartTimer(object key, object msg, TimeSpan timeout, TimeSpan initi

ITimerMsg timerMsg;
if (msg is INotInfluenceReceiveTimeout)
timerMsg = new TimerMsgNotInfluenceReceiveTimeout(key, nextGen, this);
timerMsg = new TimerMsgNotInfluenceReceiveTimeout(key, nextGen, this, msg);
else
timerMsg = new TimerMsg(key, nextGen, this);
timerMsg = new TimerMsg(key, nextGen, this, msg);

ICancelable task;
if (repeat)
Expand Down
Loading