Skip to content

Instantly share code, notes, and snippets.

@kjnilsson
Created May 8, 2014 10:58
Show Gist options
  • Save kjnilsson/300a7693f401ca104512 to your computer and use it in GitHub Desktop.
Save kjnilsson/300a7693f401ca104512 to your computer and use it in GitHub Desktop.
Delegating handler to capture request processing times
type TimingHandler() =
inherit DelegatingHandler ()
let cont (sw : Stopwatch) (t: Task<HttpResponseMessage>) =
sw.Stop()
debug "request time: %i" sw.ElapsedMilliseconds
t.Result // dont like this
override this.SendAsync (request, token) =
let sw = new Stopwatch()
sw.Start()
base.SendAsync(request, token)
.ContinueWith(cont sw, token)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment