SumoLogic / sumologic-opentelemetry-js

OpenTelemetry auto-instrumentation bundle for JavaScript
Apache License 2.0
22 stars 3 forks source link

Feature Request: Filter errors #78

Open dheeraj-jn opened 1 year ago

dheeraj-jn commented 1 year ago

Allow to pass a callback to the initialize method to filter the logs to be sent. Use case: to avoid a deluge of false positive errors and benign issues.

Example usage:

window.sumoLogicOpenTelemetryRum.initialize({
  // ...
  collectErrors: true,
  filterLog: (log: LogRecord) => {
    if (log.message.includes('foo')) {
      return undefined; // returning undefined will filter out this log
    }
    log.message = 'Bar ' + log.message; // optional: can modify log
    return log; // return modified log to be used
  }
});

This can be called in recordLog:

  recordLog(log: LogRecord) {
    const newLog = this.filterLog(log);
    if (newLog === undefined) {
      return;
    }
    // ...
  }
TRybakSUMO commented 1 year ago

Hi @dheeraj-jn, thanks for the proposition, I think we will be able to address your request in the next release. Stay tuned!

dheeraj-jn commented 1 year ago

@TRybakSUMO that's great to know! Awaiting the release.