Skip to content

Disable sentry-trace headers #12302

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

Closed
3 tasks done
nCrafts opened this issue May 31, 2024 · 4 comments
Closed
3 tasks done

Disable sentry-trace headers #12302

nCrafts opened this issue May 31, 2024 · 4 comments
Labels
Package: browser Issues related to the Sentry Browser SDK

Comments

@nCrafts
Copy link

nCrafts commented May 31, 2024

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/browser

SDK Version

8.5.0

Framework Version

2.5.10

Link to Sentry event

No response

SDK Setup

Sentry.init({
  dsn: "https://xxxxx.ingest.sentry.io/xxxxx",
  enableTracing: false,
  sampleRate: 0,
  tracesSampleRate: 0,
  autoSessionTracking: false,
  tracePropagationTargets: ["example.com"],
});

Steps to Reproduce

See above code

Expected Result

Sentry should simply be processing server exceptions and logging them. No other 'features' should be enabled.

Actual Result

I am trying to use Sentry to capture server errors but I don't know how to prevent it from just taking over. It's adding sentry-trace and baggage headers to HTML pages, and there seems to be no way to disable it. Things seem opt-out when they should be opt-in.

From what I can tell the tracePropagationTargets setting should allow me to disable it, but it doesn't seem to work. I've set tracePropagationTargets to example.com but it's still sending out those headers with all requests.

I am caching my HTML pages at the edge which would probably make these headers useless anyways.

Another user brought up a similar issue before.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 May 31, 2024
@github-actions github-actions bot added the Package: browser Issues related to the Sentry Browser SDK label May 31, 2024
@mydea
Copy link
Member

mydea commented May 31, 2024

Hey,

the thing that controls the headers is tracePropagationTargets. If you do not set this, and tracing is not enabled, not headers should be attached to any requests.

With the config you set, sentry-trace header would be attached to any URL matching "example.com".

Just to be clear, are you talking about @sentry/browser? (this is what you selected in the issue template) Because not sure how that would interact with HTML pages at all...?

@nCrafts
Copy link
Author

nCrafts commented May 31, 2024

I have tried both configurations with no success. Here is my current config. I removed the tracePropagationTargets. The headers are still being injected:

Sentry.init({
  dsn: "https://xxxxx.ingest.sentry.io/xxxxx",
  enableTracing: false,
  sampleRate: 0,
  tracesSampleRate: 0,
  autoSessionTracking: false,
});

Note that previously I was using ["example.com"] which also shouldn't inject those headers since example.com shouldn't match any URI on my server. The other relevant parts of my hooks.server.ts file:

import * as Sentry from "@sentry/sveltekit";
import { sentryHandle } from "@sentry/sveltekit";

const myErrorHandler = ({ error, event }: { error: any; event: any }) => {
  return {
    message: "Whoops!",
    code: error?.code ?? "UNKNOWN",
  };
};

export const handleError = Sentry.handleErrorWithSentry(myErrorHandler);
  
  export const handle = sequence(
    sentryHandle({
      injectFetchProxyScript: false,
    })
  );
  

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 May 31, 2024
@mydea
Copy link
Member

mydea commented Jun 3, 2024

Hey,

can you try just removing all trace sample rates completely, we handle it slightly different if it is defined vs. not defined.
Also, setting tracePropagationTargets: [] should generally disable setting this at all.

Sentry.init({
  dsn: "https://xxxxx.ingest.sentry.io/xxxxx",
  sampleRate: 0,
  autoSessionTracking: false,
  tracePropagationTargets: [],
});

Does that work?

@nCrafts
Copy link
Author

nCrafts commented Jun 3, 2024

That worked. Merci!

@nCrafts nCrafts closed this as completed Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: browser Issues related to the Sentry Browser SDK
Projects
Archived in project
Development

No branches or pull requests

2 participants