This will result in a instance in Error Reporting:
{
"severity": "ERROR",
"message": "hello error",
"@type": "type.googleapis.com/google.devtools.clouderrorreporting.v1beta1.ReportedErrorEvent"
}
(severity is not taken into consideration, I managed to get a INFO
severity "error" into Error Reporting)
This will also result in a message in Error Reporting:
{
"severity": "ERROR",
"message": "hello error",
"stack_trace": "goroutine 8 [running]:\nmain.main.func2({0x6f0948, 0xc0000d6000}, 0xc0000b6700)\n\t/app/main.go:42 +0x6c\nnet/http.HandlerFunc.ServeHTTP(0xc000045af0?, {0x6f0948?, 0xc0000d6000?}, 0x0?)\n\t/usr/local/go/src/net/http/server.go:2109 +0x2f\nnet/http.(*ServeMux).ServeHTTP(0x0?, {0x6f0948, 0xc0000d6000}, 0xc0000b6700)\n\t/usr/local/go/src/net/http/server.go:2487 +0x149\nnet/http.serverHandler.ServeHTTP({0xc00006d0e0?}, {0x6f0948, 0xc0000d6000}, 0xc0000b6700)\n\t/usr/local/go/src/net/http/server.go:2947 +0x30c\nnet/http.(*con"
}
BUT; this will not end up as a ERROR in Error Reporting:
{
"severity": "ERROR",
"message": "hello error",
"stack_trace": "fake stack trace"
}
NB: All the JSON messages here are pretty printed, it is important that the JSON you print in your app is on a single line to work with structured logging.
NB2: If you want your errors to be grouped by the service that made them you need to add serviceContext
. E.g.
"serviceContext":{"service":"service-name"}