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

fix(http): do not set outgoing http span as active in the context #1479 #1546

Merged
merged 5 commits into from
Oct 13, 2020

Conversation

vmarchaud
Copy link
Member

See #1479 for motivation

@vmarchaud vmarchaud self-assigned this Sep 19, 2020
@vmarchaud vmarchaud added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 19, 2020
@codecov
Copy link

codecov bot commented Sep 19, 2020

Codecov Report

Merging #1546 into master will decrease coverage by 0.01%.
The diff coverage is 87.50%.

@@            Coverage Diff             @@
##           master    #1546      +/-   ##
==========================================
- Coverage   91.50%   91.48%   -0.02%     
==========================================
  Files         165      165              
  Lines        5036     5036              
  Branches     1025     1025              
==========================================
- Hits         4608     4607       -1     
- Misses        428      429       +1     
Impacted Files Coverage Δ
packages/opentelemetry-plugin-http/src/http.ts 97.26% <87.50%> (-0.55%) ⬇️

@vmarchaud vmarchaud changed the title fix: do not set outgoing http span as active in the context #1479 fix(http): do not set outgoing http span as active in the context #1479 Sep 19, 2020
@vmarchaud vmarchaud linked an issue Sep 20, 2020 that may be closed by this pull request
Copy link
Member

@dyladan dyladan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with @blumamir's suggested test, but this seems like a good idea to me.

@obecny
Copy link
Member

obecny commented Sep 21, 2020

@vmarchaud this PR duplicates similar stuff I fixed here -> #1541

@blumamir
Copy link
Member

@obecny This PR only removes the withSpan from outgoing HTTP requests. Your PR Still has it. What am I missing?

@obecny
Copy link
Member

obecny commented Sep 22, 2020

@obecny This PR only removes the withSpan from outgoing HTTP requests. Your PR Still has it. What am I missing?

maybe I'm missing something but trying to analyze possible merge between 2 prs and wondering if it won't be either duplicated or the outcome will be different for both cases.

@vmarchaud
Copy link
Member Author

vmarchaud commented Sep 22, 2020

@vmarchaud this PR duplicates similar stuff I fixed here -> #1541

You are right however that wasn't the goal of the PR in the first place. I think we could merge your PR first and then i will rebase my PR to remove the tracer.withSpan.

@vmarchaud vmarchaud marked this pull request as draft September 22, 2020 13:17
@obecny
Copy link
Member

obecny commented Sep 22, 2020

@vmarchaud this PR duplicates similar stuff I fixed here -> #1541

You are right however that wasn't the goal of the PR in the first place. I think we could merge your PR first and then i will rebase my PR to remove the tracer.withSpan.

make sense, thx :)

@vmarchaud vmarchaud marked this pull request as ready for review October 6, 2020 09:44
@vmarchaud
Copy link
Member Author

I've rebased the PR, i believe this is a simpler fix than #1541 that does involves injecting anything in the context.

@vmarchaud
Copy link
Member Author

cc @open-telemetry/javascript-approvers Would like more review to ship it in the next release please !

@dyladan
Copy link
Member

dyladan commented Oct 7, 2020

Motivating example for those not sure.

Scenario: You want to make 2 requests. The second request should not be made until after the first request completes.

With fix:

const parent = tracer.startSpan("parent");

tracer.withSpan(parent, () => {
	console.log(tracer.getActiveSpan().name); // parent
	http.get(url, (res) => { // new span is created by the http plugin
		res.resume() // discard response data
		res.on('end', () => {
			// inside this callback, the http.GET span should NOT be active
			console.log(tracer.getActiveSpan().name); // parent - Success!
            
            // the span for this request is a sibling of the first request as expected
			http.get(url, (res) => {/* elided */}) 
		})
	});
});

without fix

const parent = tracer.startSpan("parent");

tracer.withSpan(parent, () => {
	console.log(tracer.getActiveSpan().name); // parent
	http.get(url, (res) => { // new span is created by the http plugin
		res.resume() // discard response data
		res.on('end', () => {
			// inside this callback, the http.GET span should NOT be active
			console.log(tracer.getActiveSpan().name); // GET - Oh no! D:  <-------- bug here
            
            // the span for this request is a child of the first request
            // even though it is not _caused_by_ the first request.
			http.get(url, (res) => {/* elided */}) 
		})
	});
});

@obecny obecny added the bug Something isn't working label Oct 9, 2020
@vmarchaud
Copy link
Member Author

@mwear Would be really nice to review this one so we can ship it with 0.12 ? Thanks

@dyladan dyladan merged commit 4b5b023 into open-telemetry:master Oct 13, 2020
@mwear
Copy link
Member

mwear commented Oct 14, 2020

@mwear Would be really nice to review this one so we can ship it with 0.12 ? Thanks

Sorry I missed the boat on this @vmarchaud.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Context mixup when using wreck library to make downstream request
6 participants