-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The Pino transport could not be used as a transport (that is, as initialised by `pino.transport()`, but only as a destination, and only in the main thread. This commit makes the Pino transport communicate with the extension directly, which should work from any worker thread -- the assumption being that the extension has been started by the main thread. This works around the fact that the client cannot be serialised and sent across threads. This allows for the Pino transport to be used like other transports, and _alongside_ other transports: ```js const logger = pino({ transport: { targets: [ { target: "@appsignal/nodejs/pino", options: { group: "pino" } }, { target: ... } ] } }) ``` The `pino/index.js` file has been added as a convenience to allow for the target to be referred to as `@appsignal/nodejs/pino`, which is nicer-looking than the transport's real location inside `dist/`.
- Loading branch information
Showing
4 changed files
with
81 additions
and
21 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
.changesets/allow-pino-transport-to-be-used-as-a-transport.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- | ||
bump: patch | ||
type: fix | ||
--- | ||
|
||
Allow Pino transport to be used as a transport. Before, our Pino transport could only be used as a destination: | ||
|
||
```js | ||
import pino from "pino"; | ||
import { Appsignal, AppsignalPinoTransport } from "@appsignal/nodejs"; | ||
|
||
pino(AppsignalPinoTransport({ | ||
client: Appsignal.client, | ||
group: "pino" | ||
})); | ||
``` | ||
|
||
This meant it was not possible to log both to our transport and to another destination. | ||
|
||
Now, it is also possible to use it as a Pino transport, with the `transport` Pino config option or the `pino.transport()` function: | ||
|
||
```js | ||
import pino from "pino"; | ||
|
||
pino({ | ||
transport: { | ||
target: "@appsignal/nodejs/pino", | ||
options: { | ||
group: "pino" | ||
} | ||
} | ||
}); | ||
``` | ||
|
||
It is no longer necessary to pass the AppSignal client to the Pino transport. AppSignal must be active for the Pino transport to work. | ||
|
||
By enabling its use as a transport, it is now possible to use it alongside other transports: | ||
|
||
```js | ||
pino({ | ||
transport: { | ||
targets: [ | ||
// Send logs to AppSignal... | ||
{ target: "@appsignal/nodejs/pino" }, | ||
// ... and to standard output! | ||
{ target: "pino/file" } | ||
] | ||
} | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
* | ||
!/dist/**/* | ||
!/pino/**/* | ||
!/scripts/**/* | ||
scripts/**/*.test.js | ||
!/ext/appsignal_extension.cpp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
"use strict"; | ||
module.exports = require("../dist/pino_transport"); | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters