This topic describes how to activate Tracing Analysis and dependent services, grant permissions, and report application data to Tracing Analysis. This helps you get started with Tracing Analysis. In the example demonstrated in this topic, a Java application is used.

Prerequisites

  • Tracing Analysis is activated.
  • Log Service is activated.
  • Resource Access Management (RAM) is activated.

Grant Tracing Analysis the permissions to read data from and write data to Log Service

  1. Log on to the Tracing Analysis console.
  2. On the page that appears, click Authorize to grant Tracing Analysis the permissions to read data from and write data to Log Service.
  3. In the message that appears, click OK.

Use Jaeger to report Java application data

In the following example, Jaeger is used to report the data of a Java application. For more information about how to use other clients to report data and how to report the data of applications that are developed in other languages, see the references at the end of this topic.

  1. Download the demo project. Go to the manualDemo directory and run the program as instructed in the README.md file.
  2. Add the following dependency for Jaeger clients to the pom.xml file:
    <dependency>
        <groupId>io.jaegertracing</groupId>
        <artifactId>jaeger-client</artifactId>
        <version>0.31.0</version>
    </dependency>
  3. Set initialization parameters and create a tracer.

    A tracer can be used to create spans to record distributed operation time, transmit data across servers in pass-through mode by using the Extract or Inject method, or set the current span. The tracer also contains data such as the endpoint used for data reporting, local IP address, sample rate, and service name. You can adjust the sample rate to reduce the overhead that is caused by data reporting.

    Note Replace <endpoint> with the endpoint for your client and region. You can log on to the Tracing Analysis console and obtain the endpoint on the Cluster Configurations page.
    // Replace manualDemo with your application name. 
    io.jaegertracing.Configuration config = new io.jaegertracing.Configuration("manualDemo");
    io.jaegertracing.Configuration.SenderConfiguration sender = new io.jaegertracing.Configuration.SenderConfiguration();
    // Replace <endpoint> with the endpoint displayed on the Cluster Configurations page of the Tracing Analysis console. 
    sender.withEndpoint("<endpoint>");
    config.withSampler(new io.jaegertracing.Configuration.SamplerConfiguration().withType("const").withParam(1));
    config.withReporter(new io.jaegertracing.Configuration.ReporterConfiguration().withSender(sender).withMaxQueueSize(10000));
    GlobalTracer.register(config.getTracer());
  4. Record the request data.
    Tracer tracer = GlobalTracer.get();
    // Create a span. 
    Span span = tracer.buildSpan("parentSpan").withTag("myTag", "spanFirst").start();
    tracer.scopeManager().activate(span, false);
    tracer.activeSpan().setTag("methodName", "testTracing");
    // The business logic. 
    secondBiz();
    span.finish();
  5. Wait for 2 to 3 minutes. Then, log on to the Tracing Analysis console and view the reported trace data on the Applications page.

What to do next

After the application data is reported to Tracing Analysis, you can perform the following operations in the Tracing Analysis console: