Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tomer-yechiel/pino-sentry-transport
https://github.com/tomer-yechiel/pino-sentry-transport
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/tomer-yechiel/pino-sentry-transport
- Owner: tomer-yechiel
- License: mit
- Created: 2022-06-14T19:21:16.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-25T20:11:34.000Z (10 months ago)
- Last Synced: 2024-04-26T12:03:56.794Z (8 months ago)
- Language: TypeScript
- Size: 1.45 MB
- Stars: 19
- Watchers: 1
- Forks: 8
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-opensource-israel - pino-sentry-transport - Send logs from pino to Sentry. ![GitHub last commit](https://img.shields.io/github/last-commit/tomer-yechiel/pino-sentry-transport?style=flat-square) ![GitHub top language](https://img.shields.io/github/languages/top/tomer-yechiel/pino-sentry-transport?style=flat-square) ![GitHub stars](https://img.shields.io/github/stars/tomer-yechiel/pino-sentry-transport?style=flat-square) (Projects by main language / typescript)
README
# Pino Sentry transport
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![bundle][bundle-src]][bundle-href]
[![JSDocs][jsdocs-src]][jsdocs-href]
[![License][license-src]][license-href][//]: # ([![GitHub Workflow Status](https://github.com/tomer-yechiel/pino-sentry-transport/actions/workflows/pino-sentry-transport.yml/badge.svg?branch=main)](https://github.com/tomer-yechiel/pino-sentry-transport/actions))
**Pino Sentry Transport** allows you to send logs from [Pino](https://github.com/pinojs/pino) directly to [Sentry](https://sentry.io/).
## Installation
```shell
npm i pino-sentry-transport
```## Usage
```typescript
import pino from "pino";const logger = pino({
transport: {
target: "pino-sentry-transport",
options: {
sentry: {
dsn: "https://:@sentry.io/",
// additional options for sentry
},
withLogRecord: true, // default false - send the entire log record to sentry as a context.(FYI if its more then 8Kb Sentry will throw an error)
tags: ['level'], // sentry tags to add to the event, uses lodash.get to get the value from the log record
context: ['hostname'], // sentry context to add to the event, uses lodash.get to get the value from the log record,
minLevel: 40, // which level to send to sentry
expectPinoConfig: true, // default false - pass true if pino configured with custom messageKey or errorKey see below
}
},
});
```### Configuration Options
- **`withLogRecord`**: When set to `true`, sends the entire log record as context to Sentry. Be cautious of log records larger than 8KB, as Sentry will throw an error.
- **`tags`**: An array specifying which fields from the log record should be added as tags in Sentry. Uses `lodash.get` to extract values.
- **`context`**: An array specifying which fields from the log record should be added as context in Sentry. Also uses `lodash.get` for value extraction.
- **`minLevel`**: The minimum log level required for a message to be sent to Sentry. Log levels follow Pino's conventions (e.g., 40 for 'error').
- **`expectPinoConfig`**: If set to `true`, allows the transport to work with custom `messageKey` or `errorKey` settings in Pino.### Sentry initialization
Because Pino transport runs in a separate worker thread, Sentry needs to be [initialized](https://docs.sentry.io/platforms/javascript/configuration/webworkers/#usage-with-worker-level-initialization) in the transport.### License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.[npm-version-src]: https://img.shields.io/npm/v/pino-sentry-transport
[npm-version-href]: https://npmjs.com/package/pino-sentry-transport
[npm-downloads-src]: https://img.shields.io/npm/dm/pino-sentry-transport
[npm-downloads-href]: https://npmjs.com/package/pino-sentry-transport
[bundle-src]: https://img.shields.io/bundlephobia/minzip/pino-sentry-transport?label=minzip
[bundle-href]: https://bundlephobia.com/result?p=pino-sentry-transport
[license-src]: https://img.shields.io/github/license/tomer-yechiel/pino-sentry-transport.svg
[license-href]: https://github.com/tomer-yechiel/pino-sentry-transport/blob/main/LICENSE
[jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12
[jsdocs-href]: https://www.jsdocs.io/package/pino-sentry-transport