How can I supervise an actor materialized out of an ActorSource?

Say I materialize an actor inside a Flow definition from an ActorSource argument that I passed into the GraphDSL.create() call. I want to ensure this actor is supervised; it forms an essential part of the service I am building and if it fails without restarting service will be interrupted with no other way of figuring it out. Since it’s materializer by an ActorMaterializer instance that is itself part of an ActorSystem, there has to be a way somewhere to supervise this actor and ensure that if it dies, I at least know about it before my users.

Here is the code example:

def webflow() = Flow.fromGraph(GraphDSL.create(actorSource) { implicit builder => source =>
        // actor that does stuff and sends info to the actor inside "source"
        val actorSink = builder.add(ActorSink.actorRef[Protocol](
                    ref = ref,
                    onCompleteMessage = Disconnected,
                    onFailureMessage = Failed.apply
                )
            )
        // materialized value - I want to watch this!
        val actorSource = builder.materializedValue.map(ref => Register(ref))
        // now the data can be fed back to the stream
        actorSource ~> actorSink
        // define more component, expose ports
        ....
    }
)

That is not within your control since the actor is not something you define or start.

The source ref is not implemented by an actual actor but an internal, stateless construct that forwards elements to the internal actor running the stream, so the source actor ref cannot really fail itself and any failure would likely be in the actor running the stream, which would make the stream fail.