Is there a way to output sentry messages to the console

Viewed 159

I'm working on a suite of microservices writting in golang. I have a demo in a couple of months, and by next year these services should be in production. For now, I'm just hashing out all the basics and boilerplate, including calls to sentry.

All of the services make several async requests that set several processes in motion. If one thing fails, I don't want to panic or return; I want to continue execution, but I want to be able to go back and see what happened.

While developing, I don't really want to send anything to Sentry, but I want to see what the output to Sentry would be so I can make sure that the messages, breadcrumbs, stacktraces etc are all being captured as intended. Is anything like this possible? I tried running the local server but it's quite bloated and it fired up about 20 docker containers and consumed a LOT of memory. Just looking for something lightweight so I can see what's going on.

1 Answers

I came up with a solution -- the output is very verbose, but it's exactly what I was looking for (for now). I simply provided my own transport implementation and passed it in to ClientOptions:

type consoleTransport struct{}

func (t *consoleTransport) Configure(options sentry.ClientOptions) {
    zap.L().Info("Sentry client initialized with an empty DSN. Using consoleTransport. No events will be delivered.")
}

func (t *consoleTransport) SendEvent(event *sentry.Event) {
    b, _ := json.Marshal(event)
    fmt.Println("[SENTRY CONSOLE] " + string(b))
}

func (t *consoleTransport) Flush(_ time.Duration) bool {
    return true
}
Related