asynkron / Akka.OpenTelemetry

Apache License 2.0
5 stars 1 forks source link

Mind notes - design issues #1

Open rogeralsing opened 1 year ago

rogeralsing commented 1 year ago

This library uses a custom ActorRefProvider to allow decorating actors with middleware. This works but is problematic in a few ways:

In Proto.Actor, messages can have headers, just like in HTTP etc. Akka.NET does not have this. therefore I'm using an envelope type for the payload. This means that when sending a message, we either need to know up front if the target actorref belongs to a tracable actor. so that we don't send envelopes to non-traced actors.

Or, we just make it so that all local actors are decorated with the tracing middleware, and get around this issue that way.

Another issue is likely Akka.Remote, e.g. if a remote node does not have tracing enabled, then sending envelopes to those would fail.

Therefore, I think the naive but pragmatic way would be to enforce that all nodes in the Akka.NET system/cluster all have this extension enabled.

If someone has any other ideas, shoot

rogeralsing commented 1 year ago

I still need to figure out how to properly replace the RemoteActorRefProvider, maybe just copy paste all code from the original class.

Another interesting thing to solve, the old async await TaskScheduler bits also needs to work. Maybe just keeping the activity info around for as long as the async task is running.

rogeralsing commented 1 year ago

The current actor context needs to be intercepted somehow. e.g. Context.ActorSelection needs to be intercepted

rogeralsing commented 1 year ago

Intercepting ActorSelection:

        internal static void DeliverSelection(IInternalActorRef anchor, IActorRef sender, ActorSelectionMessage sel)
        {
            if (sel.Elements.IsNullOrEmpty())
            {
                anchor.Tell(sel.Message, sender);   <-- if the anchor is tracable, it should work out of the box?
rogeralsing commented 1 year ago

If I just copy contents of ActorSelection and inject a tracable anchor. it might work?

rogeralsing commented 1 year ago

Next issue. how do I know if headers should be used for e.g. remote senders? Responses sent to the chat client from the chat server demo are not traced as the server doesn't know if it should use tracing headers or not

Maybe it could be possible to determine if headers should be used if target actorref is in user-space? e.g. akka.tcp://MyServer@localhost:8081/user/ChatServer