Getting Access to Logrus Hooks

We rely quite heavily on k6 extensions in our current setup. One thing we’d like to be able to do is integrate with sentry to pick up on any exceptions our extensions run into. Our first attempt at doing this was to wrap the CLI:

func main() {
	err := sentry.Init(sentry.ClientOptions{
		Dsn:     "SomeDSN",
	if err != nil {
		log.Fatalf("sentry.Init: %s", err)
	defer sentry.Flush(2 * time.Second)


However, this doesn’t work since sentry doesn’t quite support logrus and, even if it did, I’m not positive sentry would be able to pick up exceptions since k6 code uses a custom logger threaded throughout.

One approach I was considering was creating a k6 extension that can somehow grab the existing logrus logger and add new hooks. Is that possible?

I do think moving logging to its own extension would help and I’m reasonably interested in helping; however, I’m trying to find a workaround in the meantime.

I am not sure why you want to tap into logrus, why not just catch the exceptions and log them that way? Something like this:

export default function() {
    try {
        // ... your test code ...
    } catch (e) {
        throw e; // re-throw

I am not sure you even need an xk6 extension for Sentry, they probably have an HTTP REST API that would be perfectly usable with vanilla k6 scripts :man_shrugging:

True - this will probably work. Thanks for the fast response!