How to use the @sentry/utils.logger.warn function in @sentry/utils

To help you get started, we’ve selected a few @sentry/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github getsentry / sentry-javascript / packages / apm / src / span.ts View on Github external
}

    this.spanRecorder.finishSpan(this);

    if (this.transaction === undefined) {
      // If this has no transaction set we assume there's a parent
      // transaction for this span that would be flushed out eventually.
      return undefined;
    }

    if (this.sampled === undefined) {
      // At this point a `sampled === undefined` should have already been
      // resolved to a concrete decision. If `sampled` is `undefined`, it's
      // likely that somebody used `Sentry.startSpan(...)` on a
      // non-transaction span and later decided to make it a transaction.
      logger.warn('Discarding transaction Span without sampling decision');
      return undefined;
    }
    const finishedSpans = this.spanRecorder ? this.spanRecorder.finishedSpans.filter(s => s !== this) : [];

    if (useLastSpanTimestamp && finishedSpans.length > 0) {
      this.timestamp = finishedSpans[finishedSpans.length - 1].timestamp;
    }

    return this._hub.captureEvent({
      contexts: {
        trace: this.getTraceContext(),
      },
      spans: finishedSpans,
      start_timestamp: this.startTimestamp,
      tags: this.tags,
      timestamp: this.timestamp,
github getsentry / sentry-javascript / packages / hub / src / hub.ts View on Github external
private _callExtensionMethod(method: string, ...args: any[]): T {
    const carrier = getMainCarrier();
    const sentry = carrier.__SENTRY__;
    // tslint:disable-next-line: strict-type-predicates
    if (sentry && sentry.extensions && typeof sentry.extensions[method] === 'function') {
      return sentry.extensions[method].apply(this, args);
    }
    logger.warn(`Extension method ${method} couldn't be found, doing nothing.`);
  }
}
github getsentry / sentry-javascript / packages / node / src / handlers.ts View on Github external
client.close(timeout).then((result: boolean) => {
      if (!result) {
        logger.warn('We reached the timeout for emptying the request buffer, still exiting now!');
      }
      global.process.exit(1);
    }),
  );
github getsentry / sentry-javascript / packages / core / src / integrations / inboundfilters.ts View on Github external
private _shouldDropEvent(event: Event, options: InboundFiltersOptions): boolean {
    if (this._isSentryError(event, options)) {
      logger.warn(`Event dropped due to being internal Sentry Error.\nEvent: ${getEventDescription(event)}`);
      return true;
    }
    if (this._isIgnoredError(event, options)) {
      logger.warn(
        `Event dropped due to being matched by \`ignoreErrors\` option.\nEvent: ${getEventDescription(event)}`,
      );
      return true;
    }
    if (this._isBlacklistedUrl(event, options)) {
      logger.warn(
        `Event dropped due to being matched by \`blacklistUrls\` option.\nEvent: ${getEventDescription(
          event,
        )}.\nUrl: ${this._getEventFilterUrl(event)}`,
      );
      return true;
    }
    if (!this._isWhitelistedUrl(event, options)) {
      logger.warn(
        `Event dropped due to not being matched by \`whitelistUrls\` option.\nEvent: ${getEventDescription(
          event,
github getsentry / sentry-javascript / packages / browser / src / transports / fetch.ts View on Github external
.then(response => {
            const status = Status.fromHttpCode(response.status);

            if (status === Status.Success) {
              resolve({ status });
              return;
            }

            if (status === Status.RateLimit) {
              const now = Date.now();
              this._disabledUntil = new Date(now + parseRetryAfterHeader(now, response.headers.get('Retry-After')));
              logger.warn(`Too many requests, backing off till: ${this._disabledUntil}`);
            }

            reject(response);
          })
          .catch(reject);
github getsentry / sentry-javascript / packages / apm / src / integrations / tracing.ts View on Github external
idleTimeout: 500,
      shouldCreateSpanForRequest(url: string): boolean {
        const origins = (_options && _options.tracingOrigins) || defaultTracingOrigins;
        return (
          origins.some((origin: string | RegExp) => isMatchingPattern(url, origin)) &&
          !isMatchingPattern(url, 'sentry_key')
        );
      },
      startTransactionOnLocationChange: true,
      traceFetch: true,
      traceXHR: true,
      tracesSampleRate: 1,
      tracingOrigins: defaultTracingOrigins,
    };
    if (!_options || !Array.isArray(_options.tracingOrigins) || _options.tracingOrigins.length === 0) {
      logger.warn(
        'Sentry: You need to define `tracingOrigins` in the options. Set an array of urls or patterns to trace.',
      );
      logger.warn(`Sentry: We added a reasonable default for you: ${defaultTracingOrigins}`);
    }
    Tracing.options = this._options = {
      ...defaults,
      ..._options,
    };
  }
github getsentry / sentry-javascript / packages / core / src / basebackend.ts View on Github external
public constructor(options: O) {
    this._options = options;
    if (!this._options.dsn) {
      logger.warn('No DSN provided, backend will not do anything.');
    }
    this._transport = this._setupTransport();
  }
github getsentry / sentry-javascript / packages / browser / src / transports / xhr.ts View on Github external
request.onreadystatechange = () => {
          if (request.readyState !== 4) {
            return;
          }

          const status = Status.fromHttpCode(request.status);

          if (status === Status.Success) {
            resolve({ status });
            return;
          }

          if (status === Status.RateLimit) {
            const now = Date.now();
            this._disabledUntil = new Date(now + parseRetryAfterHeader(now, request.getResponseHeader('Retry-After')));
            logger.warn(`Too many requests, backing off till: ${this._disabledUntil}`);
          }

          reject(request);
        };
github getsentry / sentry-javascript / packages / hub / src / hub.ts View on Github external
public getIntegration(integration: IntegrationClass): T | null {
    const client = this.getClient();
    if (!client) {
      return null;
    }
    try {
      return client.getIntegration(integration);
    } catch (_oO) {
      logger.warn(`Cannot retrieve integration ${integration.id} from the current Hub`);
      return null;
    }
  }
github getsentry / sentry-javascript / packages / core / src / baseclient.ts View on Github external
public getIntegration(integration: IntegrationClass): T | null {
    try {
      return (this._integrations[integration.id] as T) || null;
    } catch (_oO) {
      logger.warn(`Cannot retrieve integration ${integration.id} from the current Client`);
      return null;
    }
  }