-
Notifications
You must be signed in to change notification settings - Fork 761
Fix for FASTAPI unable to record AppService URL (Issue #3654) #3670
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
Open
rads-1996
wants to merge
9
commits into
open-telemetry:main
Choose a base branch
from
rads-1996:fix-fastapi-url
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+339
−17
Open
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7789448
Fix for FASTAPI unable to record AppService URL
rads-1996 92e8582
Fixed tests and pylint errors
rads-1996 06fe0a0
Merge branch 'main' into fix-fastapi-url
rads-1996 ba85358
Fixed ruff format
rads-1996 b5a670f
Merge branch 'fix-fastapi-url' of https://github.com/rads-1996/opente…
rads-1996 81f521a
Updated CHANGELOG
rads-1996 bd5f31f
Updated CHANGELOG
rads-1996 c536cb9
Merge branch 'main' into fix-fastapi-url
rads-1996 7ba7f95
Merge branch 'main' into fix-fastapi-url
rads-1996 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -445,15 +445,28 @@ def get_host_port_url_tuple(scope): | |
"""Returns (host, port, full_url) tuple.""" | ||
server = scope.get("server") or ["0.0.0.0", 80] | ||
port = server[1] | ||
|
||
host_header = asgi_getter.get(scope, "host") | ||
if host_header: | ||
host_value = host_header[0] | ||
# Ensure host_value is a string, not bytes | ||
if isinstance(host_value, bytes): | ||
host_value = host_value.decode("utf-8") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use the already created |
||
|
||
url_host = host_value | ||
|
||
else: | ||
url_host = server[0] + (":" + str(port) if str(port) != "80" else "") | ||
server_host = server[0] + (":" + str(port) if str(port) != "80" else "") | ||
|
||
# using the scope path is enough, see: | ||
# - https://asgi.readthedocs.io/en/latest/specs/www.html#http-connection-scope (see: root_path and path) | ||
# - https://asgi.readthedocs.io/en/latest/specs/www.html#wsgi-compatibility (see: PATH_INFO) | ||
# PATH_INFO can be derived by stripping root_path from path | ||
# -> that means that the path should contain the root_path already, so prefixing it again is not necessary | ||
# - https://wsgi.readthedocs.io/en/latest/definitions.html#envvar-PATH_INFO | ||
full_path = scope.get("path", "") | ||
http_url = scope.get("scheme", "http") + "://" + server_host + full_path | ||
http_url = scope.get("scheme", "http") + "://" + url_host + full_path | ||
return server_host, port, http_url | ||
|
||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.