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 panic in otelhttptrace #3892

Merged
merged 4 commits into from Jun 1, 2023
Merged

Fix panic in otelhttptrace #3892

merged 4 commits into from Jun 1, 2023

Conversation

@Alkorin Alkorin requested review from a team, Aneurysm9 and dmathieu as code owners May 29, 2023 12:56
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented May 29, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: Alkorin / name: Thomas Soëte (d42e293)

Copy link
Member

@pellared pellared left a comment

Choose a reason for hiding this comment

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

Can you please add test(s)?

@codecov
Copy link

codecov bot commented May 29, 2023

Codecov Report

Merging #3892 (9ebb157) into main (ba7a210) will increase coverage by 0.0%.
The diff coverage is 100.0%.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #3892   +/-   ##
=====================================
  Coverage   79.3%   79.4%           
=====================================
  Files        165     165           
  Lines      10426   10426           
=====================================
+ Hits        8278    8284    +6     
+ Misses      2012    2006    -6     
  Partials     136     136           
Impacted Files Coverage Δ
...on/net/http/httptrace/otelhttptrace/clienttrace.go 79.0% <100.0%> (+2.5%) ⬆️

@Alkorin
Copy link
Contributor Author

Alkorin commented May 29, 2023

Done

Copy link
Member

@pellared pellared left a comment

Choose a reason for hiding this comment

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

The test is flaky.

When I run go test -count=100 it always fails.
Personally, I would look into possible synchronization issues.
From https://pkg.go.dev/net/http/httptrace#ClientTrace:

Functions may be called concurrently from different goroutines and some may be called after the request has completed or failed.

(Not directly related to this PR). If I understand this correctly it may even mean that the current implementation may contain logical race conditions as I do not see how activeHooks synchronizes multiple concurrent HTTP requests.

Wait100Continue trace event is sent here before "http.receive" phase which results with a panic
@Alkorin
Copy link
Contributor Author

Alkorin commented May 30, 2023

True, the lock on https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/instrumentation/net/http/httptrace/otelhttptrace/clienttrace.go#L235 may introduce a context switch and the span is recorded after the end of the request.

Test updated

Copy link
Member

@pellared pellared left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution 👍

I updated the changelog.

@pellared pellared merged commit f9e088e into open-telemetry:main Jun 1, 2023
22 checks passed
@MrAlias MrAlias added this to the v0.43.0 milestone Aug 28, 2023
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

Successfully merging this pull request may close these issues.

None yet

5 participants