Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Core issue with Sentry tracing #2961

Open
2 tasks done
KristofDeTroch opened this issue Mar 14, 2025 · 3 comments
Open
2 tasks done

[BUG] Core issue with Sentry tracing #2961

KristofDeTroch opened this issue Mar 14, 2025 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@KristofDeTroch
Copy link

Describe the Bug

When running a Mastra agent in an environment with Sentry for error monitoring the interop crashes on tracing interactions. It is not possible to disable tracing in Mastra and overriding it with a dummy handler results in not getting any responses and no api calls being made.
This is the dummy config we built:

const response = await this.proposalAgent.generate([{ role: 'user', content }], {
      telemetry: {
        isEnabled: true,
        tracer: {
          startActiveSpan: () => ({}) as any,
          startSpan: () => ({}) as any,
        },
      },
      output: dailyBriefItemSchema,
      maxRetries: config.genAi.maxRetries,
});

The error we get is:

Image

The sentry source where this fails can be found in: https://github.com/getsentry/sentry-javascript/blob/5c4cab7b34c736ecd5c029048ba14181dabaaa9f/packages/opentelemetry/src/propagator.ts

Full thread can be found in discord: https://discord.com/channels/1309558646228779139/1350044378357563415

Steps To Reproduce

We added an example gist here: https://gist.github.com/ljobse/ca4fe4cc404c881782e51922d64cd428

Expected Behavior

  1. Disabling tracing should not break behaviour
  2. Interop with Sentry would be nice

Environment Information

@mastra/core@0.4.4
Node@20.12.0

Component

Integrations

Code Snippet

Error Logs

Additional Context

No response

Verification

  • I have searched the existing issues to make sure this is not a duplicate
  • I have included sufficient information for the team to reproduce and understand the issue
@KristofDeTroch KristofDeTroch added the bug Something isn't working label Mar 14, 2025
@ljobse
Copy link

ljobse commented Mar 17, 2025

I've been looking into this and have 1 very bad workaround:
Initializing sentry with skipOpenTelemetrySetup: true, will skip the invalid spans from being picked up. Obviously this will also drop all other spans so tracing will no longer work correctly in sentry.

I think there are 2 major issues here:

  1. Disabling tracing does not actually disable any collection of spans. This is due to the decorator setup and the global telemetry configuration
  2. Invalid spans are being registered. I think this is due to BaggageTracer but I don't really see why the opentelemetry data is structured differently from what sentry expects.

@TylerBarnes
Copy link
Contributor

@wardpeet tagging you in since I believe you know about our telemetry setup

@Michielnuyts
Copy link

Running into the same issue at the moment. (0.7.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants