You can send trace data from OpenCensus to the OpenTelemetry Collector by using OpenCensus SDK, and then forward the data to Simple Log Service by using the OpenTelemetry Collector. This topic describes how to forward trace data to Simple Log Service by using the OpenTelemetry Collector.
Prerequisites
A trace instance is created. For more information, see Create a trace instance.
Procedure
Install the OpenTelemetry Collector.
Configure the OpenTelemetry Collector.
Create a file named config.yaml.
Add the following code to the config.yaml file.
Replace the variables in the following code with the actual values. For more information about the variables, see Variables.
receivers: opencensus: endpoint: 0.0.0.0:6850 exporters: logging/detail: loglevel: debug alibabacloud_logservice/traces: endpoint: "${endpoint}" project: "${project}" logstore: "${instance}-traces" access_key_id: "${access-key-id}" access_key_secret: "${access-key-secret}" service: pipelines: traces: receivers: [opencensus] # Set the receivers parameter to opencensus. exporters: [alibabacloud_logservice/traces] # Set the exporters parameter to alibabacloud_logservice/traces. # for debug #exporters: [logging/detail,alibabacloud_logservice/traces]
Table 1. Variables
Variable
Description
Example
${endpoint}
The endpoint of Simple Log Service. The format is ${region-endpoint}. ${region-endpoint} is the endpoint of the project. You can access Simple Log Service by using an endpoint of the Internet, the classic network, or a virtual private cloud (VPC). For more information, see Endpoints.
cn-hangzhou.log.aliyuncs.com
${project}
The name of the Simple Log Service project.
test-project
${instance}
The ID of the trace instance. For more information, see Create a trace instance.
test-traces
${access-key-id}
The AccessKey ID of your Alibaba Cloud account.
We recommend that you use the AccessKey pair of a Resource Access Management (RAM) user who has only the write permissions on the Simple Log Service project. An AccessKey pair consists of an AccessKey ID and an AccessKey secret. For information about how to grant the write permissions on a specific project to a RAM user, see Use custom policies to grant permissions to a RAM user. For information about how to obtain an AccessKey pair, see AccessKey pair.
None
${access-key-secret}
The AccessKey secret of your Alibaba Cloud account.
We recommend that you use the AccessKey pair of a RAM user who has only the write permissions on the Simple Log Service project.
None
Start the OpenTelemetry Collector.
./otelcontribcol_linux_amd64 --config="./config.yaml"
Configure OpenCensus.
Change the endpoint of OpenCensus to the endpoint on which the OpenTelemetry Collector listens. For example, if the endpoint of the OpenTelemetry Collector is ${collector-host}, you must set the endpoint of OpenCensus to ${collector-host}:6850.