Skip to main content

Posts

Showing posts with the label AOP

Using PostSharp for AOP with Reactive Extensions - update

After digging further into the use of AOP with Reactive Extensions my first post about can be improved by using the Do method instead of the Subscribe method on the IObservable<T> inside the AOP aspect OnExit method. Why? The previous implementation I gave would worked well for a hot observable , but for a cold observable this wouldn't apply as it would instantiate a new stream for each subscription setup in the aspect - Lee campbell has a good definition for hot & cold observables. This means the OnExit method changes from: to: There isn't much difference in the implementation, the significant part is re-assigning the ReturnValue for the method execution arguments.

Using PostSharp for AOP with Reactive Extensions

I'm currently working on a project with @HamishDotNet  & @LordHanson where we make heavy use of Rx (Reactive Extensions) for processing streams of data which are generated asynchronously. We have multiple pipeline processes based around an Rx stream, they look something like this: The method Sequence returns an instance of IObservable<T>  which is then acted upon by 4 or 5 methods before the Subscriber is called, some of these methods might mutate the state along the way. The important part is the idea of the pipeline to process the Rx stream as it is generated by the asynchronous Sequence method. So what I wanted to do is log what's going on - how long each step takes (in the pipeline) as well as how long the Rx stream is alive and when the stream generates a value. The issue we have is we don't want to overly modify the code just support such logging\telemetry. I don't want to end up with something like this: Don't get me wrong, if I had only ...