Trace table for individual transactions  Accounting

Chapter 5: Tracing and Accounting

Specific tracing example

The following example shows how to enable or disable tracing for specific transactions. It also shows how TDSETSPT calls affect the contents of the trace table. TDS packet tracing is initially turned on for eight specific transactions. Tracing continues for the specified functions until a TDSETSPT call turns tracing off for those functions, or until TDSETLOG disables tracing entirely.

This example does not show exact syntax or arguments; it merely indicates which flags and transactions are set. See the sample program in the appropriate Programmer’s Reference for the Server Option for an example of exact coding. PL/1 and COBOL versions of this guide are available.

*--------------------------------------------------------------------*
 *  First, initialize your environment and set on specific tracing. *
 *--------------------------------------------------------------------*
 CALL ’TDINIT’ ...  
 CALL ’TDSETLOG’ ... (global flag: OFF,
       API flag: ON, 
       header flag: OFF, 
       data flag: OFF)... 
 
 *-------------------------------------------------------------------*
 * Enable packet tracing (option 01) for a specific transaction.*
 *-------------------------------------------------------------------*
 CALL ’TDSETSPT’ ... (trace flag: ON,
       trace option: 01,
       tran ID: MYT1)...  
 
 *-------------------------------------------------------------------*
 * Use the same parameter values except the transaction ID*
 * in the next seven TDSETSPT calls.*
 *-------------------------------------------------------------------*
 CALL ’TDSETSPT’ ... (tran ID: MYT2)... 
 CALL ’TDSETSPT’ ... (tran ID: MYT3)... 
 CALL ’TDSETSPT’ ... (tran ID: MYT4)... 
 CALL ’TDSETSPT’ ... (tran ID: MYT5)... 
 CALL ’TDSETSPT’ ... (tran ID: MYT6)... 
 CALL ’TDSETSPT’ ... (tran ID: MYT7)... 
 CALL ’TDSETSPT’ ... (tran ID: MYT8)...                                 
 
 *------------------------------------------------------------------*
 * With tracing on, begin to accept and process client requests.			*
 *------------------------------------------------------------------*
 CALL ’TDACCEPT’
 .
 .
 .

At this point, the trace table looks like this:

Table 5-2: Sample trace table (1)

Transaction ID

Tracing flag

MYT1

TRUE

MYT2

TRUE

MYT3

TRUE

MYT4

TRUE

MYT5

TRUE

MYT6

TRUE

MYT7

TRUE

MYT8

TRUE

Later, you decide to turn on tracing for one more transaction, MYT9:

 *-------------------------------------------------------------------*
 * Try to turn on packet tracing for MYT9.                           *
 *-------------------------------------------------------------------*
 CALL ’TDSETSPT’ ... (trace flag: ON,
            trace option: 01,
            tran ID: MYT9)...
 *-------------------------------------------------------------------*
 * The operation fails, and you get a return code of SOS,            *
 * indicating that the trace table is full.                          *
 * The contents of the trace table do not change.                    *
 * To make room in the table for MYT9, you decide to                 *
 * turn tracing off for MYT0.                                        *
 *-------------------------------------------------------------------*
 CALL ’TDSETSPT’...(trace flag: OFF,
            trace option: 01,
            tran ID: MYT0)...
 *-------------------------------------------------------------------*
 * The operation fails, and you get a return code                    *
 * of ENTRY NOT FOUND, indicating that there is no such              *
 * transaction listed in the trace table.                            *
 * The contents of the trace table do not change.                    *
 *-------------------------------------------------------------------*
 * Since you apparently don‘t have an up-to-date list of the         *
 * contents of the trace table, you use TDLSTSPT to survey           *
 * all entries.                                                      *
 *                                                                   *
 * TDLSTSPT returns an array containing eight elements, each         *
 * containing the transaction ID of an entry in the trace table      *
 * for which tracing is TRUE.                                        *
 *-------------------------------------------------------------------*
 CALL ’TDLSTSPT’ ...
 *-------------------------------------------------------------------*
 * You decide to turn tracing off for MYT3.                          *
 *-------------------------------------------------------------------*
 CALL ’TDSETSPT’ ...(trace flag: OFF,
            trace option: 08,
            tran ID: MYT3)...
 *-------------------------------------------------------------------*
 * The operation succeeds;  the return code is OK.                   *
 *-------------------------------------------------------------------* 

The trace table now looks like this:

Table 5-3: Sample trace table (2)

Transaction ID

Tracing flag

MYT1

TRUE

MYT2

TRUE

MYT3

FALSE

MYT4

TRUE

MYT5

TRUE

MYT6

TRUE

MYT7

TRUE

MYT8

TRUE

NoteThe third position in the trace table is now considered empty.

When you try again to turn tracing on for MYT9, TDSETSPT moves it into the open position in the trace table.

*-------------------------------------------------------------------*
 * Try to enable tracing for MYT9.                                   *
 *-------------------------------------------------------------------*
 CALL ’TDSETSPT’ ...(trace flag: ON,
            trace option: 01,
            tran ID: MYT9)
 .
 .
 .

The trace table now looks like this:

Table 5-4: Sample trace table (3)

Transaction ID

Tracing flag

MYT1

TRUE

MYT2

TRUE

MYT9

TRUE

MYT4

TRUE

MYT5

TRUE

MYT6

TRUE

MYT7

TRUE

MYT8

TRUE

Still later, you decide to turn on tracing for MYT2:

*-------------------------------------------------------------------*
 * Try to enable tracing for MYT2.                                   *
 *-------------------------------------------------------------------*
 CALL ’TDSETSPT’ ... (trace flag: OFF,
            trace option: 01,
            tran ID: MYT2)... 
 *-------------------------------------------------------------------*
 * The operation fails. You get a TDS DUPLICATE ENTRY return code, as*
 * tracing is already enabled for the transaction–no action needed.  *
 *-------------------------------------------------------------------*




Copyright © 2005. Sybase Inc. All rights reserved. Accounting

View this book as PDF