This topic shows you 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.

Authorize Tracinng Analysis to read and write your log service data

  1. Log on Link tracing console.
  2. In Overview Page, click Authorization to authorize Tracing Analysis to read and write your log service.
  3. In Cloud resource access authorization, select the required permissions and click Agree to authorize.
    Accessing Log Role

Use Jaeger to report data of a Java application

In the following example, Jaeger is used to report data of a Java application. For more information about how to use other clients to report data and how to report 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. Open the pom. xml file and add the dependency on the Jaeger client.
    <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 Access point information tab of 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 for your client and region. You can log on to the Tracing Analysis console and obtain the endpoint on the Access point information tab of the Cluster Configurations page.
    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 request data.
    Tracer tracer = GlobalTracer.get();
    // Create a Span
    Span span = tracer.buildSpan(&quot;parentSpan&quot;).withTag(&quot;myTag&quot;, &quot;spanFirst&quot;).start();
    tracer.scopeManager().activate(span, false);
    tracer.activeSpan().setTag(&quot;methodName&quot;, &quot;testTracing&quot;);
    // Business logic
    secondBiz();
    span.finish();
  5. Wait for 2 to 3 minutes. Then, log on to the Tracing Analysis console and view the trace data that has been reported 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: