Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.
This repository was archived by the owner on Oct 23, 2023. It is now read-only.

Feature Request | Allow Multiple Raven Instances #459

@steverice

Description

@steverice

Do you want to request a feature or report a bug?

feature

Has someone had this problem before?

This is the same feature described in getsentry/sentry-javascript#1269, but a request that it be available in raven-node.

To recap:
Our node server executes code that is is affected by other services from multiple teams. Each of these services is developed and managed independently. Each team wants to have a separate DSN so their errors can be monitored separately. At the same time, we have a Raven singleton that captures any uncaught errors (those that are not captured explicitly with captureException).
Unfortunately, the current API doesn’t allow this.

Currently, we accomplish this with some messy manipulation of Raven's internals. Roughly,

const makeRaven = () => {
  const raven = new RavenFactory();
  raven.prototype = RavenFactory.prototype;
  raven.version = Raven.version;
  raven.disableConsoleAlerts = Raven.disableConsoleAlerts;
  raven.utils = ravenUtils;
  raven.transports = ravenTransports;
  raven.parsers = ravenParsers;
  return raven;
};

Object.keys(sentryConfigs).forEach((key) => {
  const ravenConfig = sentryConfigs[key];
  if (key === 'main') {
    const dsn = ravenConfig.dsn;
    // Must configure Raven before doing anything else with it
    Raven.config(dsn, ravenConfig).install();
    // The request handler must be the first middleware on the app
    expressServer.use(Raven.requestHandler());
  } else {
    const extraRaven = makeRaven();
    extraRaven.config(dsn, ravenConfig); // don't install because this shouldn't catch unhandled errors
    Raven._extraRavens = Raven._extraRavens || {};
    Raven._extraRavens[key] = extraRaven;
  }
});

and then we use these by calling Raven._extraRavens[projectName].captureException().

Obviously, this isn't the greatest or most stable solution. API support for this such as added in getsentry/sentry-javascript#1272 would be much preferred.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions