New Relic Go easy instrumentation does most of the work for you by suggesting changes to your source code that instrument your application with the New Relic Go agent. This tool is currently in preview.
Before you begin, make sure you have:
- The Go-Samples repository cloned locally
- Go-easy instrumentation tool installed:
go install github.com/newrelic/go-easy-instrumentation@latest
- Required environment variables set:
export NEW_RELIC_LICENSE_KEY="your_license_key" export NEW_RELIC_APP_NAME="your_app_name"
-
Hello World
From the root directory, run:
go-easy-instrumentation instrument 1.hello-world -o 1.hello-world/greeting.diff
The instrumentation changes will be saved in 1.hello-world.
-
REST API
Run the following command from the go-easy directory:
Note: Ensure the go-easy repository is cloned under the go-samples directory
go-easy-instrumentation instrument 2.rest-api --output 2.rest-api/rest-api.diff
Check for the
rest-api.diff
file in the 2.rest-api directory. -
Multi-endpoint REST API with Gin
Run the following command:
go-easy-instrumentation instrument 3.gin -o 3.gin/gin-rest.diff
Check for the
gin-rest.diff
file in the 3.gin directory. -
gRPC Client & Server
This requires two separate commands, one for the client and another for the server.
Client
To instrument the gRPC client, run the following command:
go-easy-instrumentation instrument 4.gRpc/client --output 4.gRpc/client/grpc-client.diff
Server
To instrument the gRPC server, run the following command:
go-easy-instrumentation instrument 4.gRpc/server --output 4.gRpc/server/grpc-server.diff