Initialize the Controller Configuration

Controller information settings permit the SDK to connect to the Controller. Some settings are required for all applications while others are required only for certain types of application environments. For example, if the SDK needs to connect to the Controller via an internal proxy in your network, set up the connection settings for the proxy. See Go SDK Reference for a complete list of settings and which ones are required.

Assign values to the required settings in your application. For example, to set the Controller connection information:

cfg := appd.Config{}
cfg.AppName = "exampleapp"
cfg.TierName = "orderproc"
cfg.NodeName = "orderproc01"
cfg.Controller.Host = "my-appd-controller.example.org"
cfg.Controller.Port = 8090
cfg.Controller.UseSSL = false
cfg.Controller.Account = "customer1"
cfg.Controller.AccessKey = "secret"
cfg.InitTimeoutMs = 1000  // Wait up to 1s for initialization to finish

InitTimeoutMs field. Once you initialize the configuration, you pass the configuration object to the call to initialize the agent via InitSDK(). The InitTimeoutMs field can have these values:

  • When set to 0 , the default, the InitSDK() function operates as an asynchronous action, so that the initialization call does not block your program.
  • Setting the value to -1 instructs the program to wait indefinitely until the controller configuration is received by the agent, that is, the InitSDK () method returns control. This is useful when you want to capture short-running Business Transactions that occur at application startup and you do not mind the delay of waiting for the Controller to send the configuration.
  • Alternatively, set it to a specific number of milliseconds to wait.

If you use a multi-tenant Controller (SaaS or on-premises multi-tenant), you need to create the context for the multi-tenant environments using the AddAppContextToConfig() method. You can then pass the context as a parameter to methods for performing particular operations, such as starting a Business Transaction or adding custom metrics. See Go SDK Reference for AddAppContextToConfig() and related methods.