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

How to disable HTTP headers injection? #6285

Open
MatanAti opened this issue Nov 14, 2024 · 5 comments
Open

How to disable HTTP headers injection? #6285

MatanAti opened this issue Nov 14, 2024 · 5 comments

Comments

@MatanAti
Copy link

Hey, I am having a real hard time disabling HTTP headers injection
I have a .NET core 3.1 application which I run, and I am having issues where external sites block me due to additional headers:
X-Datadog-Parent-Id, X-Datadog-Sampling-Priority, X-Datadog-Tags, X-Datadog-Trace-Id
I have no reason to have this in my service, don't want to attach anything to the HTTP requests going out.
Here is how I define the tracer:

            var settings = TracerSettings.FromDefaultSources();
            Tracer.Configure(settings);

What can I do?
TIA.

@link04
Copy link
Contributor

link04 commented Nov 14, 2024

Hello @MatanAti, so in this case you can disable it by setting DD_TRACE_PROPAGATION_STYLE_INJECT="", with an empty value no headers are injected as opposed to the defaults we set for context propagating and connecting traces out of the box.

Related configuration documentation and Trace Context Propagation details, hopping this helps your case.

@MatanAti
Copy link
Author

Hi @link04 thanks for the reply
I tried that, and for some reason it didn't work for me in the C# application I have.
On the other hand, for the TS application it did.

Its needed to be added as ENV variable, right?
Is that anything perhaps I can do from code? as your suggested solution just not working for some reason for me.
TIA

@link04
Copy link
Contributor

link04 commented Nov 14, 2024

So it should indeed be added as an env var depending on how the app is running, we recommend that as opposed to adding in code changes. For your C# service, I wanted to make sure that you added the env var either on the main directory of the service or registry if applicable and restarted your service, it needs to be fully stop and started so the tracer can pick up the new configuration.

If the env var is available for your service then the Startup Logs will include the following value for trace_propagation_style_inject:
"trace_propagation_style_inject":["\"\""],"trace_propagation_style_extract":["Datadog","tracecontext"]

If even after restarting your service or checking the logs the setting is not taken into account, will recommend you reaching out to the Datadog Support | Help Center where we can take a look at the logs and help you out without showcasing your service data.

@MatanAtiasLSports
Copy link

Hi, I have this ENV variable, that seems like for some reason is causing the headers to still be injected: CORECLR_ENABLE_PROFILING=1
Can you please explain if this env variable is critical and what different values I can put in it? as seems like just removing it causes no traces to go out?
Without it requests go out without the headers

@link04
Copy link
Contributor

link04 commented Nov 18, 2024

Hello @MatanAtiasLSports, so CORECLR_ENABLE_PROFILING=1 enables tracing for the .NET/.NET Core services hence why removing makes it so that no traces show up at all as we don't try to trace the service, a colleague recommended setting DD_TRACE_PROPAGATION_STYLE_INJECT=none instead of an empty string to disable the injection, I've realized depending on your setup adding an empty string could be interpreted as not set so last thing I think would help you tried is setting the value to none, stopping and starting your service then confirming that the headers are not injected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants