Skip to content

Latest commit

 

History

History
78 lines (60 loc) · 2.66 KB

README.md

File metadata and controls

78 lines (60 loc) · 2.66 KB

Component to DSN Multiplexer

IMPORTANT NOTE: This is a code sample, NOT a supported product, use at your own risk.

Description

A self hosted proxy server written in Golang that serves as a middleware between your app and Sentry. This server allows you to route error events and minidumps from one codebase to multiple Sentry projects using a custom tag called sentry_relay_component

Supported Datamodels

  • Errors
  • Minidumps

Tested SDKs

  • Python
  • Javascript
  • Electron

Configuration

Inside your app, use Sentry.setTag('sentry_relay_component', {component_name}) in places/scenarios where you would like the error event to be routed to a specifc project.

Create a configuration file in JSON format to map components to their respective project DSNs. For example, config.json:

{
    "mapping": {
        "A": "https://[email protected]/1",
        "B": "https://[email protected]/2"
    }
}

Run

The main function should be provided with 3 arguments:

  1. defaultDSN - The DSN of your main/default project where the events will be sent to in cases where sentry_relay_component is not specified or has no mapping in the config file.
  2. ConfigFilePath - A path to a file that contains a JSON object that contains mapping from component name to DSN
  3. numberOfGoWorkers - This argument is set in order to support concurency, each go worker will handle X goroutines, each goroutine will process one event.

Run the proxy with the following command:

go run main <defaultDSN> <configFilePath> <numberOfGoWorkers>

Example:

go run main http://[email protected]/4507374994653185 config.json 20

This starts the server on port 8080. The server listens for incoming requests and forwards them based on the component tags defined in the configuration file.

In your app, initialize Sentry with pointing the DSN to the proxy server.

You will need to substitute your org ingest url with the address of the proxy server.

Example:

Let's say you are runnning this proxy server on:

www.yourserveraddress.com:8080

and the DSN of your main project is:

https://[email protected]/4507374994653185

The DSN that you will be pointing to is:

https://[email protected]:8080/4507374994653185

Initialize Sentry in your app as follows:

Sentry.init({
  dsn: 'https://[email protected]:8080/4507374994653185'
});

Diagram

Screenshot 2024-06-05 at 9 32 47 PM