Make asking about codes and debugging efficient with New Relic CodeStream

newrelicgolang

New Relic CodeStream is a plugin which is useful to ask about codes, create issue or PR and debug on IDE for IntelliJ, VSCode and so on.

Install

Install the plugin to IDE and set the integretion.

Comment

You can comment to code blocks to ask about it, or create an issue.

If Slack integration is set, following post is submited.

By “Open in IDE” button, you can jump to the target line and response a comment.

Debug

By default, New Relic’s Errors Inbox stores 4xx, 5xx responses except for 404, but you can also send other errors with NoticeError().

func BrokenFunc() error {
	return newrelic.Error{
		Message:    "Func is broken",
		Class:      "FuncError",
		Attributes: map[string]interface{}{},
		Stack:      newrelic.NewStackTrace(),
	}
}

if err := BrokenFunc(); err != nil {
    nrecho.FromContext(c).NoticeError(err)
    return c.String(http.StatusInternalServerError, "XD")
}

The status code treated as Error can be specified as follows.

app, err := newrelic.NewApplication(
    newrelic.ConfigAppName("test_app"),
    newrelic.ConfigLicense(os.Getenv("NEWRELIC_LICENSE_KEY")),
    newrelic.ConfigDistributedTracerEnabled(true),
    func(cfg *newrelic.Config) {
        cfg.ErrorCollector.IgnoreStatusCodes = []int{
            http.StatusBadRequest,
            http.StatusNotFound,
        }
    },
)

Passing following Environment variables,

$ export [email protected]:sambaiz/newrelic-codestream-example.git
$ export NEW_RELIC_METADATA_COMMIT=$(git rev-parse HEAD)

“Open in IDE” from Errors Inbox is enabled.

If newrelic.Error has stack traces, it can be tracked.

Error can be contained assignees and comments. These would be useful from the initial action for system failure to the post-mortem.