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

Publish lifecycle events for Artery #28003

Closed
patriknw opened this issue Oct 15, 2019 · 3 comments
Closed

Publish lifecycle events for Artery #28003

patriknw opened this issue Oct 15, 2019 · 3 comments
Assignees
Labels
1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted t:remoting:artery
Milestone

Comments

@patriknw
Copy link
Member

Requested in https://discuss.lightbend.com/t/remotinglifecycleevent-with-artery/4915 and maybe related to our other discussions about how to publish more structured events than plain logging.

@patriknw patriknw added discuss Tickets that need some discussion before proceeding. Not decided if it's a good idea. t:remoting:artery labels Oct 15, 2019
@patriknw patriknw self-assigned this Dec 2, 2019
@patriknw patriknw added 1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted and removed discuss Tickets that need some discussion before proceeding. Not decided if it's a good idea. labels Dec 2, 2019
@patriknw
Copy link
Member Author

patriknw commented Dec 2, 2019

Pull request for the structured log events is in #28209

Those log events are published to the eventStream as LogEventWithMarker and it's possible to subscribe to them with an Actor like this:

  class ConnectedListener extends Actor {

    context.system.eventStream.subscribe(self, classOf[LogEventWithMarker])

    override def receive: Receive = {
      case event: LogEventWithMarker =>
        if (event.marker.name == "akkaConnected")
          println(s"# Connected to ${event.marker.properties("akkaRemoteAddress")}")
        else if (event.marker.name == "akkaDisconnected")
          println(s"# Disconnected ${event.marker.properties("akkaRemoteAddress")}")
    }
  }

The specific Artery TCP connected/disconnected event that was requested here are included, but note that it's logged at DEBUG level so enabling that level is required for consuming them with the listener shown above.

I understand that this might be seen as a not so nice stringly typed api, but the design has been driven by the primary purpose of consuming these events via logging backend infrastructure such as ELK-stack.

The marker and property names are documented in PR #28209, see the addition in logging.md

@patriknw patriknw added this to the 2.6.1 milestone Dec 5, 2019
@patriknw patriknw closed this as completed Dec 5, 2019
@igorfialko
Copy link

So if I want to use it in production but don't want debug level logging then it doesn't work? In meanwhile I just ping target actor to see if it's up or down to adjust state of this actor accordingly. Doesn't artery do it internally already?

@patriknw
Copy link
Member Author

Our general recommendation is to use Slf4j/Logback for production logging and then the akka.loglevel should be set to DEBUG and then more fine grained filtering can be done with the logging backend configuration (logback.xml). https://doc.akka.io/docs/akka/current/typed/logging.html#slf4j-backend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted t:remoting:artery
Projects
None yet
Development

No branches or pull requests

2 participants