Distributed Message Tracer
com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_link3' is unknown.

Distributed Message Tracer

The Distributed Message Tracer solution allows you to trace the list of events that belong to a message and search through its results. A message is a single user activity that may invoke one or more services that independently generate events that are sent to WSO2 SP for processing. In addition, the activity itself generates an event that is considered the parent events.

e.g., When a transaction being processed passes through many subsystems, you can search through events collected from different subsystems to check whether the transaction is completed, the subsystem at which it is currently being processed etc. 

This solution allows you to set up the Message Tracers to match different scenarios.

 The Distributed Message Tracer solution is packed with WSO2 SP by default. To use this solution, follow the sections below:

To try out the Distributed Message Tracer, you can run the Message Tracer sample shipped with WSO2 Stream Processor. For detailed instructions to run a sample, see Samples.

Setting up the Message Tracer

This step involves configuring a Siddhi application in a way that allows the required details relating to activities can be captured and processed as required. To do this, let's define a business rule via the WSO2 SP Business Rules Manager as follows. For more information, see  Creating Business Rules . 

  1. In your terminal, navigate to the <SP_HOME>/bin directory. Then issue one of the following commands to start the dashboard server.

    • On Windowsdashboard.bat --run

    • On Linux/Mac OS: ./dashboard.sh

     

  2. Start a WSO2 SP worker runtime by issuing one of the following commands from the <SP_HOME>/bin directory.

    • On Windowsworker.bat --run

    • On Linux/Mac OS./worker.sh

  3. Access the Business Rules Manager via one of the following URLs.

  4. If you do not have any business rules that are already created, click Create. If there are existing rules, click to create a new rule.

     

  5. Click Template to create the business rule from the business template that is already available in the Distributed Message Tracer solution.

     

  6. Click on Message Tracer to create your business rule from the Message Tracer template group.


    This opens the Message Tracer page. 

  7. To configure the Siddhi application, select Message Tracer App Template in the Rule Template field.

      
    This opens the Message Tracer App Template business rules template. 

  8. Enter the required information in the fields of the Message Tracer App Template business rules template as follows.

  9. Click SAVE & DEPLOY. The rule you create is added as shown in the example below.

  10. Click +and enter another business rule from the Message Tracer Source Template template with the following information.

  11. Click SAVE & DEPLOY.

Tracing messages in the dashboard

To trace activities via the Message Tracer dashboard, follow the procedure below:

  1. Access the Dashboard Portal via one of the following URLs.

    • http://<SP_HOST>:<HTTP_PORT>/portal (e.g.,  http://localhost:9290/portal )

    • https://<SP_HOST>:<HTTPS_PORT>/portal (e.g.,  https://localhost:9643/portal )

  2. Log in with your credentials. The Distributed Message Tracer dashboard is included in the dashboard listing as shown below.

  3. Click on the Distributed Message Tracer dashboard to open the dashboard. The widgets in the dashboard are displayed as follows.

  4. To filter the information you want to view in the dashboard, do the following:

    1. In the Service field, select the service for which you want to view message statistics.

    2. Click on the required date range in the Date Range widget to view message statistics for the required time period. If the time period for which you want to view statistics is not displayed in this widget, you can click Custom and select a specific time interval.

Once you enter information to filter message statistics to be displayed, click SEARCH. The available traces are displayed in the Tracing List section as shown in the example below.

 

Once you click on the required trace ID, information related to the trace is displayed as shown in the following example.

 

Using the WSO2 SP Message Trace client

To publish messages to be traced WSO2 SP Message Trace client, you need to wrap the WSO2 SP Message Trace client as shown below once you develop the service, and get a WSO2 SP Tracer instance.

// createStreamProcessorTracerClient instance StreamProcessorTracerClient streamProcessorTracerClient = new StreamProcessorTracerClient(); Properties tracerProperties = new Properties(); // read configuration file and populate tracerProperties. // The following properties needed to initialize the tracer. /* * reporter.wso2sp.publisher.type: thrift * reporter.wso2sp.publisher.username: admin * reporter.wso2sp.publisher.password: admin * reporter.wso2sp.publisher.url: tcp://localhost:7611 * reporter.wso2sp.publisher.authUrl: ssl://localhost:7711 * reporter.wso2sp.publisher.service.name: WSO2 MSF4J * trace.name: wso2sp * reporter.wso2sp.publisher.databridge.agent.config: /Users/ramindu/wso2/git/sinthuja/msf4j/samples/message-tracing/open-tracing/src/main/resources/data.agent.config.yaml * javax.net.ssl.trustStore: /Users/ramindu/wso2/git/sinthuja/msf4j/samples/message-tracing/open-tracing/src/main/resources/wso2carbon.jks * javax.net.ssl.trustStorePassword: wso2carbon */ tracerProperties.setProperty(WSO2SP_REPORTER_PUBLISHER_TYPE, configRegistry.getConfigOrDefault(getFullQualifiedConfig(WSO2SP_REPORTER_PUBLISHER_TYPE), DEFAULT_WSO2SP_REPORTER_PUBLISHER_TYPE_CONFIG)); tracerProperties.setProperty(WSO2SP_REPORTER_USERNAME, configRegistry.getConfigOrDefault(getFullQualifiedConfig(WSO2SP_REPORTER_USERNAME), DEFAULT_WSO2SP_REPORTER_USERNAME)); tracerProperties.setProperty(WSO2SP_REPORTER_PASSWORD, configRegistry.getConfigOrDefault(getFullQualifiedConfig(WSO2SP_REPORTER_PASSWORD), null)); tracerProperties.setProperty(WSO2SP_REPORTER_URL, configRegistry.getConfigOrDefault(getFullQualifiedConfig(WSO2SP_REPORTER_URL), DEFAULT_WSO2SP_REPORTER_URL)); tracerProperties.setProperty(WSO2SP_REPORTER_AUTHURL, configRegistry.getConfigOrDefault(getFullQualifiedConfig(WSO2SP_REPORTER_AUTHURL), DEFAULT_WSO2SP_REPORTER_AUTHURL)); tracerProperties.setProperty(WSO2SP_REPORTER_AUTHURL, configRegistry.getConfigOrDefault(getFullQualifiedConfig(WSO2SP_REPORTER_AUTHURL), DEFAULT_WSO2SP_REPORTER_AUTHURL)); tracerProperties.setProperty(WSO2SP_REPORTER_DATABRIDGE_AGENT_CONFIG, configRegistry.getConfigOrDefault(getFullQualifiedConfig(WSO2SP_REPORTER_DATABRIDGE_AGENT_CONFIG), null)); tracerProperties.setProperty(WSO2SP_REPORTER_TRUSTSTORE, configRegistry.getConfigOrDefault(getFullQualifiedConfig(WSO2SP_REPORTER_TRUSTSTORE), null)); tracerProperties.setProperty(WSO2SP_REPORTER_TRUSTSTORE_PASSWORD, configRegistry.getConfigOrDefault(getFullQualifiedConfig(WSO2SP_REPORTER_TRUSTSTORE_PASSWORD), null)); tracerProperties.setProperty(TRACER_NAME, TRACER_VALUE); streamProcessorTracerClient.init(tracerProperties); //create the trace using the service name and ScopeManager and return the WSO2 SP tracer streamProcessorTracerClient.getTracer(serviceName, NoOpSco

Using the WSO2 SP Message Trace Client with Ballerina

Before you begin:

Download Ballerina from here.

Install it by following the instructions in the Ballerina Installation Guide.

To run the Message Trace Client with Ballerina, follow the steps below:

  1. Clone the ballerina-observability repository.

  2. To build the ballerina-sp-extension component, navigate to the ballerina-observability/tracing-extensions/modules/ballerina-sp-extension directory and issue the following command:
    mvn clean install

    This creates JAR files in the target of the component.

  3. Copy the JAR files created in the ballerina-sp-extension component, and place them in the bre/lib directory of the Ballerina distribution.

  4. Create a ballerina sample service as follows, and save it as HelloWorldService.bal in a preferred location in your machine.

    import ballerina/http; import ballerina/log; service<http:Service> hello bind { port: 9099 } { sayHello(endpoint caller, http:Request req) { http:Response res = new; res.setPayload("Hello, World!"); caller->respond(res) but { error e => log:printError( "Error sending response", err = e) }; } }
  5. Download the resources from  and unzip.

  6. Add the following to ballerina.conf file. You need to change the file path destinations to the javax.net.ssl.trustStore.

    [b7a.observability.tracing] enabled=true name="wso2sp" [b7a.observability.tracing.wso2sp] reporter.wso2sp.publisher.type="thrift" reporter.wso2sp.publisher.username="admin" reporter.wso2sp.publisher.password="admin" reporter.wso2sp.publisher.url="tcp://localhost:7611" reporter.wso2sp.publisher.authUrl="ssl://localhost:7711" reporter.wso2sp.publisher.databridge.agent.config="/Users/ramindu/wso2/message-tracing/open-tracing/src/main/resources/data.agent.config.yaml" javax.net.ssl.trustStore="/Users/ramindu/wso2/message-tracing/open-tracing/src/main/resources/wso2carbon.jks" javax.net.ssl.trustStorePassword="wso2carbon" reporter.wso2sp.publisher.service.name="ballerina_hello_world"
com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.