Tracing. A bit of a wrap up

by Matt 1. August 2007 10:21

As can be seen from the last few posts (if you ignore the monsters one), I've been having a bit of a deep dive into the System.Diagnostics tracing classes, and especially the concept of activities (as glorified by WCF's Service Trace Viewer).

I needed a logging solution for a project at work. This was all about seeing if System.Diagnostics was up to the job. Here are the key points I see from this.

Boring Logging Solved

If your requirements are just for simple but flexible logging, then you're sorted. Knock yourself out.

Reducing Dependencies

I don't want my project to have to take on dependencies it doesn't need. It has to be downloaded to a client's desktop. I'd rather not have to download log4net, or Enterprise Library.

Asynchronous Logging

Unfortunately, logging is synchronous, which would mean a performance hit. You'll need to weigh up if this matters to you. Logging in a client application will likely not have as much of an impact as logging on a high volume server side app.

We can mitigate this by writing an asynchronous TraceListener. Or just use Enterprise Library's MSMQ trace listener. There goes point #2 above.

Logging Arbitrary/Ambient Data

You can enable the logging of certain types of standard data, such as process id, thread id and callstack, which is very useful. You can also use TraceSource.TraceData to output custom data, such as a customer identifier. If you always wanted to output the customer identifier (what I'm calling ambient data), you'll need to write a wrapper API.

The nice thing is that once the extra data has been serialised, Service Trace Viewer can search and filter on it, thanks to custom xpath expressions.

End to End Tracing

The value in being able to join up logging at the client side with logging at the server side and view them in a nice tool like Service Trace Viewer shouldn't be underestimated.

But sometimes end to end tracing isn't enough. If you're interested in knowing the steps a customer took to get to a certain point, you need to group all customer interactions into a form of session.

A simple solution would be to have a session identifier as the form of ambient data that always gets output. Then Service Trace Viewer could filter on this.

Another solution would be to write a particular event that ties the session identifier to a specific activity id, then correlate all the activity ids from that.

End to End Tracing Analysis

Which nicely brings me to the analysis of the end to end tracing.

Service Trace Viewer is a nice tool, but I think it's more of a visualisation/inspection tool than an analysis tool.

End to end tracing is a graph. To get all of the records in a single end to end call, I need to walk that graph and follow the transfer of activities. This is fairly straightforward when we're in an xml file that I'll need to process linearly anyway, but if we stored the data in a database? That'd make an interesting query...

But we can still mitigate this. There's nothing stopping storing a session identifier in each record, either at runtime or post processing.

File Formats

Hang on. Databases? Oh.

Service Trace Viewer only supports flat files.

And you can only use STV if you use the XmlWriterTraceListener.

Propogation of Activities/Context

This Just Works when you're using WCF, and is easy to implement if your not, and the gains in end to end tracing are very cool.

Custom Logging in Service Trace Viewer

It appears that WCF interacts so nicely with Service Trace Viewer by chucking out more information. WCF has built a whole load of plumbing on top of System.Diagnostics, all of which is internal, but it helps dump full exception details, give friendly names to activities and so on. I need to investigate this a bit more.

Finished...

It's clear that System.Diagnostics isn't the final word on tracing and logging, but it's certainly Good Enough, and given its extensibility, it's definitely a Good Start.

I wanted to be able to tick enough boxes that I could just use the logging out of the box, without having to go and evaluate any other frameworks. I think I've done that, but only just. Simple logging is handled, but I really like the activities idea. Yet to make it easy to use that, I think I'm going to have to write some wrappers. And if there's extra stuff to output to make Service Trace Viewer play nicer, then maybe that'll be a few more wrappers. That's a little disappointing.

Tags:

Comments (23) -

Bed tray table ideas
Bed tray table ideas
2/11/2011 9:17:02 AM #

Choose a job you love, and you will never have to work a day in your life.

Reply

Robert Price
Robert Price
3/24/2011 11:58:16 AM #

The magnonomous truth about this article is, that it spoke to me deeply. Thank you for sharing your thoughts and concerns.

Reply

Houston Chiropractor
Houston Chiropractor
3/24/2011 2:52:40 PM #

The solid truth about this  blog article is, that it spoke to me deeply. Thank you for sharing your thoughts and concerns.

Reply

suv review
suv review
7/20/2011 10:33:44 PM #

Fantastic task I like your type! Would really like to right here your feedback on my website! I am also seeking for someone to help you me make websites!

Reply

suv hybrid
suv hybrid
7/21/2011 12:46:55 PM #

I've recently began a weblog, the data you provide on this site has helped me tremendously. Thanks for all your time & work.

Reply

best ipad games
best ipad games
7/24/2011 4:53:28 AM #

hi!,I like your writing so so much! proportion we communicate extra about your post on AOL? I require a specialist in this area to unravel my problem. May be that's you! Taking a look forward to see you.

Reply

LAURENCE  Debora
LAURENCE Debora
7/27/2011 10:11:48 AM #

Bienvenue sur annuaires-gratuit.com.Des fonctionnalités inédites, nombreuses annuaires.

Reply

LAURENCE  Debora
LAURENCE Debora
7/28/2011 5:37:57 AM #

Notre objectif et de vous simplifiée les choses et faire connaître vos annuaires.

Reply

DEBORA Laurence
DEBORA Laurence
8/1/2011 7:52:27 AM #

Il ne vous reste plus qu' à créer votre propre annuaire, l'inscription est  gratuite .

Reply

DEBORA Laurence
DEBORA Laurence
8/2/2011 4:09:52 AM #

Service page annuaires : Trouver l'annuaire qu'il vous faut sur annuaires-gratuit.com .

Reply

Dwayne Gleitz
Dwayne Gleitz
10/3/2011 12:04:06 PM #

Great, entertaining blog. Some of readers don't think that every site must have comments section. But I think that surfer comments specify a blog. Briefly thanks for accepting users writing on this well designed website. S.yours.

Reply

zumba bristol
zumba bristol
10/12/2011 4:16:58 AM #

Greetings! Thanks a lot to make this sort of an enlightening blog post. Basically you could have brought up those subjects the opposite way round. However you presented it a helpful individual twist. Looking foward to looking in on your site with greater regularity.

Reply

dent repair reading
dent repair reading
10/12/2011 6:06:12 AM #

It’s laborious to search out educated individuals with this topic, however, you appear to be you recognize what you’re discussing! Thanks

Reply

Travis
Travis
11/23/2011 12:09:22 PM #

Hiya,
I just want to give a big thumbs up for the good info youve got here on this post.
Thank you   - -

Johna Rimmer Photography
937 Villaire Avenue
Windsor ON, N8S 2J5
(519) 567-3082

Reply

philix
philix United States
11/22/2015 8:21:06 AM #

great web site.

Reply

Reuben Ellenbecker
Reuben Ellenbecker United States
1/6/2016 1:56:25 PM #

Let me be the first to say: Congrats, Neil! I've been following this site from day one, and have loved every single day of awesomeness that it has delivered. You deserve all the success coming your way. Keep it up!AWESOME!

Reply

Lauren Button
Lauren Button United States
1/15/2016 5:45:57 AM #

Let me be the first to say: Congrats, Neil! I've been following this site from day one, and have loved every single day of awesomeness that it has delivered. You deserve all the success coming your way. Keep it up!AWESOME!

Reply

Jose Bacone
Jose Bacone United States
1/15/2016 8:32:33 AM #

this is awesome like the book of awesome

Reply

Rueben Derosa
Rueben Derosa United States
1/15/2016 8:54:44 AM #

the style of keeping you connected with so many things of different types is awesome and you find it interesting everytime.

Reply

Anna Farris
Anna Farris United States
7/20/2016 7:43:28 AM #

Take my word for it, it's not as easy as you think

Reply

Mitchel Verducci
Mitchel Verducci United States
8/25/2016 4:21:03 AM #

Hopefully you can make a blog dicussing the smart home planning using available recent technology equiptments for homes

Reply

Joi Demman
Joi Demman United States
6/4/2017 8:41:42 AM #

Hi there I am so glad I located your web site, I really discovered you by mishap,while I was investigating on Aol for another thing, Nevertheless I am here currently as well as   <a href="small-games.pro/.../">Scatter Slots Hack</a> would certainly jujst prefer to claim joys for an incredible post aand a all round amazing blog site (I additionally enjoy the theme/design), I do not have time to surf everything currently but I have book-marked it and also included your RSS feeds, so when I have time I will bbe back to find out more, Please do keep up the superb work.work

Reply

UpMusic
UpMusic United States
8/6/2017 10:33:12 AM #

Wow, your website is awesome

Reply

Add comment

biuquote
  • Comment
  • Preview
Loading

Rel=Me

Month List

RecentComments

Comment RSS