Setting traceparent in CICS TG clients

Two methods are available to set traceparent in CICS® Transaction Gateway clients. You can create the traceparent using the vendor's implementation, and then set the obtained traceparent in the CICS TG client. The supported clients are Java/JEE/Jakarta and .NET/.Net Core. If traceparent is set in a CICS TG client, it takes a higher precedence than the tracking token. For more information about using tracking token, see Transaction Tracking with TrackingToken

Method 1

Set traceparent as part of the ECIRequest Object, as shown below for the supported clients.

  • Java: ECIRequest.setTraceParent(String traceParent);
  • JEE/Jakarta: ECIInteractionSpec.setTraceParent(String traceParent);
  • .NET and .Net Core: EciRequest.TraceParent= String traceParent;

Method 2

Set the traceparent by implementing the TraceParentInterface interface.

  • Java/JEE/Jakarta:
    • Use the requestExit class that implements RequestExit and TraceParentInterface
    • Java – Configure requestExits using the arguments as shown below:
      -DrequestExits = <fully_qualified_class_name implementing RequestExit, TraceParentInterface>
      Note: CLASSPATH should be set for <fully_qualified_class_name implementing RequestExit, TraceParentInterface>.
    • JEE/Jakarta – Set requestExits to <fully_qualified_class_name implementing RequestExit, TraceParentInterface>. See ECI resource adapter deployment parameters.
      Note: CLASSPATH should be set for <fully_qualified_class_name implementing RequestExit, TraceParentInterface>

    In the following example, BasicMonitorForTraceParentClient class implements requestExit and TraceParentInterface.

    public class BasicMonitorForTraceParentClient implements RequestExit, TraceParentInterface {
    ….
    public String getTrace(RequestEvent requestEvent, Map<RequestData, Object> data) {
    //get traceparent via Vendor logic
    return traceparent;
    }}
  • .NET and .NETCore:

    Configure the traceparent using an external program that implements TraceParentInterface, and then set the TraceParent parameter in appsettings.json as shown below:

    Traceparent”:”<namespace>.<class name>,<dll name>

    In this example, InstanaTracing.cs includes the vendor logic to set the traceparent.

    appsettings.json
    {
        "CtgApplid": "CTGAPP",
        "CtgApplidQualifier": "IBMAPP",
        "TraceParent": "Distributed.Tracing.SpanCreation,dotnettracing",
    }
    application.csproj
    <ItemGroup>
      <Reference Include="dotnettracing">
    <SpecificVersion>False</SpecificVersion>
    <HintPath……../dotnettracing.dll</HintPath>
    </Reference>
    </ItemGroup>
    dotnettracing.csproj
    <Reference Include="IBM.CTG.Core">
          <SpecificVersion>False</SpecificVersion>
          <HintPath>../IBM.CTG.Core.dll</HintPath>
          </Reference>
      </ItemGroup>
    InstanaTracing.cs
    using IBM.CTG;
    namespace Distributed.Tracing
    {
        public class SpanCreation : TraceParentInterface
        {
            public string getTraceParent(string requestEvent)
            {
    //get traceparent via Vendor logic
                          return (String traceparent)
                    }
                }}