-
Notifications
You must be signed in to change notification settings - Fork 821
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
fix(instrumentation-http): set outgoing request attributes on start span #2349
Conversation
Looks like I also pushed some layout changes in the |
I see you pushed an update after this. Did you manage to get it fixed? In my experience when the lint:fix doesn't work it's because there is a syntax error preventing the linter from correctly parsing the file. Otherwise it will explicitly print what the error was that it couldn't fix. |
Codecov Report
@@ Coverage Diff @@
## main #2349 +/- ##
=======================================
Coverage 92.77% 92.77%
=======================================
Files 145 145
Lines 5220 5221 +1
Branches 1069 1070 +1
=======================================
+ Hits 4843 4844 +1
Misses 377 377
|
packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts
Outdated
Show resolved
Hide resolved
Couldn't fix it yet. Looks like my IDE enforces a shorter line width (when calling "Option + Shift + F") which is something that is not configured in eslint.config.js for the project. Do you happen to know what is the value currently used in the project? |
reverted the changes manually (it wasn't fun). ready for review :) |
If it's not in the config it most likely uses the default value. |
I'm not very familiar with linting. Is the default value coming from the environment and can be potentially different in different setups? |
I think we should define a prettier config file in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
Which problem is this PR solving?
Fixes #1255
Fixes #2320
And fix an HTTP instrumentation test:
'should have 1 ended span when request throw on bad "options" object'
For HTTP instrumentation, the span for outgoing request is currently started (
startSpan
) without any attributes. Only later when response arrives, request and response attributes are calculated and set on it. This is problematic in 2 situations:startSpan
function call (on the options). Request attributes are already available at this point, but since they are not sent to startSpan, sampling is impossible for this case.Additionally, there is a test for HTTP instrumentation called
'should have 1 ended span when request throw on bad "options" object'
, which callshttp.request
assuming it will throw, and then asserting in thecatch
block, but the function did not actually throw, so the test didn't check anything at all.Short description of the changes
I moved the request attributes calculation to happen before starting the span (instead of doing it when response arrive), which solves the 2 issues above.
I also changed the mentioned test so it actually throws an error, and added assertions in it for the logic I changed in the code.