-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New relic integration with go : I am unable to monitor my go project with new relic #585
Comments
Take a look at this example code and just double check that your implementation is following best practices: https://github.com/newrelic/go-agent/blob/master/v3/examples/server/main.go If you're still having trouble let us know |
Hi @iamemilio, |
When you wrap an http handler with new relic, we pass a transaction into the context. You should use that transaction to call the methods of the go agent application. To run this, first do package main
import (
"fmt"
"io"
"net/http"
"os"
"github.com/newrelic/go-agent/v3/newrelic"
)
func customEvent(w http.ResponseWriter, r *http.Request) {
txn := newrelic.FromContext(r.Context())
io.WriteString(w, "recording a custom event")
txn.Application().RecordCustomEvent("MyAppMainEvent", map[string]interface{}{
"text": "Hello VP",
"env": "go_local",
"alertType": "error",
"priority": "Critical",
"source": "MyAppMain",
})
}
func main() {
app, err := newrelic.NewApplication(
newrelic.ConfigAppName("MyAppMain"),
newrelic.ConfigLicense("YOUR_NEW_RELIC_LICENSE_KEY"),
newrelic.ConfigAppLogForwardingEnabled(true),
)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
http.HandleFunc(newrelic.WrapHandleFunc(app, "/custom_event", customEvent))
http.ListenAndServe(":8000", nil)
} |
hi @urvesh-educloud I am going to close this and assume that the solution provided worked for you. If that is not the case, please re-open the ticket |
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/newrelic
Import the github.com/newrelic/go-agent/v3/newrelic package in your application.
import github.com/newrelic/go-agent/v3/newrelic
Initialize the Go agent by adding the following in the main function or in an init block:
NOTE: I have follows all the trouble shooting as well.
main.go
The text was updated successfully, but these errors were encountered: