InMemory testing and query monitoring

85 views
Skip to first unread message

Sean Feldman

unread,
Jan 21, 2013, 3:31:09 PM1/21/13
to rav...@googlegroups.com
When working with RavenDB, it helps to see what queries server receives. Is it possible to see that queries are sent when working with InMemory instance (unit testing)?
Thanks

Chris Marisic

unread,
Jan 21, 2013, 3:37:55 PM1/21/13
to rav...@googlegroups.com
Changes Api?

Sean Feldman

unread,
Jan 21, 2013, 4:06:08 PM1/21/13
to rav...@googlegroups.com
Chris,

Changes API will not show info on queries (based on documentation here http://ravendb.net/docs/2.0/client-api/changes-api). As well it requires to know document id up-front - not something I'd like to do on every test.

Chris Marisic

unread,
Jan 21, 2013, 4:11:35 PM1/21/13
to rav...@googlegroups.com
Seems like it should have a QueryReceived PatchReceived etc

Sean Feldman

unread,
Jan 21, 2013, 4:37:33 PM1/21/13
to rav...@googlegroups.com
Don't know. It looks the documentation is either outdated or I'm missing something.

Chris Marisic

unread,
Jan 21, 2013, 4:39:41 PM1/21/13
to rav...@googlegroups.com
I wasn't implying that, I was implying that's likely needed as a feature then.

Matt Warren

unread,
Jan 21, 2013, 4:48:27 PM1/21/13
to ravendb
Well one way is to implement a plugin for AbstractIndexQueryTrigger, see https://github.com/ayende/ravendb/blob/master/Raven.Database/Plugins/AbstractIndexQueryTrigger.cs.

That way your code will be called on every query and you can log it.

Sean Feldman

unread,
Jan 21, 2013, 5:03:03 PM1/21/13
to rav...@googlegroups.com
Matt,
Could you point to some information on creating/registering custom plugins with RavenDB? Can't find anything.
Thanks.

Matt Warren

unread,
Jan 21, 2013, 5:06:04 PM1/21/13
to ravendb
See http://ravendb.net/docs/2.0/server/extending/plugins, there's general stuff at the top and then a section titled "Index Query Triggers" lower down.

Matt Johnson

unread,
Jan 21, 2013, 5:11:36 PM1/21/13
to rav...@googlegroups.com
Another way is to hook into the logging abstraction:

public class DebugTarget : Raven.Abstractions.Logging.Target
{
    public override void Write(LogEventInfo logEvent)
    {
        if (logEvent.Level != LogLevel.Debug)
            return;

        Debug.WriteLine("{0} - {1} - {2}",
                        logEvent.TimeStamp.ToLocalTime().ToString("hh:mm:ss.fff"),
                        logEvent.Level,
                        logEvent.FormattedMessage);
    }
}

// around init somewhere:
LogManager.RegisterTarget<DebugTarget>();



On Monday, January 21, 2013 2:48:27 PM UTC-7, Matt Warren wrote:

Sean Feldman

unread,
Jan 21, 2013, 5:23:08 PM1/21/13
to rav...@googlegroups.com
Matt, that was it, awesome.

Sean Feldman

unread,
Jan 23, 2013, 12:42:46 PM1/23/13
to rav...@googlegroups.com
One thing logger doesn't show is constructed query :(

Oren Eini (Ayende Rahien)

unread,
Jan 23, 2013, 12:55:00 PM1/23/13
to ravendb
A pull request? 


--
 
 

Reply all
Reply to author
Forward
0 new messages