If you use the OpenTelemetry SDK to collect trace data, you can send the trace data to Tracing Analysis, or forward the trace data to Tracing Analysis by using the OpenTelemetry Collector.

Prerequisites

Obtain an authentication token in the Tracing Analysis console. For more information, see Obtain an authentication token.

Directly submit data

If you use the OpenTelemetry SDK to collect the trace data of an application, you can send the trace data to Tracing Analysis over OpenTelemetry gRPC. To do this, you must specify an endpoint and the required authentication information.

  • Endpoint: Replace <endpoint> with the endpoint that you want to use in the "Connect to Tracing Analysis and authenticate clients" topic.
  • Authentication information: Replace <token> in the Authentication: <token> expression with the token that you obtained in the "Connect to Tracing Analysis and authenticate clients" topic. Then, add the expression to the header of a gRPC request.

Sample code in Java:

SdkTracerProvider sdkTracerProvider = SdkTracerProvider.builder()
                .addSpanProcessor(BatchSpanProcessor.builder(OtlpGrpcSpanExporter.builder()
                        .setEndpoint("<endpoint>")
                        .addHeader("Authentication", "<token>")
                        .build()).build())
                .build();
Note
  • Replace <endpoint> with the endpoint of the region to which you want to submit trace data. Example: http://tracing-analysis-dc-bj.aliyuncs.com:8090.
  • Replace <token> with the token that you obtained in the "Connect to Tracing Analysis and authenticate clients" topic. Example: b590lhguqs@3a7xxxxxxx9b_b590lhguqs@53dxxxxx8301.

Use the OpenTelemetry Collector to forward trace data

If you use the OpenTelemetry SDK or the OpenTelemetry Collector to collect the trace data of an application, you must set the Endpoint parameter to the URL of the OpenTelemetry Collector that is deployed on an on-premises host. In this case, you do not need to specify authentication information. However, you must configure an OLTP exporter in the OpenTelemetry Collector. The OLTP exporter contains an endpoint and authentication information. You can use the OLTP exporter to submit trace data to Tracing Analysis.

  1. Download the OpenTelemetry Collector.
  2. Create a configuration file named otel-config.yaml and replace the original exporters section with the following code. For more information, see the sample code that is provided on the Official OpenTelemetry website.
    exporters:
      otlp:
        endpoint: <endpoint>:8090
        tls:
          insecure: true
        headers:
          Authentication: <token>
    Note
    • Replace <endpoint> with the endpoint of the region to which you want to submit trace data. Example: http://tracing-analysis-dc-bj.aliyuncs.com:8090.
    • Replace <token> with the token that you obtained in the "Connect to Tracing Analysis and authenticate clients" topic. Example: b590lhguqs@3a7xxxxxxx9b_b590lhguqs@53dxxxxx8301.

    Example:

    exporters:
      otlp:
        endpoint: tracing-analysis-dc-bj.aliyuncs.com
        tls:
          insecure: true
        headers:
          Authentication: b590lhguqs@3a7xxxxxxx9b_b590lhguqs@53dxxxxx8301
  3. Run the following command to start the OpenTelemetry Collector:
    ./ocb_0.44.0_linux_amd64 --config="./otel-config.yaml"