Using service trace viewer for viewing correlated traces and troubleshooting

Source: Internet
Author: User


This topic describes the format of trace data, how to view it, and approaches that use the service trace viewer to troubleshoot your application.

Using the service trace Viewer tool

The Windows Communication Foundation (WCF) Service trace Viewer tool helps you correlate diagnostic traces produced by WCF listeners to locate the root cause of an error. the tool gives you a way to easily view, group, and filter traces so that you can diagnose, repair and verify issues with WCF services. for more information about using this tool, see service trace Viewer tool.

This topic contains screenshots of traces generated by running the tracing and message logging sample, when viewed using the service trace Viewer tool. this topic demonstrates how to understand trace content, activities and their correlation, and how to analyze large numbers of traces when troubleshooting.

Viewing trace content

A trace event contains the following most significant information:

    • Activity name when set.
    • Emission time.
    • Trace Level.
    • Trace source name.
    • Process name.
    • Thread ID.
    • A unique trace identifier, which is a URL that points to a destination in the online msdn library, from which you can obtain more information related to the trace.

All of these can be seen in the upper right panel in the service trace viewer, or inBasic InformationSection in the formatted view of the lower-right panel when selecting a trace.

In addition, the formatted view also provides a description for the trace and additional detailed information when available. the latter can include exception type and message, call stacks, message action, from/to fields, and other exception information.

In the XML view, useful XML tags include the following:

    • <Subtype> (Trace Level ).
    • <Timecreated>.
    • <Source> (trace source name ).
    • <Correlation> (activity Id set when emitting the trace ).
    • <Execution> (process and thread ID ).
    • <Computer>.
    • <Extendeddata>, including <action>, <messageid> and the <activityid> set in the message header when sending a message.

If you examine the "sent a message over a channel" Trace, you may see the following content.

Copy code

<E2etraceevent xmlns = ""> <system xmlns = ""> <eventid> 262163 </eventid> <type> 3 </type> <subtype name = "information"> 0 </subtype> <level> 8 </level> <timecreated systemtime = "2006-08-04t18: 45: 30.8491051z "/> <source name =" system. servicemodel "/> <correlation activityid =" {27c6331d-8998-43aa-a382-03239013a6bd} "/> <execution processname =" client "processid =" 1808 "threadid =" 1 "/> <channel/computer>> test1 </computer> </system> <applicationdata> <tracedata> <dataitem> <tracerecord xmlns = "" severity = "information"> <traceidentifier> </traceidentifier> <description> sent a message over a channel. </description> <appdomain> client.exe </appdomain> <source> system. servicemodel. channels. clientframingduplexsessionchannel/35191196 </source> <extendeddata xmlns = ""> <messageproperties> <allowoutputbatching> false </allowoutputbatching> </messageproperties> <messageheaders> <action d4p1: mustunderstand = "1" xmlns: d4p1 = "" xmlns = ""> http://Microsoft.ServiceModel.Samples/ICalculator/Multiply </Action> <messageid xmlns = ""> urn: UUID: messages </messageid> <activityid correlationid = "b02e2189-0816-4387-980c-dd8e306440f5" xmlns = ""> messages </activityid> <replyto xmlns = ""> <address> </address> </replyto> <to d4p1: mustunderstand = "1" xmlns: d4p1 = "" xmlns = ""> net. TCP: // localhost/servicemodelsamples/service </to> </messageheaders> <remoteaddress> net. TCP: // localhost/servicemodelsamples/service </remoteaddress> </extendeddata> </tracerecord> </dataitem> </tracedata> </applicationdata> </e2etraceevent>
Servicemodel e2e Tracing

WhenSystem. servicemodelTrace source is set withSwitchvalueOther than off, andActivitytracing, WCF creates activities and transfers for WCF processing.

An activity is a logical unit of processing that groups all traces related to that processing unit. for example, you can define one activity for each request. transfers create a causal relationship between activities within endpoints. propagating the activity ID enables you to relate activities within SS endpoints. this can be done by settingPropagateactivity=TrueIn configuration at every endpoint. Activities, transfers, and propagation allow you to perform error correlation. In this way, you can find the root cause of an error more quickly.

On the client, one WCF activity is created for each object model call (for example, open channelfactory, add, divide, and so on .) each of the Operation CILS is processed in a "process action" activity.

In the following screenshot, extracted from the tracing and message logging sample the left panel displays the list of activities created in the client process, sorted by creation time. the following is a chronological list of activities:

    • Constructed the channel Factory (clientbase ).
    • Opened the channel factory.
    • Processed the Add action.
    • Set up the secure session (this occurred on the first request) and processed three security infrastructure response messages: RST, rstr, SCT (process Message 1, 2, 3 ).
    • Processed the subtract, multiply, and divide requests.
    • Closed the channel factory, and doing so closed the secure session and processed the Security Message response cancel.

We see the security infrastructure messages because of the wshttpbinding.


In WCF, we show response messages being processed initially in a separate activity (process message) Before we correlate them to the corresponding process action activity that includes des the request message, through a transfer. this happens for infrastructure messages and asynchronous requests and is due to the fact that we must inspect the message, read the activityid header, and identify the existing process action activity with that ID to correlate to it. for synchronous requests, we are blocking for the response and hence know which process action the response relates.

When we select an activity in the left panel, we can see nested activities and traces on the upper right panel. therefore, this is a reduced hierarchical view of the List of Activities on the left, based on the selected parent activity. because the selected Process Action add is the first request made, this activity contains the set up secure session activity (transfer to, transfer back from ), and traces for the actual processing of the Add action.

If we double click the Process Action add activity in the left panel, we can see a graphical representation of the client WCF activities related to add. the first activity on the left is the root activity (0000), which is the default activity. WCF transfers out of the ambient activity. if this is not defined, WCF transfers out of 0000. here, the second activity, Process Action add, transfers out of 0. then we see setup secure session.

On the upper right panel, we can see all traces related to the Process Action add activity. specifically, we have sent the request message ("sent a message over a channel") and received the response ("received a message over a channel") in the same activity. this is shown in the following graph. for clarity, the set up secure session activity is collapsed in the graph.

Here, we load client traces only for clarity, but service traces (Request Message received Ed and Response Message sent) appear in the same activity if they are also loaded in the tool andPropagateactivityWas setTrue.This is shown in a later registration.

On the service, the activity model maps to the WCF concepts as follows:

  1. We construct and open a servicehost (this may create several host-related activities, for instance, in the case of security ).
  2. We create a listen at activity for each listener in the servicehost (with transfers in and out of open servicehost ).
  3. When the listener detects a Communication Request initiated by the client, it transfers to a "receive bytes" activity, in which all bytes sent from the client are processed. in this activity, we can see any connection errors that have happened during the client-service interaction.
  4. For each set of bytes that is wrongly ed that corresponds to a message, we process these bytes in a "process message" activity, where we create the WCF message object. in this activity, we see errors related to a bad envelope or a malformed message.
  5. Once the message is formed, we transfer to a process action activity. IfPropagateactivityIs setTrueOn both the client and service, this activity has the same ID as the one defined in the client, and described previusly. from this stage we start to benefit from direct correlation into SS endpoints, because all traces emitted in WCF that are related to the request are in that same activity, including the response message processing.
  6. For out-of-process action, we create an "execute user code" activity to isolate traces emitted in user code from the ones emitted in WCF. in the preceding example, the "Service sends add response" trace is emitted in the "execute user code" activity not in the activity propagated by the client, if applicable.

In the authentication that follows, the first activity on the left is the root activity (0000), which is the default activity. the next three activities are to open the servicehost. the activity in column 5 is the listener, and the remaining activities (6 to 8) Describe the WCF processing of a message, from bytes processing to user code activation.

The following screenshot shows the activities for both the client and service, and highlights the Process Action add activity processing SS processes (orange ). arrows relate the request and response messages sent and received ed by the client and service. the traces of Process Action are separated into SS processes in the graph, but shown as part of the same activity in the upper-right panel. in this panel, we can see client traces for sent messages followed by service traces for sorted Ed and processed messages.

In the following error scenario, error and warning traces at the service and client are related. an exception is first thrown in user code on the Service (right-most green activity that includes des a warning trace for the exception "the service cannot process this request in user code. "). when the response is sent to the client, a warning trace is again emitted to denote the fault message (left pink activity ). the client then closes its WCF client (yellow activity on the lower-left side), which aborts the connection to the service. the service throws an error (longest pink activity on the right ).

The sample used to generate these traces is a series of synchronous requests using the wshttpbinding. there are deviations from this graph for scenarios without security, or with asynchronous requests, where the process action activity encompasses the begin and end operations that constitute the asynchronous call, and shows transfers to a callback activity. for more information about additional scenarios, see end-to-end tracing scenarios.

Troubleshooting using the service trace Viewer

When you load trace files in the service trace Viewer tool, you can select any red or yellow activity on the left panel to track down the cause of a problem in your application. the 000 activity typically has unhandled exceptions that bubble up to the user.

On the upper right panel, you can examine traces for the activity you selected on the left. you can then examine red or yellow traces in that panel and see how they are correlated. in the preceding graph, we see warning traces both for the client and service in the same process action activity.

If these traces do not provide you with the root cause of the error, you can utilize the graph by double-clicking the selected activity on the left panel (here process action ). the graph with related activities is then displayed. you can then expand related activities (by clicking the "+" signs) to find the first emitted trace in red or yellow in a related activity. keep expanding the activities that happened just before the red or yellow trace of interest, following transfers to related activities or message flows processing SS endpoints, until you track the root cause of the problem.

If servicemodelActivitytracingIs off but servicemodel tracing is on, you can see servicemodel traces emitted in the 0000 activity. However, this requires more effort to understand the correlation of these traces.

If message logging is enabled, you can use the message tab to see which message is impacted by the error. by double-clicking a message in red or yellow, you can see the Graph view of the related activities. these activities are the ones most closely related to the request where an error happened.

See also

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.