Skip to content

[Question/Bug] Can't report Transactions on multiple instances with different DSNs #4185

Closed
@mitzafon-wix

Description

@mitzafon-wix

Package + Version

  • @sentry/browser
  • @sentry/node
  • raven-js
  • raven-node (raven for node)
  • other: @sentry/react

Version:

@sentry/browser: 6.15.0
@sentry/react: 6.15.0

Description

My client consists of a platform with a global Sentry (using Sentry.init) and micro services that each has its own Sentry Hub with a different DSN (using new Sentry.Hub).

When I try and use transactions, I see that only the global Sentry can send transactions, and all of my micro services transactions reporting are "failing silently" (I don't see any request on the Network Tab).

I also tried to reproduce it on the same app and I encountered the issue.
Is it by design? Can I make it work somehow?

// App.ts

import * as Sentry from '@sentry/react'; // tried with @sentry/browser as well

Sentry.init({
  dsn: 'XXXXXXXXXXXXXXXX',
  integrations: [
    new Integrations.BrowserTracing(),
  ],

  // for the sake of debugging
  tracesSampleRate: 1.0,
  beforeSend(event) {
     // some unrelated logic
     return event;
  },
});

This component reports transactions for the global/main Sentry:

// AmazingComponent.ts
import * as Sentry from '@sentry/react';

const transaction = Sentry.startTransaction({ name: 'shopCheckout' });
console.log('After transaction start, before finish');
transaction.finish(); // Reports this transaction!

This component doesn't reports transactions for the a Sentry Hub:

// CoolComponent.ts
import * as Sentry from '@sentry/react';

const newHub = new Sentry.Hub(
      new Sentry.BrowserClient({
        dsn: 'YYYYYYYYYYYYYYYYY', // different DSN than the Sentry.init one
        integrations: [
          new Integrations.BrowserTracing(),
        ],
      }),
    );

const newHubTransaction = newHub.startTransaction({
    name: 'InnerTransaction',
});

console.log('After Hub transaction start, before finish');
newHubTransaction.finish(); // nothing is reported to Sentry

P.S

I can report exceptions via the Hub (i.e using newHub.captureException(...) is being reported successfully).

P.S 2 🎮 😉

I don't think a solution involving makeMain each time I want to report a transaction is valid, because I have many micro services that can report at the same time...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions