Use the CICS and IMS SDK for custom tracing

The CICS and IMS SDK supports customer-specific distributed tracing that uses either standard Dynatrace tags or customer-supplied custom tags.

  • It is part of the CICS and IMS modules.
  • It requires no additional license.
  • It supports all common z/OS languages.

The CICS and IMS SDK also provides APIs that let you add nodes to an existing PurePath® distributed trace and associate arguments and return values with them. Each API returns 0 to indicate success or another integer value, positive or negative, to indicate failure. See the list of return codes below.

DTSTUB provides access to SDK functions. Add a DD statement and an INCLUDE to the binder step to include it in your program. For example:

//SZDTLOAD DD DISP=SHR,DSN=_hlq_.SZDTLOAD
...
INCLUDE SZDTLOAD(DTSTUB)

Include API function declarations

You can download and use these include and sample programs:

These sample programs with SDK API calls are also availabe in the <hlq>.SZDTSAMP product dataset.

API naming conventions

Each function name starts with DT, followed by characters that define the purpose of the function and an optional suffix that indicates the argument type.

DTaaaabb
^ ^ ^
| | `- Parameter type:
| | - 'TN' text - null terminated string
| | - 'TP' text - PL/I string
| | - 'TF' text - fixed length string
| | - 'A' byte array
| | - 'S' 16-bit signed integer
| | - 'I' 32-bit signed integer
| | - 'L' 64-bit signed integer
| |
| `-- Method type:
| - 'SP' Start PurePath distributed trace
| - 'SLP' Start linked PurePath distributed trace
| - 'SCLP' Start linked PurePath distributed trace with custom tag
| - 'IL' Insert link
| - 'ICL' Insert link with custom tag
| - 'IAL' Insert asynchronous link
| - 'IACL' Insert asynchronous link with custom tag
| - 'EP' End PurePath distributed trace
| - 'EN' Enter
| - 'EX' Exit
| - 'EXEX' Exit with exception
| - 'DC' Data capture
|
`---- 'DT' prefix

Start PurePath distributed trace

Starts a new CICS or IMS distributed trace that is unrelated to any existing distributed trace.

Note that CICS LINKs, CICS STARTs, and IMS program to program message switches initiated by the transaction being traced automatically create their own linked subpaths.

Parameters

c_string

Distributed trace name specified as a null-terminated string.

pli_string

Distributed trace name specified as a PLI varying string.

fixed_len_string

Distributed trace name specified as a fixed-length string with an explicit length.

length

Length of the specified fixed-length string.

ccsid

Coded character set identifier for the string. Specify a value of zero (0) to use the CICS or IMS region's default code page.

Start linked PurePath distributed trace

Starts a CICS or IMS distributed trace that is a continuation of another PurePath, typically in response to an inbound service request from another platform.

Note that CICS LINKs, CICS STARTs, and IMS program to program message switches initiated by the transaction being traced automatically create their own linked subpaths.

Parameters

binarytag

Standard binary tag specified as a byte array.

customtag

Custom tag specified as a byte array.

c_string

Standard string tag specified as a null-terminated string.

pli_string

Standard string tag specified as a PLI varying string.

fixed_len_string

Standard string tag specified as a fixed-length string with an explicit length.

length

Length of the specified fixed-length string or byte array. Note that this is the length of the tag, not the buffer.

End PurePath distributed trace

Terminates the current distributed trace created by a Start PurePath distributed trace or Start Linked PurePath distributed trace API.

The End PurePath distributed trace API may not be required because the distributed trace ends automatically at the end of the transaction, or when another Start PurePath distributed trace or Start Linked PurePath distributed trace API is used in the same transaction to trace another input message. End PurePath distributed trace should be used before a long running transaction waits for another input message to arrive.

When used, End PurePath distributed trace must be issued by the same transaction that issued the Start PurePath distributed trace or Start Linked PurePath distributed trace, regardless of CICS LINKs, CICS STARTs, or IMS program to program message switches which create their own linked subpaths automatically, which are independent of the SDK.

Parameters

None

Links the current distributed trace to another distributed trace, typically in response to an outbound request from the CICS or IMS application to a server on another platform.

The string or array used with these APIs returns a new tag that is sent with the outbound request, but DTICLA requires the caller to supply a custom tag.

Parameters

binarytag

Standard binary tag returned as a byte array (output).

customtag

Custom tag specified as a byte array (input).

c_string

Standard string tag returned as a null-terminated string (output).

pli_string

Standard string tag returned as a PLI varying string (output).

fixed_len_string

Standard string tag returned as a fixed-length string with an explicit length (output).

length

Length of the supplied byte array (input).

tag_buffer_len

Length of the supplied buffer that is used to return the new tag (input).

Also used as an output parameter by DTILA and DTILTF to return the actual length of the returned array or string.

Links the current distributed trace to another distributed trace, typically in response to an outbound request from the CICS or IMS application to a server on another platform.

This feature is very similar to the Insert link with important difference that it inserts links for outbound requests that do not necessarily operate in a synchronous manner.

The string or array used with these APIs returns a new tag that is sent with the outbound request, but DTIACLA requires the caller to supply a custom tag.

Parameters

binarytag

Standard binary tag returned as a byte array (output).

customtag

Custom tag specified as a byte array (input).

c_string

Standard string tag returned as a null-terminated string (output).

pli_string

Standard string tag returned as a PLI varying string (output).

fixed_len_string

Standard string tag returned as a fixed-length string with an explicit length (output).

length

Length of the supplied byte array (input).

tag_buffer_len

Length of the supplied buffer that returns the new tag (input).

Also used as an output parameter by DTIALA and DTIALTF to return the actual length of the returned array or string.

Enter node

Adds a node to the currently active CICS or IMS subpath to indicate the execution start of a new program or activity.

The number of Exit node and Exit node with exception APIs must equal the number of Enter node APIs. Subpaths with unbalanced numbers of enter and exit APIs are marked as corrupted.

Typically, this API is used by the program calling the named program but it could also be issued at the beginning of the called program. The Enter node API returns a 32-but integer token that must be saved so it can be specified on the associated Exit node or Exit node with exception API.

Parameters

c_string

Program name specified as a null-terminated string.

pli_string

Program name specified as a PLI varying string.

fixed_len_string

Program name specified as a fixed-length string with an explicit length.

length

Length of the specified fixed-length string.

token

A 32-bit binary integer token used to associate this node with the corresponding Exit node (output).

Exit node

Indicates that the program or activity associated with the most recent Enter node API has ended.

Each Exit node or Exit node with exception API pairs with the most recent Enter node API. Subpaths with unbalanced numbers of enter and exit APIs are marked as corrupted.

Related Enter node and Exit node APIs should be issued by the same program in most cases. This is so an exit does not attempt to end a node associated with a program with its own node due to a LE call, CICS LINK, or IMS program to program message switch invoked since the most recent Enter node API.

Parameters

token

The 32-bit integer token that was returned by the most recent Enter Node API that hasn't issued Exit node or Exit node with exception.

Exit node with exception

Indicates that the program or activity associated with the most recent Enter node API ended with an error.

Each Exit node or Exit node with exception request pairs with the most recent Enter node request. Subpaths with unbalanced numbers of enter and exit APIs are marked as corrupted.

Related Enter node and Exit node APIs should be issued by the same program in most cases. This is so an exit does not attempt to end a node associated with a program with its own node due to a LE call, CICS LINK, or IMS program to program message switch invoked since the most recent Enter node API.

Parameters

token

The 32-bit integer token that was returned by the most recent Enter node API that hasn't issued Exit node or Exit node with exception.

Data capture

Provides an argument capture value for a subsequent Enter node API, or the return value for a subsequent Exit node or Exit node with exception API.

Multiple Data capture APIs may be issued before an Enter node API to capture entry arguments, but only one return value may be associated with an Exit node or Exit node with exception API.

An Enter node, Exit node, or Exit node with exception API should always immediately follow one or more Data capture APIs to prevent the captured value being unintentionally associated with another node.

Parameters

c_string

Capture value specified as a null-terminated string.

pli_string

Capture value specified as a PLI varying string.

fixed_len_string

Capture value specified as a fixed-length string with an explicit length.

length

Length of the specified fixed-length string.

ccsid

Coded character set identifier for the string. Specify a value of zero (0) to use the CICS or IMS region's default code page.

int16_value

A 16-bit signed binary value such as a COBOL PIC S9(5) COMP, PLI FIXED BIN 15. C short int, or assembler halfword.

int32_value

A 32-bit signed binary value such as a COBOL PIC S9(9) COMP, PLI FIXED BIN 31. C int, or assembler fullword (F).

int64_value

A 64-bit signed binary value such as a COBOL PIC S9(18) COMP, PLI FIXED BIN 63. C long long int, or assembler doubleword (FD).

API return codes

All APIs return an integer value.

Return CodeAPI TypesActionDescription

0

All

As documented

Success

4

Start PurePath distributed trace

Start linked PurePath distributed trace

None

A distributed trace is already in progress for this transaction.

4

Data capture

Enter node

Exit node

Exit node with exception

End PurePath distributed trace

Insert link

Insert asynchronous link

None

No distributed trace is in progress for this transaction at this time.

8

End PurePath distributed trace

None

A different sensor started the distributed trace that is in progress for this transaction.

8

Start linked PurePath distributed trace

None

The specified tag's format is invalid or the specified string length doesn't match the actual string tag length.

8

Insert link

Insert asynchronous link

None

The supplied buffer is too small to hold the tag.

8

Exit node

Exit node with exception

None

The supplied token is not valid.

12

Start PurePath distributed trace

None

The specified distributed trace name is too long.

12

Start linked PurePath distributed trace

Start linked PurePath distributed trace with custom tag

Insert link with custom tag

Insert asynchronous link with custom tag

None

The specified tag length is negative or too long.

12

Data capture

None

The specified capture string is too long (currently limited to 200 bytes).

12

Enter node

None

The specified node name is too long (currently limited to 8 bytes).

16

Start linked PurePath distributed trace

None

A dummy tag was specified.

2000

All

Correct calling program

A program check occurred in the CICS or IMS instrumentation while handling an SDK API. This is presumably caused by an incorrect argument.

Negative return codes

A negative return code generally indicates that the CICS or IMS instrumentation is not available, so the application program should continue on the assumption that tracing isn't being performed.

In a CICS environment, the CICS DFHRMCAL interface passes SDK requests to the CICS module's task related user exit (TRUE). DFHRMCAL returns undocumented negative values such as -2 if the CICS instrumentation is not active. If negative return codes are encountered, you can use the DTAX transaction to see whether the CICS instrumentation is enabled.

In an IMS environment, a negative return code also indicates that the IMS instrumentation is not available.

  • Return code -1 means the IMS instrumentation is not installed in this IMS subsystem.
  • Return code -4 means the IMS instrumentation is installed but has been disabled.
  • Return code -5 indicates that the installation process is not completed in this dependent region.
  • Return code -5 is expected if the SDK starts a distributed trace in the first transaction to execute after the message region starts or the IMS instrumentation is enabled. Initialization may take a second or two, so this condition may occur for more than one transaction at startup.

If the SDK returns negative return codes while other transactions in the affected dependent region are traced successfully, please contact a Dynatrace product expert via live chat within your Dynatrace environment.

API notes

The CICS and IMS SDK supports COBOL, PL/I, Assembler, and C/C++. PL/I and C provide include members that declare the API functions.

COBOL programs must specify a type such as PIC S9(9) that corresponds to a binary fullword for integer variables such as RC, LENGTH (not a valid COBOL variable name), CCSID, and TAG_BUFER_LEN. Array or string variables can be declared as PIC X(##).

All character string values assume the default EBCDIC code page of the CICS or IMS region unless the API accepts an explicit CCSID override.

The binary tag length is 30 bytes and a string tag may be up to 79 bytes. The tag_buffer_len specifying the area length to hold an output tag argument must be set as follows:

  • DTILA and DTIALA API—30 or more.
  • DTILTF and DTIALTF API—79 or more.
  • DTILTN and DTIALTN API—80 or more to allow for a null terminator byte.
  • DTILTP and DTIALTP API—81 or more to allow for the halfword string length.

It is recommended that code that handles standard string tags should support tags that are significantly larger than the minimum sizes above to minimize compatibility issues with future extended tag formats.

Input string arguments other than tags are currently limited to a maximum length of 200 bytes. This limit does not include the two-byte length of a PLI varying string or the null terminator byte of a null-terminated string, just the text contents of the string.