Enrich your Go application's business logs with trace IDs so that you can quickly locate related logs when issues occur and speed up troubleshooting.
Prerequisites
-
You have compiled and deployed your application with the ARMS agent for Go.
-
You have configured log collection using Simple Log Service. For more information, see Data collection overview.
Background
Application Real-Time Monitoring Service (ARMS) correlates trace IDs with business logs in Go microservices by instrumenting logging frameworks. The following table lists the supported frameworks.
|
Component |
Repository address |
Minimum version |
Maximum version |
|
Zerolog |
v1.10.0 |
v1.33.0 |
|
|
Zap |
v1.20.0 |
v1.27.0 |
|
|
Logrus |
v1.5.0 |
v1.9.3 |
|
|
Log |
v1.21 |
No limit |
|
|
Slog |
v1.21 |
No limit |
Enable log and trace correlation
Log on to the ARMS console. In the left-side navigation pane, choose .
On the Application List page, select the region in the top navigation bar and then click the name of the application.
NoteIcons in the Language column have the following meanings:
: a Java application connected to Application Monitoring.
: a Golang application connected to Application Monitoring.
: a Python application connected to Application Monitoring.-: an application connected to Managed Service for OpenTelemetry.
-
In the top navigation bar, choose .
-
On the Custom Configurations tab, in the Application Log Association section, select
Simple Log Serviceas the log source, turn on the Associate Business Logs with Trace ID switch, select the service region, and then bind theProjectandLogstore.Set Correlation Type to Logstore or StoreView, configure the Correlation Index (both full-text index and field-specific indexes are supported), and then click Save.
-
If the trace ID is successfully printed in your application's business logs as shown in the following example, the correlation is successful.
2024/12/09 11:14:39 trace_id=0c74ce6d96528xxx 2 span_id=ae73xxx cedbrequest to mongon server $$$$$$$$$$$$$$ map[Content-Length:[20] Content-Type:[text/plain; charset=utf-8] Date:[Mon, 09 Dec 2024 03:14:39 GMT] Eagleeye-Traceid:[0c74ce6d96528cxxx 2]] $$$$$$$$$$$$$$ -
(Optional) Configure log collection in Simple Log Service to upload application logs to the project and Logstore you bound in a previous step.
By default, ARMS does not collect application logs.
12-09 10:43:38 10.36.45.83 cn-hangzhou.xxx.83 1733712219 k8s-group-c7ab2784bd...d17fa c7ab2784bd8a84020b05...d17fa xxx.101 ad-recommend-server registry.cn-hangzhou...erver insights xxx.83 cn-hangzhou.xxx.83 ad-recommend-server-...bc6xn 65c79c55-9e04-469f-9...9d636 _source_: stderr _time_: 2024-12-09T10:43:38.366744191+08:00 content: 2024/12/09 10:43:38 trace_id=cf6281bdde61f7xxx7dd span_id=7fc65xxx72e[grpc] SayHello message:"Hello Hello"