Code Monkey home page Code Monkey logo

structured-log-seq-sink's People

Contributors

dependabot[bot] avatar wedvich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

structured-log-seq-sink's Issues

Sink is not handling promise rejections

We are currently using the window.onunhandledrejection function to log any unhandled rejected promises within our code.

The issue we are seeing is that structured-log-seq-sink is not handling any of it's internal promises being rejected, thus causing the window.onunhandledrejection to be raised.

This is causing a infinite loop for us as when the seq server is not available, the fetch promise fails, causing an window.onunhandledrejection event to raised, which we handle and then try to log the error and the cycle continues.

Here is some example code to reproduce the issue

var structuredLog = require('structured-log');
var seqSink = require('structured-log-seq-sink');

var logger = structuredLog.configure()
  .writeTo(seqSink({ url: "http://INVALID_URL_TO_SIMULATE_SEQ_NOT_AVAILABLE" }))
  .writeTo(new structuredLog.ConsoleSink())
  .create();

window.onunhandledrejection = (event) => {
  logger.error(
    'A window.onunhandledrejection exception occured: {errorMessage}',
    event.reason ? event.reason.message : null
  )
  return false
}

logger.info('this causes an infinite loop')

While we can write code to work around the issue, I believe the solution is to swallow any exceptions that occur within the sink. Especially given that we are never given access to the fetch promise to handle ourselves.

Thoughts?

Listen for changes in minimum level from Seq

When using an API key to send events , the minimum accepted level for events can be set for that API key in Seq. A header is returned in the HTTP response with the minimum supported level when logging. This sink could use an internal minimum level filter that's updated by whatever Seq gives it.

  • Add internal minimum level filter
  • Update minimum level with response value from Seq

Add support for batching

Instead of sending events as soon as they arrive, it would be beneficial to batch them and send them at regular intervals to reduce the number of HTTP requests.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.