grafana / k6

A modern load testing tool, using Go and JavaScript - https://k6.io
GNU Affero General Public License v3.0
24.93k stars 1.23k forks source link

Log output as xk6 extension #1939

Open ivanape opened 3 years ago

ivanape commented 3 years ago

I was reading about xk6 extension and this amazing way to provide new features to k6.

I have reviewed the code for https://github.com/li-zhixin/xk6-influxdbv2 and I was wondering if there is a similar options to extend the log support.

In fact, yesterday I have sent the PR (https://github.com/k6io/k6/pull/1938) to extend the log support for k6, but I think I would be nice to add this feature with a xk6 extension.

Checking the k6 code in https://github.com/k6io/k6/tree/master/log, I have not seen any option to extend the logger support.

So, my questions are... could we add new loggers support using xk6? If not, there is a plan to provide this support?

Thank you!

Iván

na-- commented 3 years ago

Ah, sorry, I didn't realize this issue was opened until after I answered to you in the PR (https://github.com/k6io/k6/pull/1938#issuecomment-810863937) :sweat_smile:

We'll discuss this internally, but yes, we're more likely to support extensions for log outputs than we're likely to merge built-in ones for log outputs that aren't very common. I don't see a big reason not to support log extensions, so it's likely going to happen at some point.

ivanape commented 3 years ago

Thank you @na--!

Please, let me know if I can help to support this requirement.

na-- commented 3 years ago

We discussed this a bit internally and decided that we'd like to have log output extensions, eventually. It's not a priority and we probably won't work on it ourselves for the next few versions, but we might accept a PR with the required refactoring and functions to support log output extensions.

Also, before we support log output extensions, we should switch the current logging library we use, github.com/sirupsen/logrus, to something else, since it's in maintenance mode and since it's more than a bit inconvenient to integrate with it. We might switch to github.com/uber-go/zap (https://github.com/k6io/k6/issues/216) or to some other structured logging library, we need to do some research. We'd also accept a PR for that, if anyone is interested in working on it :sweat_smile: