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
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();
- 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.