Splunk AppDynamics

Setup up AppDynamics agent on Go lang application

Abhishek_Tiwari
New Member

I am having golang application and want to connect to AppDynamics. But when I am creating an application I am not able to find any machine agent for go lang application. Although they are providing go SDK. But I am not able to send data with the help of that.

Labels (1)
0 Karma

Kyle_Furlong
Contributor

Hi Abhishek,

Are both the Go SDK and machine agent for the server independently reporting?

0 Karma

T_c
New Member

@Kyle.Furlong 
> Are both the Go SDK and machine agent for the server independently reporting?

I've downloaded the Golang SDK and done basic setup. It can report to the controller (although i dont see the same details that my nodejs or java service has). Is it required to also install a machine agent?

0 Karma

Kyle_Furlong
Contributor

Hi T.c,

No, it is not required to install the machine agent. It is only recommended if you would like to have infrastructure metrics for the instance.

As you noted, the Go SDK does not provide the same level of instrumentation as our full-fledged agents. You will need to integrate the SDK functions into your code to surface the data which you are interested in.

We are in the process of R&D on a solution for Go which is more like our Java agent, but I can provide no timeline or further details in the present moment.

0 Karma

Suman_Ailineni
New Member

How GoLang SDK knows controller details to report.

Thanks,

Kumar

0 Karma

Kyle_Furlong
Contributor

Hi  Suman,

Please check the docs and go through the install steps: https://docs.appdynamics.com/display/PRO45/Using+Go+SDK

Regards,

Kyle

Morelz
Builder

Hi There

As mentioned with Golang it's a Dynamics Agent, where you have to use the AppDynamics SDK to implement the instrumentation into your Golang Application

Please find belowa sample Golang Application that has a single BT & just does a remote http service call.

This is just to have an example of how it would be instrumented

==================================================================================

package main

import (
appd "appdynamics"
"net/http"
"log"
"io/ioutil"
"fmt"
"os"
"time"
)

func main() {

fmt.Printf("About to run golang test process...\n")

cfg := appd.Config{}

cfg.AppName = "Go_App"
cfg.TierName = "GoTier"
cfg.NodeName = "gonode1"
cfg.Controller.Host = "controller.saas.appdynamics.com"
cfg.Controller.Port = 443
cfg.Controller.UseSSL = true
cfg.Controller.Account = "customer1"
cfg.Controller.AccessKey = "xxxxxxxxx"
cfg.InitTimeoutMs = 30000

fmt.Printf("about to call InitSDK(InitTimeoutMS = %d)...", cfg.InitTimeoutMs)
if err := appd.InitSDK(&cfg); err != nil {
fmt.Printf("Error initializing the AppDynamics SDK\n")
os.Exit(1)
} else {
fmt.Printf("Initialized AppDynamics SDK successfully\n")
}
backendName := "HTTPBE"
backendType := "HTTP"
backendProperties := map[string]string {
"URL": "https://httpbin.org/get",
}
resolveBackend := false

appd.AddBackend(backendName, backendType, backendProperties, resolveBackend)

for loop := 0; loop < 3000; loop++ {
btHandle := appd.StartBT("GoTestBT1", "")
ecHandle := appd.StartExitcall(btHandle, backendName)
hdr := appd.GetExitcallCorrelationHeader(ecHandle)
resp, err := http.Get("https://httpbin.org/get")
fmt.Printf(hdr)
if err != nil {
log.Fatalln(err)
}

body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatalln(err)
log.Println(string(body))

}
appd.EndExitcall(ecHandle)
appd.EndBT(btHandle)
fmt.Printf("Loop %d: Got BT handle %x\n", loop, btHandle)

time.Sleep(1 * time.Second)

if loop%10 == 0 {
fmt.Printf("Setting error for loop #%d\n", loop)
appd.AddBTError(btHandle,appd.APPD_LEVEL_ERROR,"Error message test string",true)
}

appd.EndBT(btHandle)
}

fmt.Println("calling term()...")

appd.TerminateSDK()

fmt.Println("done")
}

===================================================================================

Ciao

Get Updates on the Splunk Community!

New This Month - Splunk Observability updates and improvements for faster ...

What’s New? This month, we’re delivering several enhancements across Splunk Observability Cloud for faster and ...

What's New in Splunk Cloud Platform 9.3.2411?

Hey Splunky People! We are excited to share the latest updates in Splunk Cloud Platform 9.3.2411. This release ...

Buttercup Games: Further Dashboarding Techniques (Part 6)

This series of blogs assumes you have already completed the Splunk Enterprise Search Tutorial as it uses the ...