You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm interested in conducting some measurements around how the current DHT implementation performs. Therefore, I wanted to hook into the RPC calls and track when which RPC is performed and how long it took.
In my concrete case, I'm measuring the different steps of the provide process. While I'm able to subscribe to query events via routing.RegisterForQueryEvents, I haven't found a way to know when the actual ADD_PROVIDER RPCs are performed.
My first idea was to implement the dht_pb.MessageSender interface which would just wrap the actual dht_pb.ProtocolMessenger and enrich it with some tracking code. However, I didn't see an option to actually pass my implementation to the IpfsDHT as it's an unexported field (IpfsDHT.protoMessenger) and only initialized here.
Then I thought, I'll just provide my own MessageSenderImpl and wrap the one that's used by the ProtocolMessenger. Unfortunately, the messageSenderImpl is in an internal package. Even if it weren't in an internal package I wouldn't be able to pass it to the IpfsDHT either (afaict).
Now the ugly part: I ended up copying the messageSenderImpl code, enriching it with my tracking code, passing the updated implementation to dht_pb.NewProtocolMessenger and then monkey patching the dht_pb.NewProtocolMessenger package method to return my own implementation when dht.New is called.
The code can be found here. Just for the record, it works :D.
Is there another way to track the RPCs that I'm missing?
If not, would it be possible...
to add a configuration option where one can provide one's own ProtocolMessenger or
to provide a similar hook to RegisterForQueryEvents like RegisterForRPCEvents?
The text was updated successfully, but these errors were encountered:
dennis-tra
changed the title
Adding RPC Hooks or allow configuration of own MessageSender
Adding RPC Hooks or allow configuration of own ProtocolMessenger
Dec 8, 2021
dennis-tra
changed the title
Adding RPC Hooks or allow configuration of own ProtocolMessenger
RPC Hooks or ProtocolMessenger configuration option
Dec 8, 2021
I'm interested in conducting some measurements around how the current DHT implementation performs. Therefore, I wanted to hook into the RPC calls and track when which RPC is performed and how long it took.
In my concrete case, I'm measuring the different steps of the provide process. While I'm able to subscribe to query events via
routing.RegisterForQueryEvents
, I haven't found a way to know when the actualADD_PROVIDER
RPCs are performed.My first idea was to implement the
dht_pb.MessageSender
interface which would just wrap the actualdht_pb.ProtocolMessenger
and enrich it with some tracking code. However, I didn't see an option to actually pass my implementation to the IpfsDHT as it's an unexported field (IpfsDHT.protoMessenger
) and only initialized here.Then I thought, I'll just provide my own MessageSenderImpl and wrap the one that's used by the
ProtocolMessenger
. Unfortunately, the messageSenderImpl is in aninternal
package. Even if it weren't in an internal package I wouldn't be able to pass it to the IpfsDHT either (afaict).Now the ugly part: I ended up copying the messageSenderImpl code, enriching it with my tracking code, passing the updated implementation to
dht_pb.NewProtocolMessenger
and then monkey patching thedht_pb.NewProtocolMessenger
package method to return my own implementation when dht.New is called.The code can be found here. Just for the record, it works :D.
RegisterForQueryEvents
likeRegisterForRPCEvents
?The text was updated successfully, but these errors were encountered: