All Products
Search
Document Center

Application Real-Time Monitoring Service:Associate Go application logs with a traceId

Last Updated:Sep 04, 2026

You can associate your Go application's business logs with a trace by including the traceId. When an issue occurs, you can use the traceId to quickly find the relevant business logs, which helps you locate, analyze, and resolve the problem.

Prerequisites

  • You have compiled and deployed your application with the Go agent.

  • You have configured data collection in Simple Log Service (SLS). For more information, see Data collection overview.

Background

ARMS correlates a traceId with business logs in Go microservices by instrumenting log frameworks. The following log frameworks are supported:

Framework

Repository

Minimum version

Maximum version

Zerolog

https://github.com/rs/zerolog

v1.10.0

v1.33.0

Zap

https://github.com/uber-go/zap

v1.20.0

v1.27.0

Logrus

https://github.com/sirupsen/logrus

v1.5.0

v1.9.3

Log

https://pkg.go.dev/log

v1.21

No limit

Slog

https://pkg.go.dev/log/slog

v1.21

No limit

Enable log association with traceId

  1. Log on to the ARMS console. In the left-side navigation pane, choose Application Monitoring > Application List.

  2. On the Application List page, select the region in the top navigation bar and then click the name of the application.

    Note

    Icons in the Language column have the following meanings:

    • Java icon: a Java application connected to Application Monitoring.

    • image: a Golang application connected to Application Monitoring.

    • image: a Python application connected to Application Monitoring.

    • -: an application connected to Managed Service for OpenTelemetry.

  3. In the top navigation bar, choose Application Configuration > Custom Configurations.

  4. On the Custom Configurations tab, in the Application Log Association Configuration section, set the log source to Simple Log Service (SLS) and turn on the Associate Business Logs with traceId switch. Then, select the region where your SLS is deployed and bind the Project and Logstore.

    Set Association Type to Logstore or StoreView and Association Index to full-text index or a specific field index. Then, click Save.

  5. If the traceId is printed in your application's business logs as shown in the following example, the association is successful.

    2024/12/09 11:14:39  trace_id=0c74ce6d96528xxx2 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:[0c74ce6d96528cxxx2]]
    $$$$$$$$$$$$$$
  6. (Optional) Configure SLS data collection to upload application logs to the Project and Logstore that you bound in the preceding steps.

    By default, ARMS does not collect application logs.

    1  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"