fix(exporter/otlp): support non-standard types as attribute values and log body#5239
Open
grvmishra788 wants to merge 3 commits into
Open
fix(exporter/otlp): support non-standard types as attribute values and log body#5239grvmishra788 wants to merge 3 commits into
grvmishra788 wants to merge 3 commits into
Conversation
…c-methods - Use str(Path(...)) as expected value so tests pass on Windows (backslash separator) - Add pylint disable for too-many-public-methods on TestCommonEncoder (21 methods)
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Passing a
pathlib.Path(or any other type outside the OTLPAnyValuespec) as a span/log attribute value or log body caused the OTLP exporter to crash:Both the proto-common and json-common OTLP encoders (
_encode_value()) had no fallback for unrecognised types. This PR adds astr()best-effort fallback before raising, so non-standard types are encoded as their string representation instead of crashing the exporter. Ifstr()itself raises, the original exception propagates unchanged.The fix mirrors the existing
_clean_extended_attribute_value()behaviour in the SDK and is applied consistently across both encoder implementations.Fixes #5210.
Type of change
How Has This Been Tested?
None-handling tests (allow_null=True/False) and list-with-Noneerror paths all pass unchanged.Does This PR Require a Contrib Repo Change?
Checklist: