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

feat: Improve urlencoding logic + bug fixes #4338

Merged
merged 2 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/phoenix-otel/src/phoenix/otel/otel.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def __init__(self, *args: Any, **kwargs: Any):
if bound_args.arguments.get("endpoint") is None:
_, endpoint = _normalized_endpoint(None)
bound_args.arguments["endpoint"] = endpoint
super().__init__(*args, **kwargs)
super().__init__(**bound_args.arguments)
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure I know the difference. lol

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This didnt pipe in the headers if a user set them for our GRPCExporter :(



def _maybe_http_endpoint(parsed_endpoint: ParseResult) -> bool:
Expand Down
11 changes: 5 additions & 6 deletions packages/phoenix-otel/src/phoenix/otel/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,19 @@ def parse_env_headers(s: str) -> Dict[str, str]:
match = _HEADER_PATTERN.fullmatch(header.strip())
if not match:
parts = header.split("=", 1)
if len(parts) == 2:
name, value = parts
encoded_header = f"{urllib.parse.quote(name)}={urllib.parse.quote(value)}"
name, value = parts
encoded_header = f"{urllib.parse.quote(name)}={urllib.parse.quote(value)}"
match = _HEADER_PATTERN.fullmatch(encoded_header.strip())
if not match:
_logger.warning(
"Header format invalid! Header values in environment variables must be "
"URL encoded: %s",
header,
f"{name}: ****",
)
continue
_logger.warning(
f"Header values in environment variables should be URL encoded, ``{header}`` "
f"was urlencoded to: ``{encoded_header}``"
"Header values in environment variables should be URL encoded, attempting to "
"URL encode header: {name}: ****"
Comment on lines +62 to +74
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure I know what's being fixed here. Can you update the description?

)

name, value = header.split("=", 1)
Expand Down
Loading