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

514 - bring back mailbox size metric #514

Merged
merged 3 commits into from
Feb 22, 2023

Conversation

skipper1982
Copy link
Contributor

Closes #514


Summary:

(please input the summary)

@lgajowy lgajowy force-pushed the 514-bring-back-mailbox-size-metric branch from ff3ebfe to cdd3365 Compare November 17, 2022 13:12
Copy link
Contributor

@lgajowy lgajowy left a comment

Choose a reason for hiding this comment

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

@skipper1982 I think I have an idea on how to use an async instrument for this metric (alternative approach). LMKWDYT. :)


import java.util.Objects;

public class MailboxEnqueueAdvice {
Copy link
Contributor

@lgajowy lgajowy Nov 21, 2022

Choose a reason for hiding this comment

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

There's a method in ActorCell:

 /**
   * If the actor isLocal, returns the number of "user messages" currently queued,
   * which may be a costly operation, 0 otherwise.
   */
  def numberOfMessages: Int

We could (maybe?) pass a reference to that field every time an actor is created.

object LocalActorRefProviderAdvice {

  @OnMethodExit
  def actorOf(@Return ref: ActorRef, @Argument(0) system: ActorSystem): Unit =
    ??? // get the reference, the path and create the instrument for the actorRef (that contains the actorcell, which has the numberOfMessages method).

}

that advice could be attached to:

private val localActorRefProviderInstrumentation: AgentInstrumentation =
    instrument("akka.actor.LocalActorRefProvider").visit(LocalActorRefProviderAdvice, "actorOf")

(taken from v0.7.0) Not sure if it's enough to instrument the localActorRefProvider

everytime we create a new actor maybe we can setup an async instrument that would periodically poll for the value from numberOfMessages, thus taking the mailbox size. Gauge seems a good fit. Not sure about the performance of this (probably awful, but maybe not?).

@skipper1982 lmk what do you think. I realize this can be unclear so let's have a call if needed. :)

@lgajowy lgajowy force-pushed the 514-bring-back-mailbox-size-metric branch from cdd3365 to 898c525 Compare February 15, 2023 14:19
@ptrdom ptrdom self-assigned this Feb 17, 2023
@ptrdom ptrdom added this to the 0.8.0 milestone Feb 17, 2023
@ptrdom ptrdom force-pushed the 514-bring-back-mailbox-size-metric branch from 898c525 to d6c797e Compare February 17, 2023 08:30
@ptrdom ptrdom requested a review from lgajowy February 17, 2023 13:13
@lgajowy lgajowy force-pushed the 514-bring-back-mailbox-size-metric branch from da090cc to 2d45281 Compare February 22, 2023 10:02
@lgajowy
Copy link
Contributor

lgajowy commented Feb 22, 2023

@adamgadomski I created an issue for a potential improvement of this metric: #615

For now merging as is.

@lgajowy lgajowy force-pushed the 514-bring-back-mailbox-size-metric branch from 2d45281 to 76a8877 Compare February 22, 2023 11:51
@lgajowy lgajowy merged commit d6c1663 into main Feb 22, 2023
@lgajowy lgajowy deleted the 514-bring-back-mailbox-size-metric branch February 22, 2023 12:28
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

Successfully merging this pull request may close these issues.

3 participants