tencent cloud

Tencent Cloud Observability Platform

Release Notes and Announcements
Release Notes
Product Introduction
Overview
Strengths
Basic Features
Basic Concepts
Use Cases
Use Limits
Purchase Guide
Tencent Cloud Product Monitoring
Application Performance Management
Mobile App Performance Monitoring
Real User Monitoring
Cloud Automated Testing
Prometheus Monitoring
Grafana
EventBridge
PTS
Quick Start
Monitoring Overview
Instance Group
Tencent Cloud Product Monitoring
Application Performance Management
Real User Monitoring
Cloud Automated Testing
Performance Testing Service
Prometheus Getting Started
Grafana
Dashboard Creation
EventBridge
Alarm Service
Cloud Product Monitoring
Tencent Cloud Service Metrics
Operation Guide
CVM Agents
Cloud Product Monitoring Integration with Grafana
Troubleshooting
Practical Tutorial
Application Performance Management
Product Introduction
Access Guide
Operation Guide
Practical Tutorial
Parameter Information
FAQs
Mobile App Performance Monitoring
Overview
Operation Guide
Access Guide
Practical Tutorial
Tencent Cloud Real User Monitoring
Product Introduction
Operation Guide
Connection Guide
FAQs
Cloud Automated Testing
Product Introduction
Operation Guide
FAQs
Performance Testing Service
Overview
Operation Guide
Practice Tutorial
JavaScript API List
FAQs
Prometheus Monitoring
Product Introduction
Access Guide
Operation Guide
Practical Tutorial
Terraform
FAQs
Grafana
Product Introduction
Operation Guide
Guide on Grafana Common Features
FAQs
Dashboard
Overview
Operation Guide
Alarm Management
Console Operation Guide
Troubleshooting
FAQs
EventBridge
Product Introduction
Operation Guide
Practical Tutorial
FAQs
Report Management
FAQs
General
Alarm Service
Concepts
Monitoring Charts
CVM Agents
Dynamic Alarm Threshold
CM Connection to Grafana
Documentation Guide
Related Agreements
Application Performance Management Service Level Agreement
APM Privacy Policy
APM Data Processing And Security Agreement
RUM Service Level Agreement
Mobile Performance Monitoring Service Level Agreement
Cloud Automated Testing Service Level Agreement
Prometheus Service Level Agreement
TCMG Service Level Agreements
PTS Service Level Agreement
PTS Use Limits
Cloud Monitor Service Level Agreement
API Documentation
History
Introduction
API Category
Making API Requests
Monitoring Data Query APIs
Alarm APIs
Legacy Alert APIs
Notification Template APIs
TMP APIs
Grafana Service APIs
Event Center APIs
TencentCloud Managed Service for Prometheus APIs
Monitoring APIs
Data Types
Error Codes
Glossary
DokumentasiTencent Cloud Observability PlatformApplication Performance ManagementAccess GuideAccessing Go ApplicationIntegrating Go Applications Via OpenTelemetry Compilation Enhancement Solution

Integrating Go Applications Via OpenTelemetry Compilation Enhancement Solution

PDF
Mode fokus
Ukuran font
Terakhir diperbarui: 2025-10-13 19:10:48
Note:
OpenTelemetry is a collection of tools, APIs, and SDKs used to detect, generate, collect, and export telemetry data (metrics, logs, and traces) to help users analyze the performance and behavior of the software. For more information about OpenTelemetry, please refer to the OpenTelemetry official website.
The OpenTelemetry community is active, with rapid technological change, extensive compatibility with mainstream programming languages, components, and frameworks, making its link-tracing capability for cloud-native microservices and container architectures widely popular.
The OpenTelemetry compilation enhancement solution is based on the community opentelemetry-go-auto-instrumentation project for further development. With this solution, Go applications can access Application Performance Management (APM) without modifying the business code. This solution provides automatic event tracking support for commonly used Go dependency libraries and frameworks, including Gin, GORM, and gRPC. For other dependency libraries and frameworks that support automatic event tracking, please see the complete list.

Prerequisites

Go version 1.23 or higher.
For dependency libraries and frameworks that require automatic event tracking, please ensure the minimum version requirement is met. For details, please refer to Dependency Libraries and Frameworks Supporting Automatic Event Tracking.

Operation Steps

Step 1. Getting the Access Point and Token

1. Log in to the TCOP console.
2. Select APM > Application list in the left menu bar, then click Access application.
3. In the Application application drawer frame that pops up on the right, click the Go language.
4. On the Access Go application page, select the Region and Business System.
5. Select OpenTelemetry as Access protocol type.
6. Select your preferred Reporting method, and obtain your Access Point and Token.
Note:
Report over private network: This reporting method requires your service to run in the Tencent Cloud VPC. The direct connectivity through VPC helps avoid the security risks of public network communication and saves costs on reporting traffic.
Report over public network: If your service is deployed locally or in non-Tencent Cloud VPC, you can report data in this method. However, it involves security risks in public network communication and incurs reporting traffic fees.

Step 2: Download Tool

Step 3: Lock the Version of OpenTelemetry Related SDK (Optional)

To avoid compilation errors caused by upstream OpenTelemetry SDK version updates, manually lock its version, for example, version v1.35.0:
go mod edit -require=go.opentelemetry.io/otel@v1.35.0
go mod edit -require=go.opentelemetry.io/otel/sdk@v1.35.0
go mod edit -require=go.opentelemetry.io/otel/trace@v1.35.0
go mod edit -require=go.opentelemetry.io/otel/metric@v1.35.0

Step 4: Compile the Application

Grant execution permission to the tool.
chmod +x otel
Add the otel prefix to the Go compilation command to complete the application compilation. For example, the go build ... command will be modified to ./otel go build ....
./otel go build -o app

Step 5: Add Environment Variable

Add the following environment variables to the Go application's runtime environment, then start the application:
OTEL_EXPORTER_OTLP_ENDPOINT=<endpoint> \\
OTEL_SERVICE_NAME=<serviceName> \\
OTEL_EXPORTER_OTLP_PROTOCOL=grpc \\
OTEL_TRACES_EXPORTER=otlp \\
OTEL_RESOURCE_ATTRIBUTES=token=<token>,host.name=<hostName> \\
./app
The corresponding field descriptions are as follows. Replace based on the actual situation.
<serviceName>: application name. Multiple application processes connecting with the same serviceName are displayed as multiple instances under the same application in APM. The application name can contain up to 63 characters, can only contain lowercase letters, digits, and the separator "-", and must start with a lowercase letter and end with a digit or lowercase letter.
<token>: business system Token obtained in preliminary steps.
<hostName>: The hostname of this instance, which is the unique identifier of the application instance. It can usually be set to the IP address of the application instance.
<endpoint>: The access point obtained in the previous step. Note that you must add the http://prefix.

Access Verification

After completing the integration steps, the Go application will report monitoring data to the APM server. In normal traffic cases, the connected application will be displayed in Application Performance Monitoring > Application list. Click Application name/ID to enter the application details page, and then select Instance Analysis to view the connected application instance. Since there is latency in the processing of observable data, please wait about 30 seconds if the application or instance does not appear in the console after connecting.

Custom Event Tracking Enhancement

When the automatic event tracking scope of the compilation enhancement solution does not meet your scenarios, or you need to add business layer event tracking, you can refer to Accessing the Go Application Through the OpenTelemetry SDK (Recommended) to perform custom event tracking enhancement based on the OpenTelemetry SDK. Custom event tracking enhancement supplements the compilation enhancement solution. Both share the same trace context and will not cause conflict.

Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan