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

Synchronous errors in node:http request instrumentation does not finish span #5016

Open
ndresselhaus opened this issue Dec 14, 2024 · 0 comments

Comments

@ndresselhaus
Copy link

If a node:http client request is initiated with parameters that cause a synchronous error to be thrown, dd-trace will not finish the instrumented http client span, preventing otherwise-completed traces from being submitted to the Agent, as the child spans are never finished. The example that triggered this issue for us was an inadvertent newline that crept into a header due to a bad config value. The problem went unnoticed for a bit because without traces, we weren't getting error metrics from our endpoint traces alerting us to the issue.

This behavior might be intentional, but I'm not sure what we'd expect to do here. The entire trace getting swallowed is very unexpected.

Expected behaviour
Parent traces (at the very least) are submitted to DataDog for ingestion.

Actual behaviour
No trace is submitted.

Steps to reproduce
I set up a repro in this repo: https://github.com/ndresselhaus/dd-trace-http-bug. It's a simple Express app that can conditionally trigger an HTTP request with a BadHeader value that will cause node:http to throw Invalid character in header content, which is interpreted as an HTTP 500 status from express.

The trace debug logs enabled is DD_TRACE_DEBUG=true demonstrated the behavior:

  • Encoded payload / Request sent to agent trace logs when there's a regular HTTP client 500 error.
  • No such logs when the synchronous "invalid header content" error resulted in no request actually being made.
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

1 participant