Skip to content

Instantly share code, notes, and snippets.

@csainty
Created February 2, 2012 01:08
Show Gist options
  • Save csainty/1720587 to your computer and use it in GitHub Desktop.
Save csainty/1720587 to your computer and use it in GitHub Desktop.
BlogPost : Bugs
$('body').ajaxComplete(function (event, xhrRequest, ajaxOptions) {
var id = xhrRequest.getResponseHeader('X-RavenDb-Profiling-Id');
if (id)
fetchResults(id.split(', '));
});
var fetchResults = function (id) {
$.get(options.url, { id: id }, function (obj) {
if (obj)
addResult(obj);
}, 'json');
};
public void AddStore(IDocumentStore store)
{
var documentStore = store as DocumentStore;
if (documentStore == null)
return;
if (documentStore.WasDisposed)
return;
object _;
documentStore.AfterDispose += (sender, args) => stores.TryRemove(documentStore, out _);
documentStore.SessionCreatedInternal += OnSessionCreated;
stores.TryAdd(documentStore, null);
}
private void OnSessionCreated(InMemoryDocumentSessionOperations operations)
{
RavenProfiler.ContextualSessionList.Add(operations.Id);
if (HttpContext.Current == null)
return;
try
{
HttpContext.Current.Response.AddHeader("X-RavenDb-Profiling-Id", operations.Id.ToString());
}
catch (HttpException)
{
// headers were already written, nothing much that we can do here, ignoring
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment