I am unable to monitor my go project with the new relic
I am able to monitor using JAVA
I have follows the documentation steps: https://docs.newrelic.com/docs/apm/agents/go-agent/installation/install-new-relic-go/
From github.com/newrelic/go-agent, use your preferred process; for example: bash command
go get github.com/newrelic/go-agent/v3/newrelicImport the github.com/newrelic/go-agent/v3/newrelic package in your application.
import github.com/newrelic/go-agent/v3/newrelicInitialize the Go agent by adding the following in the main function or in an init block:
app, err := newrelic.NewApplication( newrelic.ConfigAppName("Your Application Name"), newrelic.ConfigLicense("YOUR_NEW_RELIC_LICENSE_KEY") )
NOTE: I have follows all the trouble shooting as well.
main.go
package main
import (
    "fmt"
    "io"
    "net/http"
    "github.com/newrelic/go-agent/v3/newrelic"
)
var newrelicApp *newrelic.Application
func main() {
    app, err := newrelic.NewApplication(
        newrelic.ConfigAppName("MyAppMain"),
        newrelic.ConfigLicense("<YOUR_NEW_RELIC_LICENSE_KEY>"),
        newrelic.ConfigAppLogForwardingEnabled(true),
    )
    if err != nil {
        fmt.Printf("error is " + err.Error())
    } else {
        newrelicApp = app
        http.HandleFunc(newrelic.WrapHandleFunc(app, "/test", customEvent))
    }
}
func customEvent(w http.ResponseWriter, req *http.Request) {
    io.WriteString(w, "recording a custom event")
    newrelicApp.RecordCustomEvent("MyAppMainEvent", map[string]interface{}{
        "text":      "Hello VP",
        "env":       "go_local",
        "alertType": "error",
        "priority":  "Critical",
        "source":    "MyAppMain",
    })
}
				
                        
you don't have to store the app in a global variable and override the existing one, this will cause issues, and also you need to start a web server. i updated the code: