-
Notifications
You must be signed in to change notification settings - Fork 879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I use multiple targets and pipelines? #1302
Comments
This is not currently possible. You can't mix & match. |
I'll give it a try - I could see this as a nice to have in preparation to the v8 release |
Heya! I was just thinking the same thing and came across this issue. It looks like @dbacarel's fork hasn't had any commits in relation to this particular feature, so I started poking around myself to see what a potential PR might look like. From what I understand, the With the way those workers are written, I see a couple of potential solutions. Solution 1: Abuse the existing functionality of worker.jsEssentially instead of setting the top-level 'target' to Implementation summaryIn User input optionsIdentical to as they exist now {
targets: [
/* Targets as mapped from the "targets" property */
{target: 'target1', /*(...)*/},
{target: 'target2', /*(...)*/},
/*(...)*/
},
pipeline: [
{target: 'pipelineTarg1', /*(...)*/},
{target: 'pipelineTarg2', /*(...)*/},
]
} Resultant options structure/*options.targets*/ {
targets: [
/* Targets as mapped from the "targets" property */
{target: 'target1', /*(...)*/},
{target: 'target2', /*(...)*/},
/*(...) rest of options.targets targets*/
// pipeline target
{
target: bundlerOverrides['pino-pipeline-worker'] || join(__dirname, 'worker-pipeline.js'),
options: {
targets: [
{target: 'pipelineTarg1', /*(...)*/},
{target: 'pipelineTarg2', /*(...)*/}
]
}
}
} In essence, it just utilizes When Pros:
Cons:
Solution 2: Sol 1, but with modified user inputSimilar to solution 1, but involves some logic rewrites and an addition to the API. Instead of using the top-level pipeline property, we can take a boolean property within each obj in the targets array, eg TL;DR: Different input, same output as sol 1. Also allows for multiple pipeline outputs. Implementation summaryUser input options{
targets: [
/* Targets as mapped from the "targets" property */
{target: 'target1', /*(...)*/},
{target: 'target2', /*(...)*/},
/*(...)*/
{
pipeline: true,
targets: [
{target: 'pipelineTarg1', /*(...)*/},
{target: 'pipelineTarg2', /*(...)*/},
]
}
} Code example// lib/transport.js
if (targets) {
target = bundlerOverrides['pino-worker'] || join(__dirname, 'worker.js')
options.targets = targets.map((dest) => {
if(!dest.pipeline)
return {
...dest,
target: fixTarget(dest.target)
}
else {
return {
options: {...dest.targets},
target: bundlerOverrides['pino-pipeline-worker'] || join(__dirname, 'worker-pipeline.js')
}
})
} Solution 3: New worker transportWe could create a new worker file, I'm gonna skip over the implementation here since the input/output options are the same as prior, and the new transport would essentially just be a small transport. ConsiderationsI've got no idea what the performance impact of one, let alone multiple pipelines running under the I'm sure there are other things I'm missing too so thoughts and criticism are of course welcome. @mcollina, would you mind giving this a skim at some point? I'd love to have a bit of a sanity check, as well as a confirmation that this is still within y'alls scope before starting work on a real PR haha. |
What seems the most interesting to me is the creation of a mixed-worker.js that can handle multiple targets and pipelines. |
Gotcha, I'll start chipping away at a PR then! |
how is progress with this draft? |
@bmaupin facing some problem, did you find workaround to your issue? |
@ouya99 No, being able to log to syslog and stdout at the same time is a requirement for us so we used winston and winston-syslog instead. |
Can we have this feature anytime soon? |
If someone contributes it (or is willing to fund its development). |
@mcollina It would be immensely helpful if this could be developed. Would you be able to get the PR from @Starkrights merged? If necessary, I may be able to put some work into it. |
@mcollina i'm able to contribute too |
That PR still needs work (tests, docs) to be finished. |
second time's the charm, meantime I missed also the v9 release deadline 🥲 . I pushed a draft PR (at the moment is a prototype) to propose the introduction of named pipelines. Will continue polishing it but wanted to taste the waters first regarding the idea. |
Targets and (multiple) pipelines can now be defined within Example of usage is shown in documentation page: In addition, levels can be also specified for each pipeline too. The feature is available in the v9.1.0 released yesterday Thanks @mcollina for the review and feedbacks. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I'd like to be able to send logs to syslog and to stdout.
I know I need a pipeline for syslog (pino-syslog+pino-socket), and that works fine, e.g.
My guess would be that I'd need to combine
pipeline
withtargets
so that I can send the logs to multiple targets; one target for stdout (I'm testing with pino-pretty but the format doesn't really matter) and the other target for the syslog pipeline.I tried this:
But it throws this error:
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
Thanks!
The text was updated successfully, but these errors were encountered: