Skip to main content

Go Agent Configuration

Modify Application Name​

By default, the Go Agent uses the file name as the application name. If you need to change the application name to another format, set the environment variable TINGYUN_APP_NAME before starting the application.

export TINGYUN_APP_NAME=NewAppName

# Then start the Go application

For Docker containers:

docker run -e TINGYUN_APP_NAME=NewAppName image

Change Log Level​

The configuration file is located at installation_path/conf/goagent.conf

# Agent log level, supports error info debug
agent.log.level = info

# Daemon log level, supports error info debug
daemon.log.level = debug

# Audit mode
daemon.log.audit = true

Go SDK Configuration & Operation

When using the Go SDK, to maximize application security, for already instrumented applications, the default is that instrumentation logic is disabled if not configured.

Set Environment Variables​

To enable Go SDK monitoring, you need to set the environment variable TINGYUN_GO_APP_CONFIG to specify the configuration file path. This must be set before the application starts; setting it within the application is invalid.

$ export TINGYUN_GO_APP_CONFIG=/[configfilepath]/tingyun.conf
$ /your app path/appname [your app args]

Modify Configuration File​

The Go SDK configuration file is tingyun.conf. Please refer to the configuration item descriptions in the file for setup. Example content:

######## Application Configuration ########

# Set application name (string), optional, defaults to process name
# app_name = "My Go App"

# Agent enable flag (bool), optional, defaults to true
# agent_enabled = true

######## License / Server Configuration #########

# License key (string), required, cannot be empty
# license_key = "999-999-999"

# Collector server address, multiple addresses separated by commas, required, cannot be empty
# collector.address = "collector_ip:port"

# Whether to use SSL (https) to send requests to the collector server, default is false
# ssl = false

######## Log Configuration ########

# Log file path, required. If empty or not set, no log output
agent_log_file = agent.log

# Log output level, can be set to: debug, info, error, off
# debug: outputs all logs
# info: outputs info and error logs
# error: outputs only error logs
# off: disables log output
# Default: info
agent_log_level = info

# Audit mode (bool), default false; controls log output in conjunction with log level
# If set to false, some audit mode logs will not be output
audit_mode = true

# Log file size (integer, MB), default 10
# When the log file size exceeds this threshold, a new log file will be created, and old logs will be rotated
agent_log_file_size = 10

# Number of log files to keep (integer), default 3
# When the number of log files exceeds this threshold, the oldest files will be deleted
agent_log_file_count = 3

######## Memory Control Thresholds ########

# Maximum number of transaction data objects in the in-memory buffer queue, default 10000
# Exceeding this means too many concurrent requests, and the backend worker cannot process all collected data
# To prevent unlimited memory growth, when the buffer exceeds this threshold, new transaction data will not be collected
action_cache_max = 10000

# Maximum number of transactions per batch sent to the collector, default 5000
action_report_max = 5000

# Length of the data send buffer queue to the collector, default 5
# Exceeding this means network congestion or insufficient collector processing power
# To prevent unlimited memory growth, when the send queue exceeds this threshold, new send requests will be dropped
report_queue_count = 5

# Maximum number of component calls per transaction, default 3000
# After exceeding this, no new component call data will be collected for the transaction
agent_component_max = 3000

# Maximum SQL statement length (bytes), default 5000
# SQL statements longer than this will be truncated
agent_sql_size_max = 5000

Supported Environment Variables​

In some special cases, you may need to flexibly control configuration items via environment variables. As a supplement to the configuration file, the Go SDK also provides support for the following environment variables:

Environment VariableDescription
agent_enabledEnable agent option, values: true/false; default: true
audit_modeAudit mode, enable audit mode logs, values: true/false; default: false
agent_log_levelLog level, values: debug/info/error/off; default: info
agent_log_fileLog file path
license_keyLicense key
collectorsCollector server address, multiple addresses separated by commas
agent_init_delayAgent initialization delay (integer, seconds), default 1. Note: If the agent initializes too early, it may start before the application listens, causing the agent to miss the application's listening port. Increase the initialization delay to resolve this.
TINGYUN_GO_APP_NAMEApplication name