nvanheuverzwijn / monolog-logdna

GNU Lesser General Public License v3.0
21 stars 21 forks source link

Implement batch mode #19

Open slepic opened 9 months ago

slepic commented 9 months ago

Hi,

While I was implementing the other changes I noticed monolog supports batch mode

And the logdna formatter, although it accepts batch mode parameter, there is no way to make the logdna handler+formatter actually perform batch mode.

I think it is doable, but it would probably require to move part of the logic from formatter into the handler specifically, now the formatter returns lines array of just 1 line - it would have to instead just return that one line and the handler would be responsible to send 1 line in normal mode, and many lines in batch mode in a single request.

This could break code for anyone who instantiates manully or extends the LogdnaFormatter.

Do you think it's worth investigating further? It's not like I'm in need of that feature right now, maybe one day... But I just noticed this while digging in the code and it made me thinking maybe the current implementation of LogdnaFormatter is not exactly what monolog intends for the implementations to be...

nvanheuverzwijn commented 9 months ago

That's interesting. I guess batch mode is an optimization ? Do you have a link to documentation or example of the usage ?

slepic commented 9 months ago

I guess batch mode is an optimization ?

Probably. For example the ingestion api of logdna itself can handle multiple records in a single request and there must be others.

Do you have a link to documentation

Well after brief search I didn't find much except for the BufferHandler and OverflowHandler from monolog https://github.com/Seldaek/monolog/blob/main/doc/02-handlers-formatters-processors.md but there's not much doc except for looking at the code. Maybe the batch mode isn't a very spread feature or I haven't looked good enough (I havent :))...

Anyway, I'm not sure it needs be implemented, unless someone wants it.. I don't rn, as I said, it's just something that occured to me during the other changes and something to consider for future...