-
Notifications
You must be signed in to change notification settings - Fork 859
fix(config): allow deflate for OTLP HTTP exporters #5075
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
base: main
Are you sure you want to change the base?
Changes from all commits
2d6ea11
b01dfc6
43831ef
2ad5daf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,8 @@ | |
| import logging | ||
| from typing import Optional | ||
|
|
||
| from opentelemetry.sdk._configuration._exceptions import ConfigurationError | ||
|
|
||
| _logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
|
|
@@ -47,3 +49,33 @@ def _parse_headers( | |
| for pair in headers: | ||
| result[pair.name] = pair.value or "" | ||
| return result | ||
|
|
||
|
|
||
| def _map_compression( | ||
| value: str | None, | ||
| compression_enum: type, | ||
| *, | ||
| allow_deflate: bool = False, | ||
| ) -> object | None: | ||
| """Map a compression string to the given Compression enum value.""" | ||
| if value is None: | ||
| return None | ||
|
|
||
| value_lower = value.lower() | ||
| supports_deflate = allow_deflate and hasattr(compression_enum, "Deflate") | ||
|
|
||
| if value_lower == "none": | ||
| return None | ||
| if value_lower == "gzip": | ||
| return compression_enum.Gzip # type: ignore[attr-defined] | ||
| if value_lower == "deflate" and supports_deflate: | ||
| return compression_enum.Deflate # type: ignore[attr-defined] | ||
|
|
||
| supported_values = ["'gzip'", "'none'"] | ||
|
Contributor
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. We can probably move this code to up towards the beginning of the function and update lines 66-68 to just check if
Author
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. Moved the normalization into the shared helper path so the supported-value check uses |
||
| if supports_deflate: | ||
| supported_values.insert(1, "'deflate'") | ||
|
|
||
| raise ConfigurationError( | ||
| f"Unsupported compression value '{value}'. Supported values: " | ||
| f"{', '.join(supported_values)}." | ||
| ) | ||
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.
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.
Applied the changelog wording while rebasing the branch.